Skip to content

Synchronize browser test request assertions - #789

Merged
jserv merged 1 commit into
sysprog21:mainfrom
MorganHo001:fix-task-result-poll-wait
Nov 21, 2026
Merged

jserv merged 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. The first intercepted poll has a separate five-second deadline. A 60-second outer test budget leaves room for Playwright's 30-second waits to report their own errors and run cleanup first. 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.
  • At 96d33f60, both changed browser files pass all 194 tests locally. Browser shard 3/3 passes 1,229 tests with no failures or skips in an Ubuntu ARM64 VM.
  • An earlier full macOS browser run recorded 3,622 passes, one failure and 33 skips. The failure is the classic-scrollbar precondition; skips require ffmpeg or Java.
  • An earlier portable run had 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 assert request and join counts before async setup 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. Both tests now wait for the intercepted poll and the room-join observable before asserting; the poll wait has its own bound plus the 60-second test timeout and verifies pending state after a full interval while keeping repeated-request checks independent of interception delivery. Production code is unchanged.

Written for commit 96d33f6. 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.

jserv

This comment was marked as resolved.

cubic-dev-ai[bot]

This comment was marked as resolved.

jserv

This comment was marked as resolved.

jserv

This comment was marked as resolved.

@MorganHo001
MorganHo001 force-pushed the fix-task-result-poll-wait branch from 7f39f22 to f006947 Compare November 21, 2026 02:53

@Disesfgewu Disesfgewu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checked out f006947 on macOS 26.6 arm64 with Node v24.21.0 and Playwright Chromium:

  • node --test tests/browser/task-workspace.test.js: 119 pass, 0 fail, 0 skipped
  • node --test --test-name-pattern="cached .* interview preserves" tests/browser/strict-selection.test.js: 2 pass, 0 fail

The poll fix works for me. With the if (st.attempt === "done") return; guard after the fetch removed from pollReview, the test fails on /invalid/, so the late-answer half is covered. The two inline comments are about the end of the test: a held check that cannot fail, and a wait that is now redundant.

Comment thread tests/browser/task-workspace.test.js Resolved
Comment thread tests/browser/task-workspace.test.js Resolved
@MorganHo001
MorganHo001 force-pushed the fix-task-result-poll-wait branch from f006947 to e6c5031 Compare November 21, 2026 11:35

@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.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/browser/task-workspace.test.js Resolved

@matthiola0 matthiola0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All three tests passed at e6c5031a and with the suggested edits. Windows 11, Node.js v22.23.1, Playwright 1.64.1 (Chromium).

node --test --test-name-pattern="a result poll still on its way|a cached (strict|practice) interview preserves" tests/browser/task-workspace.test.js tests/browser/strict-selection.test.js

Comment thread tests/browser/task-workspace.test.js Resolved
Comment thread tests/browser/strict-selection.test.js Resolved
alanhc
alanhc previously approved these changes Nov 21, 2026

@alanhc alanhc 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. I read e6c5031 against 7f39f22, and both browser files pass at this head, 194/194.

  • With runFor(5000), the closing held check now catches a repeated poll. I removed stopAttemptTimers(); from renderReview and st.attempt === "done" || from pollReview, as Disesfgewu did, and the test failed with 2 !== 1 in 3 of 3 runs. It passed 3 of 3 with the code unchanged.
  • That also answers the open cubic thread: the repeated request reaches the route before held is read, since the two textContent reads come first. The check still depends on that ordering, so it is worth keeping in mind if the assertions move.
  • Dropping answered is fine. reviewPolling turns false only after api() returns, so the waitForFunction covers the same point.

matthiola0's two suggestions would make failures clearer but do not change what is covered.

@jserv

jserv commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Checked at e6c5031.

Fake time can advance before a review request reaches its route handler.
An enabled Practice editor also precedes the asynchronous room join, so
both regressions can check their counts before setup settles.

Wait for the intercepted poll and first join before asserting counts.
Bound the poll wait separately and check pending state after a full
interval, keeping repeated-request checks independent of interception
delivery. Retain result, editor, unload-warning and exact join counts.

Change-Id: I69ad3f4fa4276c4fa950342ac97439208b2d8ff9
@MorganHo001
MorganHo001 force-pushed the fix-task-result-poll-wait branch from e6c5031 to 96d33f6 Compare November 21, 2026 15:58
@jserv
jserv merged commit 7a591ea into sysprog21:main Nov 21, 2026
20 checks passed
@jserv

jserv commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Thank @MorganHo001 for contributing!

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.

6 participants