Repository navigation
Synchronize browser test request assertions #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3224,44 +3224,57 @@ test("a Finish dialog open when the attempt ends closes and finishes nothing", a | |||||||
| } | ||||||||
| }); | ||||||||
|
|
||||||||
| test("a result poll still on its way neither repeats nor replaces the delivered result", async (t) => { | ||||||||
| const ctx = await pageFor(t); | ||||||||
| if (!ctx) return; | ||||||||
| const { page } = ctx; | ||||||||
| let held = 0; | ||||||||
| const releases = []; | ||||||||
| try { | ||||||||
| await start(page); | ||||||||
| await page.route("**/api/task-reviews/**", async (route) => { | ||||||||
| held += 1; | ||||||||
| await new Promise((resolve) => releases.push(resolve)); | ||||||||
| await route.fulfill({ | ||||||||
| status: 202, | ||||||||
| contentType: "application/json", | ||||||||
| body: JSON.stringify({ pending: true }), | ||||||||
| }); | ||||||||
| test( | ||||||||
| "a result poll still on its way neither repeats nor replaces the delivered result", | ||||||||
| { timeout: 30000 }, | ||||||||
| async (t) => { | ||||||||
| const ctx = await pageFor(t); | ||||||||
| if (!ctx) return; | ||||||||
| const { page } = ctx; | ||||||||
| let held = 0; | ||||||||
| const releases = []; | ||||||||
| let polling; | ||||||||
| const pollStarted = new Promise((resolve) => { | ||||||||
| polling = resolve; | ||||||||
| }); | ||||||||
| await page.evaluate(() => document.exitFullscreen()); | ||||||||
| // Past the delivery window, with the first poll still unanswered. | ||||||||
| await page.clock.runFor(301000); | ||||||||
| assert.equal(held, 1); | ||||||||
| await page.evaluate( | ||||||||
| (value) => globalThis.taskHarness.publish("task_review", value), | ||||||||
| result("invalid", "fullscreen"), | ||||||||
| ); | ||||||||
| await page.locator("#review").waitFor({ state: "visible" }); | ||||||||
| for (const release of releases) release(); | ||||||||
| await page.clock.runFor(1000); | ||||||||
| assert.match(await page.locator("#outcome").textContent(), /invalid/); | ||||||||
| assert.doesNotMatch( | ||||||||
| await page.locator("#review-content").textContent(), | ||||||||
| /still being finalized|unavailable/i, | ||||||||
| ); | ||||||||
| } finally { | ||||||||
| for (const release of releases) release(); | ||||||||
| await page.close(); | ||||||||
| } | ||||||||
| }); | ||||||||
| try { | ||||||||
| await start(page); | ||||||||
| await page.route("**/api/task-reviews/**", async (route) => { | ||||||||
| held += 1; | ||||||||
| polling(); | ||||||||
| await new Promise((resolve) => releases.push(resolve)); | ||||||||
| await route.fulfill({ | ||||||||
| status: 202, | ||||||||
| contentType: "application/json", | ||||||||
| body: JSON.stringify({ pending: true }), | ||||||||
| }); | ||||||||
| }); | ||||||||
| await page.evaluate(() => document.exitFullscreen()); | ||||||||
| // Past the delivery window, with the first poll still unanswered. | ||||||||
| await page.clock.runFor(301000); | ||||||||
| // Advancing the page clock does not flush Playwright's network events. | ||||||||
| await pollStarted; | ||||||||
| assert.equal(held, 1); | ||||||||
| await page.evaluate( | ||||||||
| (value) => globalThis.taskHarness.publish("task_review", value), | ||||||||
| result("invalid", "fullscreen"), | ||||||||
| ); | ||||||||
| 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); | ||||||||
|
MorganHo001 marked this conversation as resolved.
Resolved
|
||||||||
| assert.match(await page.locator("#outcome").textContent(), /invalid/); | ||||||||
| assert.doesNotMatch( | ||||||||
| await page.locator("#review-content").textContent(), | ||||||||
| /still being finalized|unavailable/i, | ||||||||
| ); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is named for a poll that "neither repeats", but
Suggested change
|
||||||||
| } finally { | ||||||||
| for (const release of releases) release(); | ||||||||
| await page.close(); | ||||||||
| } | ||||||||
| }, | ||||||||
| ); | ||||||||
|
|
||||||||
| test("an ended attempt lets go of a wake lock granted late and of its detector", async (t) => { | ||||||||
| const ctx = await pageFor(t); | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2:
await answeredonly waits for the network response event, not forpollReviewto finish handling it. The late 202 can still be processed after the#outcomeand#review-contentassertions, so the test can pass without covering the guard. Wait for the page-side effect, for example by pollingst.reviewPollingor the rendered state, before advancing the clock and asserting.Prompt for AI agents