Skip to content

test: deflake the ipyleaflet Playwright lifecycle test - #354

Merged
cpsievert merged 1 commit into
mainfrom
fix-ipyleaflet-flaky-lifecycle
Oct 28, 2026
Merged

cpsievert merged 1 commit into
mainfrom
fix-ipyleaflet-flaky-lifecycle

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Closes #353

Summary

test_render_ipyleaflet_rerender_lifecycle intermittently fails in CI with a live-view count mismatch (assert 10 == 9, seen on PR #324's unrelated run). The test samples the browser's widget view registry immediately after DOM-level assertions (.leaflet-container count, marker present), but LeafletMapModel views attach and detach asynchronously, so the sample can catch a partially settled registry.

This is the same race that #342 fixed for the bqplot and keplergl lifecycle tests via wait_for_stable_view_count(). The ipyleaflet test couldn't use that helper because it counts views per model class (client_models() filtered by _model_name) rather than globally via _liveViews.size.

Changes:

  • Add wait_for_stable_model_view_count(page, model_name) to tests/playwright/conftest.py: a per-model counterpart to wait_for_stable_view_count() that polls the summed live-view count for a given _model_name until it stops changing between 500ms polls.
  • Use it for both the initial and final samples in test_render_ipyleaflet_rerender_lifecycle.

Verification

  • uv run pytest tests/playwright/render_ipyleaflet/test_render_ipyleaflet.py -x -q — 10 passed
  • uv run pytest tests/playwright/render_bqplot/test_render_bqplot.py::test_bqplot_rerender_lifecycle -x -q (other lifecycle-test consumer of the conftest) — passed
  • make check-format and pyright clean

Note: other tests sample client_models() the same way (e.g. ipysigma, plotnine, jscatter); this PR keeps scope to the ipyleaflet flake from #353, but the new helper is available if any of those flake too.

Closes #353

test_render_ipyleaflet_rerender_lifecycle samples the browser's view
registry right after DOM-level assertions, but LeafletMapModel views
attach/detach asynchronously, so the sample can catch a partially
settled registry (seen in CI: assert 10 == 9).

Add wait_for_stable_model_view_count() -- a per-model counterpart to
the wait_for_stable_view_count() helper introduced for the bqplot and
keplergl deflake (#342) -- and use it for both samples in the test.
@cpsievert
cpsievert marked this pull request as ready for review October 27, 2026 23:44
@cpsievert
cpsievert merged commit b6f187d into main Oct 28, 2026
5 checks passed
@cpsievert
cpsievert deleted the fix-ipyleaflet-flaky-lifecycle branch October 28, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: test_render_ipyleaflet_rerender_lifecycle (async view-count race)

1 participant