mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
test: improve EditCustomCollectionModal tests with async handling and schema updates
This commit is contained in:
@ -168,10 +168,16 @@ describe('EditCustomCollectionModal', () => {
|
|||||||
const schemaInput = screen.getByPlaceholderText('tools.createTool.schemaPlaceHolder')
|
const schemaInput = screen.getByPlaceholderText('tools.createTool.schemaPlaceHolder')
|
||||||
fireEvent.change(schemaInput, { target: { value: '{}' } })
|
fireEvent.change(schemaInput, { target: { value: '{}' } })
|
||||||
|
|
||||||
|
// Wait for parseParamsSchema to be called and state to be updated
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(parseParamsSchemaMock).toHaveBeenCalledWith('{}')
|
expect(parseParamsSchemaMock).toHaveBeenCalledWith('{}')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Wait for the async useEffect to complete and update schema_type
|
||||||
|
await act(async () => {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 0))
|
||||||
|
})
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
fireEvent.click(screen.getByText('common.operation.save'))
|
fireEvent.click(screen.getByText('common.operation.save'))
|
||||||
})
|
})
|
||||||
@ -181,6 +187,10 @@ describe('EditCustomCollectionModal', () => {
|
|||||||
provider: 'provider',
|
provider: 'provider',
|
||||||
schema: '{}',
|
schema: '{}',
|
||||||
schema_type: 'openapi',
|
schema_type: 'openapi',
|
||||||
|
icon: {
|
||||||
|
content: '🕵️',
|
||||||
|
background: '#FEF7C3',
|
||||||
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
auth_type: 'none',
|
auth_type: 'none',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user