Skip to content

Commit 2fc630e

Browse files
fix: mock delegationCredential in getRoutedUsers test to prevent flaky worker shutdown errors (calcom#28603)
* fix: mock delegationCredential in getRoutedUsers test to prevent flaky worker shutdown errors The getRoutedUsers.test.ts file only tests the pure sync function getRoutedUsersWithContactOwnerAndFixedUsers, but importing getRoutedUsers.ts triggers a heavy transitive import chain: getRoutedUsers.ts -> @calcom/app-store/delegationCredential -> _utils/getCalendar -> calendar.services.generated (all calendar services) -> CalendarService.ts -> ics/tsdav Sometimes the vitest worker finishes tests and shuts down before all async module resolution completes, causing: Error: [vitest-worker]: Closing rpc while "fetch" was pending Mock @calcom/app-store/delegationCredential to cut off the import chain since the tested function doesn't use it. * Clean up comments in getRoutedUsers.test.ts Removed comments about mocking delegationCredential to improve code clarity.
1 parent b436f33 commit 2fc630e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/features/users/lib/getRoutedUsers.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { describe, it, expect, vi } from "vitest";
2-
1+
import { describe, expect, it, vi } from "vitest";
32
import { getRoutedUsersWithContactOwnerAndFixedUsers } from "./getRoutedUsers";
43

54
vi.mock("@calcom/prisma", () => {
@@ -8,6 +7,12 @@ vi.mock("@calcom/prisma", () => {
87
};
98
});
109

10+
vi.mock("@calcom/app-store/delegationCredential", () => {
11+
return {
12+
enrichHostsWithDelegationCredentials: vi.fn().mockResolvedValue([]),
13+
};
14+
});
15+
1116
describe("getRoutedUsersWithContactOwnerAndFixedUsers", () => {
1217
const users = [
1318
{ id: 1, email: "user1@example.com", isFixed: false },

0 commit comments

Comments
 (0)