Repository navigation
Synchronize browser test request assertions - #789
Open
MorganHo001 wants to merge 1 commit into
Open
MorganHo001 wants to merge 1 commit into
MorganHo001 wants to merge 1 commit into
Conversation
MorganHo001
requested review from
ColtenOuO,
alanhc and
jserv
as code owners
November 19, 2026 15:41
jserv
reviewed
Nov 19, 2026
Advancing fake time does not guarantee a result poll has reached its Playwright route handler. An enabled Practice editor also does not prove the asynchronous room join has completed. Both tests can check their counts before setup is ready. Wait for the intercepted poll and the existing room-join observable before checking pending-result and cache-restoration behavior. Keep the count, result, editor and unload-warning assertions, and bound the poll wait with the test timeout. Change-Id: I95ae4339a0f0e4f7c4f39e1aa0b9b1e1e72463b1
MorganHo001
force-pushed
the
fix-task-result-poll-wait
branch
from
November 20, 2026 01:46
cb78c16 to
0f7a224
Compare
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/browser/task-workspace.test.js">
<violation number="1" location="tests/browser/task-workspace.test.js:3265">
P2: `await answered` only waits for the network response event, not for `pollReview` to finish handling it. The late 202 can still be processed after the `#outcome` and `#review-content` assertions, so the test can pass without covering the guard. Wait for the page-side effect, for example by polling `st.reviewPolling` or the rendered state, before advancing the clock and asserting.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| await page.locator("#review").waitFor({ state: "visible" }); | ||
| const answered = page.waitForResponse("**/api/task-reviews/**"); | ||
| for (const release of releases) release(); | ||
| await answered; |
There was a problem hiding this comment.
P2: await answered only waits for the network response event, not for pollReview to finish handling it. The late 202 can still be processed after the #outcome and #review-content assertions, so the test can pass without covering the guard. Wait for the page-side effect, for example by polling st.reviewPolling or the rendered state, before advancing the clock and asserting.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/browser/task-workspace.test.js, line 3265:
<comment>`await answered` only waits for the network response event, not for `pollReview` to finish handling it. The late 202 can still be processed after the `#outcome` and `#review-content` assertions, so the test can pass without covering the guard. Wait for the page-side effect, for example by polling `st.reviewPolling` or the rendered state, before advancing the clock and asserting.</comment>
<file context>
@@ -3260,7 +3260,9 @@ test(
await page.locator("#review").waitFor({ state: "visible" });
+ const answered = page.waitForResponse("**/api/task-reviews/**");
for (const release of releases) release();
+ await answered;
await page.clock.runFor(1000);
assert.match(await page.locator("#outcome").textContent(), /invalid/);
</file context>
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.
The result-poll regression can check its held-request count before Playwright dispatches the request to the route handler, as seen in this browser 3/3 run. The cached Practice test can also check its join count after the editor is enabled but before the room connection completes.
Wait for the intercepted poll and the existing room-join observable before checking pending results and cache restoration. Keep the count, result, editor and unload-warning assertions. A 30-second test timeout bounds the poll wait. Production code is unchanged.
Validation
0 !== 1; the fixed test passes.fetch-gate-note-tests,run-budget-tests,review-memory-tests,interactive-review-hook-testsandgit-hooks. The failures include temporary-path differences, empty RSS samples, missingghand a missing formatter. Optional ruff, shellcheck and actionlint are unavailable. Rust was not rerun for this test-only change.Summary by cubic
Fixes flaky browser tests that could check request and join counts before async setup finished.
Both tests could assert on counts before the underlying async work completed: the result-poll test checked the held-request count before Playwright dispatched the request to the route handler, and the cached Practice test checked the join count before the room connection finished. The tests now wait for the intercepted poll and the room-join observable before asserting, and the poll wait is bounded by a 30-second test timeout. Production code is unchanged.
Written for commit 0f7a224. Summary will update on new commits.