Skip to content

fix(test): Combine scroll checks into a single stabilized bottom script#2261

Open
karangattu wants to merge 4 commits into
mainfrom
still-not-fixed
Open

fix(test): Combine scroll checks into a single stabilized bottom script#2261
karangattu wants to merge 4 commits into
mainfrom
still-not-fixed

Conversation

@karangattu
Copy link
Copy Markdown
Collaborator

Merge the previous two JS helpers into a single SETTLED_AT_BOTTOM_SCRIPT used by the test to avoid a race between settle-then-check. The new script: simplifies variable names, increases bottom tolerance (20px) to account for subpixel rounding/layout shifts, and requires consecutive stable reads at the bottom across multiple polls before returning true. The test now uses one wait_for_function with 250ms polling (removing the extra short wait), reducing flakiness in auto-scroll assertions.

Merge the previous two JS helpers into a single SETTLED_AT_BOTTOM_SCRIPT used by the test to avoid a race between settle-then-check. The new script: simplifies variable names, increases bottom tolerance (20px) to account for subpixel rounding/layout shifts, and requires consecutive stable reads at the bottom across multiple polls before returning true. The test now uses one wait_for_function with 250ms polling (removing the extra short wait), reducing flakiness in auto-scroll assertions.
Wrap the wait_for_function scroll assertion in a try/except to capture and surface element state (scrollTop, scrollHeight, clientHeight, __stableCount, __lastScrollTop) when the assertion fails, raising a RuntimeError with those details. Also inject an init script that converts smooth scrolling to instant (behavior: 'auto') by overriding Element.prototype.scroll and scrollTo to make scrolling deterministic and faster under CI, improving test reliability for the MarkdownStream basic test.
Add a style element to the test's init script that forces scroll-behavior: auto !important globally, ensuring smooth scrolling completes instantly and deterministically under CI. Retains the existing Element.prototype.scroll override and streamlines the page.add_init_script call formatting in tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py.
Make the MarkdownStream Playwright test more deterministic by forcing instantaneous scrolling and explicitly scrolling containers to the bottom. Add el.scrollTop = el.scrollHeight to the settled check script and introduce a reusable forceAuto wrapper to override additional Element and window scroll methods (scrollBy, scrollIntoView, window.scroll*, etc.) so smooth behavior is coerced to auto. Also call page.evaluate to set the card-body scrollTop before asserting the stream is scrolled to bottom.
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.

1 participant