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 <adhabal2002@gmail.com>

* fix: revalidate teams cache after creating team in onboarding flow

Co-Authored-By: anik@cal.com <adhabal2002@gmail.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>
This commit is contained in:
Anik Dhabal Babu
2026-01-06 11:14:28 +05:30
committed by GitHub
co-authored by anik@cal.com <adhabal2002@gmail.com> anik@cal.com <adhabal2002@gmail.com> Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 6672fd4c3d
commit fca818a275
@@ -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<typeof import("@calcom/app-store/crm.apps.generated")>();
@@ -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,