From 406eddabce17657681c1ba6cfe500566b9f235fc Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Sun, 18 Oct 2026 01:56:21 +0000 Subject: [PATCH] test(agent): make completed-turn approval action test deterministic The answer does reach the endpoint after the turn completes; the expected-fail only "failed" when the 202 receipt retired the card before the aria-busy assertion ran. Hold the mocked answer until the busy state is asserted and drop test.fail so the test is a positive guard. Co-Authored-By: Claude Opus 5.5 --- browser_tests/tests/agent/agentReplyDrafts.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/browser_tests/tests/agent/agentReplyDrafts.spec.ts b/browser_tests/tests/agent/agentReplyDrafts.spec.ts index ee72d7a71f5..bacafffd246 100644 --- a/browser_tests/tests/agent/agentReplyDrafts.spec.ts +++ b/browser_tests/tests/agent/agentReplyDrafts.spec.ts @@ -247,12 +247,17 @@ test.describe('Agent reply drafts', { tag: ['@cloud', '@agent'] }, () => { test.setTimeout(60_000) const askId = `${MESSAGE_ID}:call-${selection}` const answeredRequests: Array<{ url: string; selected: string[] }> = [] + let releaseAnswer = () => {} + const answerReleased = new Promise((resolve) => { + releaseAnswer = resolve + }) await page.route( '**/api/agent/threads/*/asks/*/answer', async (route) => { const request = route.request() const body = zAgentAnswerRequest.parse(request.postDataJSON()) answeredRequests.push({ url: request.url(), selected: body.selected }) + await answerReleased await route.fulfill({ ...jsonRoute({ status: 'answered' }), status: 202 @@ -294,10 +299,6 @@ test.describe('Agent reply drafts', { tag: ['@cloud', '@agent'] }, () => { await expect(action).toBeVisible() await action.click() - test.fail( - true, - 'The approval card remains visible after its turn completes, but its action no longer reaches the answer endpoint.' - ) await expect .poll(() => answeredRequests) .toEqual([ @@ -309,6 +310,7 @@ test.describe('Agent reply drafts', { tag: ['@cloud', '@agent'] }, () => { } ]) await expect(action).toHaveAttribute('aria-busy', 'true') + releaseAnswer() send({ type: 'agent_ask_resolved', data: {