Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

test(web): fix two flaky web tests (Build exit timeout, HITL contact lookup error) (#45542)

Stephen Zhou063dcbad5cbf
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index dbb1213acbf..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
@@ -1433,11 +1428,6 @@
"count": 1
}
},
- "web/app/components/base/image-uploader/__tests__/uploader.spec.tsx": {
- "typescript/no-deprecated": {
- "count": 4
- }
- },
"web/app/components/base/image-uploader/__tests__/utils.spec.ts": {
"typescript/no-deprecated": {
"count": 1
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()