mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 13:26:58 +08:00
test(web): fix two flaky web tests (Build exit timeout, HITL contact lookup error) (#45542)
This commit is contained in:
1 parent
7de3c2938c
commit
063dcbad5c
3 files changed
+16
-12
No files matched your search
Generated
-10
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user