Commit dcbb417
authored
fix: use Proxy-based CalendarServiceMap mock to prevent test flakes (calcom#28787)
* fix: add vi.mock calls to prevent InstantBookingCreateService test flake
Add two vi.mock() calls ported from cal repo to prevent
'Closing rpc while fetch was pending' errors:
1. Mock @calcom/app-store/calendar.services.generated with a Proxy
to prevent real calendar modules (feishu, lark) from triggering
async getAppAccessToken fetch calls during test worker shutdown.
2. Mock @calcom/features/ee/organizations/di/OrganizationRepository.container
to prevent deep transitive import chain from triggering a Vitest
module-resolution RPC still in flight at shutdown.
Also removes the narrow feishucalendar mock which is now covered by
the broader calendar.services.generated Proxy mock.
* fix: update bookingScenario to use Proxy-based CalendarServiceMap
Replace the plain-object CalendarServiceMap mock with a Proxy-based
implementation that catches ALL calendar service accesses. This prevents
real calendar modules (feishu, lark, etc.) from being imported during
tests, which was causing 'Closing rpc while fetch was pending' errors
when the Vitest worker shut down.
Also update mockCalendar to use a shared mock map directly instead of
dynamically importing calendar.services.generated, avoiding loading
real calendar service modules during test execution.1 parent 77eb4c8 commit dcbb417
File tree
2 files changed
+192
-166
lines changed- packages
- features/bookings/lib/service
- testing/src/lib/bookingScenario
2 files changed
+192
-166
lines changedLines changed: 31 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | 4 | | |
7 | | - | |
8 | 5 | | |
9 | | - | |
| 6 | + | |
10 | 7 | | |
11 | 8 | | |
| 9 | + | |
| 10 | + | |
12 | 11 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 12 | | |
17 | | - | |
| 13 | + | |
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
21 | | - | |
22 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
23 | 41 | | |
24 | 42 | | |
25 | | - | |
26 | | - | |
| 43 | + | |
| 44 | + | |
27 | 45 | | |
28 | 46 | | |
29 | 47 | | |
| |||
257 | 275 | | |
258 | 276 | | |
259 | 277 | | |
260 | | - | |
261 | | - | |
262 | | - | |
| 278 | + | |
263 | 279 | | |
264 | 280 | | |
265 | 281 | | |
| |||
0 commit comments