From 4d8aa2c3df1e03a199bf4f77ee30a98bcfd93da1 Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Tue, 3 Feb 2026 14:33:59 +0800 Subject: [PATCH] test: improve EditCustomCollectionModal tests with async handling and schema updates --- .../tools/edit-custom-collection-modal/index.spec.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/app/components/tools/edit-custom-collection-modal/index.spec.tsx b/web/app/components/tools/edit-custom-collection-modal/index.spec.tsx index 848412f0ac..b993b6a779 100644 --- a/web/app/components/tools/edit-custom-collection-modal/index.spec.tsx +++ b/web/app/components/tools/edit-custom-collection-modal/index.spec.tsx @@ -168,10 +168,16 @@ describe('EditCustomCollectionModal', () => { const schemaInput = screen.getByPlaceholderText('tools.createTool.schemaPlaceHolder') fireEvent.change(schemaInput, { target: { value: '{}' } }) + // Wait for parseParamsSchema to be called and state to be updated await waitFor(() => { 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 () => { fireEvent.click(screen.getByText('common.operation.save')) }) @@ -181,6 +187,10 @@ describe('EditCustomCollectionModal', () => { provider: 'provider', schema: '{}', schema_type: 'openapi', + icon: { + content: '🕵️', + background: '#FEF7C3', + }, credentials: { auth_type: 'none', },