Skip to content

Synchronize browser test request assertions - #789

Open
MorganHo001 wants to merge 1 commit into
sysprog21:mainfrom
MorganHo001:fix-task-result-poll-wait
Open

MorganHo001 wants to merge 1 commit into
sysprog21:mainfrom
MorganHo001:fix-task-result-poll-wait

Conversation

@MorganHo001

@MorganHo001 MorganHo001 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

  • With a controlled interception delay, the original poll test fails with 0 !== 1; the fixed test passes.
  • Temporarily removing the delivered-result guard still makes the fixed test fail.
  • The task-workspace file passes all 119 tests; both cached-interview cases pass.
  • Browser shard 3/3 passes 1,226 tests with no failures or skips locally.
  • The portable lane has five local failures: fetch-gate-note-tests, run-budget-tests, review-memory-tests, interactive-review-hook-tests and git-hooks. The failures include temporary-path differences, empty RSS samples, missing gh and 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.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

ColtenOuO
ColtenOuO previously approved these changes Nov 19, 2026

@ColtenOuO ColtenOuO left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread tests/browser/task-workspace.test.js Resolved
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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

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.

3 participants