From d5dcc5ee6c770bf8aa9c7c6ba378ec8c367a6509 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 23 Sep 2026 23:12:51 -0700 Subject: [PATCH] fix(search): wait for the source-created handler in the live setup test The live service-source test asserted updateSearchIntegration immediately after the create onSuccess act, but onCreated awaits the nuqs URL-state reset (which flushes asynchronously) before it starts the mutation, so the assertion raced the flush and failed most runs. Wait for it the same way the sibling setup test already does (vi.waitFor with a 1ms interval). --- .../integrations/search-source-setup.test.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/sim/app/o/[organizationId]/settings/components/integrations/search-source-setup.test.tsx b/apps/sim/app/o/[organizationId]/settings/components/integrations/search-source-setup.test.tsx index f9ad3c4022f..605ef2986ec 100644 --- a/apps/sim/app/o/[organizationId]/settings/components/integrations/search-source-setup.test.tsx +++ b/apps/sim/app/o/[organizationId]/settings/components/integrations/search-source-setup.test.tsx @@ -604,17 +604,21 @@ describe('organization setup entry points', () => { connector({ id: 'new-gmail', connectorType: 'gmail', accessMode: 'admin' }) ) ) - expect(mocks.updateSearchIntegration).toHaveBeenCalledWith( - { - organizationId: 'org-1', - connectorType: 'gmail', - approved: true, - policy: expect.objectContaining({ - accessMode: 'service_account', - sourceId: 'new-gmail', - }), - }, - expect.any(Object) + await vi.waitFor( + () => + expect(mocks.updateSearchIntegration).toHaveBeenCalledWith( + { + organizationId: 'org-1', + connectorType: 'gmail', + approved: true, + policy: expect.objectContaining({ + accessMode: 'service_account', + sourceId: 'new-gmail', + }), + }, + expect.any(Object) + ), + { interval: 1 } ) expect(mocks.push).not.toHaveBeenCalled() await act(async () => mocks.updateSearchIntegration.mock.calls[0][1].onSuccess())