From fca818a275ea8437d8ea3fba626dab9456510c65 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:14:28 +0530 Subject: [PATCH] test: fix unit test flake (#25557) * fix: revalidate teams cache after accepting invite via token When a user accepts a team invite via token on the /teams page, the teams cache was not being invalidated. This caused the page to show stale data (empty list) while the sidebar correctly showed the teams. This fix adds a call to revalidateTeamsList() after processing an invite token, ensuring the cache is invalidated and fresh data is fetched immediately. Co-Authored-By: anik@cal.com * fix: revalidate teams cache after creating team in onboarding flow Co-Authored-By: anik@cal.com * Remove comments on teams cache revalidation Removed comments about revalidating teams cache after invite processing. * fix unit test flake * Remove unused import in useCreateTeam hook Removed unused import for revalidateTeamsList. * Remove unused import for revalidateTeamsList --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../utils/bookingScenario/bookingScenario.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/apps/web/test/utils/bookingScenario/bookingScenario.ts b/apps/web/test/utils/bookingScenario/bookingScenario.ts index aaf56f67c6..dc8ab938ae 100644 --- a/apps/web/test/utils/bookingScenario/bookingScenario.ts +++ b/apps/web/test/utils/bookingScenario/bookingScenario.ts @@ -2208,7 +2208,6 @@ export function mockCrmApp( }[] = []; const eventsCreated: boolean[] = []; - // Mock the CrmServiceMap directly instead of using the old app-store index approach vi.doMock("@calcom/app-store/crm.apps.generated", async (importOriginal) => { const original = await importOriginal(); @@ -2220,16 +2219,17 @@ export function mockCrmApp( createContact() { if (crmData?.createContacts) { contactsCreated = crmData.createContacts; - return Promise.resolve(crmData?.createContacts); + return Promise.resolve(crmData.createContacts); } return Promise.resolve([]); } getContacts(email: string) { if (crmData?.getContacts) { - contactsQueried = crmData?.getContacts; - const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email); - return Promise.resolve(contactsOfEmail); + contactsQueried = crmData.getContacts; + return Promise.resolve( + contactsQueried.filter((c) => c.email === email) + ); } return Promise.resolve([]); } @@ -2244,20 +2244,28 @@ export function mockCrmApp( ...original, CrmServiceMap: { ...original.CrmServiceMap, - [metadataLookupKey]: Promise.resolve({ + // ✅ IMPORTANT: no Promise here + [metadataLookupKey]: { default: MockCrmService, - }), + }, }, }; }); return { - contactsCreated, - contactsQueried, - eventsCreated, + get contactsCreated() { + return contactsCreated; + }, + get contactsQueried() { + return contactsQueried; + }, + get eventsCreated() { + return eventsCreated; + }, }; } + export function getBooker({ name, email,