From cb1908cf39ad26822226fc5c8a9046ac0ec3a4e9 Mon Sep 17 00:00:00 2001 From: Stephen Zhou Date: Wed, 4 Nov 2026 09:22:32 +0000 Subject: [PATCH] test(web): fix two flaky web tests (Build exit timeout, HITL contact lookup error) (#45542) --- oxlint-suppressions.json | 5 ----- .../human-input-v2/__tests__/recipients.spec.tsx | 5 ++++- .../configure/__tests__/page-build-session.spec.tsx | 13 ++++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json index fb1790064aa..80f50724af9 100644 --- a/oxlint-suppressions.json +++ b/oxlint-suppressions.json @@ -1285,11 +1285,6 @@ "count": 6 } }, - "web/app/components/base/file-uploader/file-from-link-or-local/__tests__/index.spec.tsx": { - "typescript/no-deprecated": { - "count": 1 - } - }, "web/app/components/base/file-uploader/file-from-link-or-local/index.tsx": { "better-tailwindcss/enforce-logical-properties": { "count": 3 diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/recipients.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/recipients.spec.tsx index fb5f81ddd67..e8357bcef3c 100644 --- a/web/app/components/workflow/nodes/human-input-v2/__tests__/recipients.spec.tsx +++ b/web/app/components/workflow/nodes/human-input-v2/__tests__/recipients.spec.tsx @@ -361,7 +361,10 @@ describe('recipient selection through generated queries', () => { screen.queryByText('workflow.nodes.humanInputV2.error.recipientInvalid'), ).not.toBeInTheDocument() await act(async () => fail(new Error('offline'))) - const failedChip = screen.getByLabelText('workflow.nodes.humanInputV2.recipients.loadError') + // React Query notifies observers on a later macrotask, which act() does not wait for. + const failedChip = await screen.findByLabelText( + 'workflow.nodes.humanInputV2.recipients.loadError', + ) expect(failedChip).not.toHaveAttribute('aria-invalid', 'true') expect(failedChip).toHaveAccessibleDescription(contactId) expect(within(failedChip).getByText(contactId)).toHaveClass('sr-only') diff --git a/web/features/agent-v2/agent-detail/configure/__tests__/page-build-session.spec.tsx b/web/features/agent-v2/agent-detail/configure/__tests__/page-build-session.spec.tsx index 07081df59a8..2749eb55dd4 100644 --- a/web/features/agent-v2/agent-detail/configure/__tests__/page-build-session.spec.tsx +++ b/web/features/agent-v2/agent-detail/configure/__tests__/page-build-session.spec.tsx @@ -212,7 +212,7 @@ describe('Leaving Build', () => { const discard = createDeferred<{ result: string }>() const view = createEnvironment({ buildDraft: createBuildDraft() }).render() api.discard.mockReturnValueOnce(discard.promise) - await send(user) + await send(user, 'build', 'Go') await receive() await changeMode(user, 'preview') await confirm(user) @@ -238,11 +238,22 @@ describe('Leaving Build', () => { await waitFor(() => expect(modeButton('preview')).toBeChecked()) expect(view.onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.get('mode')).toBe('preview') expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument() + }) + + it('ignores a late completion from the discarded run after re-entering Build', async () => { + const user = userEvent.setup() + createEnvironment({ buildDraft: createBuildDraft() }).render() + await send(user, 'build', 'Go') + await receive() + await changeMode(user, 'preview') + await confirm(user) + await waitFor(() => expect(modeButton('preview')).toBeChecked()) await changeMode(user, 'build') await waitFor(() => expect(modeButton('build')).toBeChecked()) vi.useFakeTimers({ shouldAdvanceTime: true }) await complete() await flushBuildRefresh() + vi.useRealTimers() expect(api.getBuildDraft).not.toHaveBeenCalled() expect(promptEditor()).toHaveAttribute('contenteditable', 'true') expect(screen.queryByText('Built answer')).not.toBeInTheDocument()