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): await document title updates in human input form spec (#45635)

Stephen Zhou8837791cc9ed
diff --git a/web/features/human-input/public/__tests__/form.spec.tsx b/web/features/human-input/public/__tests__/form.spec.tsx
index 919276cf156..474a4d6c39d 100644
--- a/web/features/human-input/public/__tests__/form.spec.tsx
+++ b/web/features/human-input/public/__tests__/form.spec.tsx
@@ -92,7 +92,7 @@ it('keeps incomplete approval available, identifies the invalid OTP, and submits
),
)
expect(await screen.findByRole('heading', { name: 'share.humanInput.thanks' })).toHaveFocus()
- expect(document.title).toBe('share.humanInput.thanks - Dify')
+ await waitFor(() => expect(document.title).toBe('share.humanInput.thanks - Dify'))
})
it('shows the clicked action as loading, preserves its focus, and prevents resend during submission', async () => {
@@ -186,7 +186,7 @@ it.each([
const request = vi.spyOn(transport, 'requestAccess')
render(<HumanInputV2Form token="form-token" transport={transport} />)
expect(await screen.findByText(text)).toBeVisible()
- expect(document.title).toBe(`${text} - Dify`)
+ await waitFor(() => expect(document.title).toBe(`${text} - Dify`))
expect(request).not.toHaveBeenCalled()
})
@@ -206,7 +206,7 @@ it.each([
/>,
)
expect(await screen.findByRole('heading', { name: text })).toBeVisible()
- expect(document.title).toBe(`${text} - Dify`)
+ await waitFor(() => expect(document.title).toBe(`${text} - Dify`))
expect(requestAccess).not.toHaveBeenCalled()
})
@@ -277,7 +277,7 @@ it('keeps retry focus through another failure and restores focus to verification
.mockReturnValue(pending.promise)
render(<HumanInputV2Form token="retry-form" transport={{ ...base, getForm }} />)
const retry = await screen.findByRole('button', { name: 'share.humanInputV2.retry' })
- expect(document.title).toBe('share.humanInputV2.unknownError - Dify')
+ await waitFor(() => expect(document.title).toBe('share.humanInputV2.unknownError - Dify'))
await user.click(retry)
expect(retry).toHaveFocus()
expect(retry).toHaveAttribute('aria-disabled', 'true')
@@ -290,7 +290,7 @@ it('keeps retry focus through another failure and restores focus to verification
expect(retry).toHaveFocus()
await act(async () => pending.resolve(definition))
expect(await screen.findByRole('textbox', { name: 'share.humanInputV2.otpLabel' })).toHaveFocus()
- expect(document.title).toBe('share.humanInputV2.otpLabel - Dify')
+ await waitFor(() => expect(document.title).toBe('share.humanInputV2.otpLabel - Dify'))
})
it('scopes attachment uploads to the displayed token and injected transport after navigation', async () => {