Repository navigation
Wait for site browser test states after actions instead of snapshotting them - #1331
Merged
Merged
Conversation
…ng them Every visibility, fold, URL and scroll check that follows a click, key press or navigation now waits with the default timeout: locator.waitFor, page.waitForURL, or a Node-side waitUntil for scroll positions, which page.waitForFunction cannot poll on pages without JavaScript. Part of #729. Closes #1326.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Site browser tests now wait for the state an action should produce, rather than reading it once straight after a click, key press or navigation.
isVisible()remains in the suite. The customtimeout: 2000/5000on waits are gone, so every wait uses the default.scrollYonly after the Space key's player appears.waitUntilexists becausepage.waitForFunctionnever re-checks on ajavaScriptEnabled: falsepage.locator.waitFordoes poll there.site/package.jsonis unchanged.Part of #729.
Closes #1326
Evidence
origin/mainpassed one local run. It relied on snapshot reads after actions, and I did not reproduce a flake locally. Probe of the alternative polling API on a page without JavaScript, where the DOM changes at 500ms:npm testinsite/at c4aaff3:scripts/affected-tests origin/mainpasses:npm test --prefix site(50/50),cargo test --test share_card --test site_deploy,cargo test --bin thirdshift prompts_page.Merge Danger
Door: two-way
Test-only change, plus one README paragraph. A revert restores the old assertions.
Blast Radius: tests
A wait that should fail now takes up to 30s to time out instead of failing at once. It still fails. Shipped site pages and the binary are untouched.
Review
The review used
origin/main(09d6d40) as the fixed point, because the localmainref was stale. Both reviewers read both changed files (site/tests/README.md,site/tests/pages.test.cjs), so no changed file went unread. Addressed: Standards 1 (the copied 30s default is now the namedDEFAULT_TIMEOUT_MS) and Standards 3 (scrolledIntoView→waitForScrolledIntoView). Neither axis found behaviour that is wrong.Unaddressed findings
Standards
waitUntilhas one caller. Declined.site/tests/README.mdnameswaitUntilas the suite's tool for "a reading no locator expresses", so it is the documented seam for future non-locator waits, not a hypothetical one.openFold(x).waitFor({ state: "detached" })reads indirectly as "wait for the fold to close". Declined. One locator for the open state, attached or detached, avoids a second helper for its negation, and theopenFoldcomment says it matches "only while it is open".unfoldGuide/checkSectionTogglesboth loop overmain h2. Declined. The two locators differ on purpose.checkSectionTogglesneeds the fold whether open or closed, to focus its summary and find its content.openFoldmust match only an open one. The loops do different things to each heading.waitForURLwithoutpath) and comments replacing messages. Declined as diagnostics only. Locator timeouts name their target, for examplelocator('#prompts-title').locator('xpath=ancestor::details[1][@open]')from the failure seen during development. A URL timeout's stack line points to the test and the loop.click({ timeout: 2000 })is the last explicit timeout (site/tests/pages.test.cjs:210). Declined. It bounds an action, not a state check. The issue asks for "visibility or state check[s]" to use the default timeout, and the README rule covers waits.Spec
waitUntil/waitForScrolledIntoVieware new, not "a polling helper already used in the suite". Declined. The suite had none (git show origin/main:site/tests/pages.test.cjs | rg -n "waitFor|poll"), and the only Playwright option,page.waitForFunction, times out without JavaScript. Both reviewers reproduced that with the probe in Evidence. Scroll position has no locator state.site/tests/README.md, and the paragraph records the rule this issue introduces.openFold(#prompts-title).waitFor({ state: "detached" }). Kept. It waits for the Prompts click to take effect before checking that Command is still open. Without it, that check would race the click this issue is about.click({ timeout: 2000 })and the copied30000. The constant is addressed above. The click timeout is declined as under Standards 6.Built with claude · claude-opus-5-5 · high
Security review outcome
No unaddressed introduced findings.