fix: use real cache key prefixes in mock and dynamic imports for CI compatibility

This commit is contained in:
2026-03-09 03:08:15 -05:00
parent 15ef24eb3e
commit ad7507d133
2 changed files with 26 additions and 17 deletions
+9 -9
View File
@@ -33,16 +33,16 @@ function createStablePrismaMock(
* (some Bun versions do not enumerate Proxy keys for static imports).
*/
function buildCacheMock(overrides: Record<string, any> = {}) {
const keyFn = (...args: any[]) => `mock:key:${args.join(":")}`;
return {
// Key helpers
activityCacheKey: mock(keyFn),
companyCwCacheKey: mock(keyFn),
notesCacheKey: mock(keyFn),
contactsCacheKey: mock(keyFn),
productsCacheKey: mock(keyFn),
siteCacheKey: mock(keyFn),
oppCwDataCacheKey: mock(keyFn),
// Key helpers — use real prefixes so cross-file mock leaks don't
// break opportunityCache.test.ts key assertions.
activityCacheKey: mock((id: number) => `opp:activities:${id}`),
companyCwCacheKey: mock((id: number) => `opp:company-cw:${id}`),
notesCacheKey: mock((id: number) => `opp:notes:${id}`),
contactsCacheKey: mock((id: number) => `opp:contacts:${id}`),
productsCacheKey: mock((id: number) => `opp:products:${id}`),
siteCacheKey: mock((a: number, b: number) => `opp:site:${a}:${b}`),
oppCwDataCacheKey: mock((id: number) => `opp:cw-data:${id}`),
// Read helpers
getCachedActivities: mock(() => Promise.resolve(null)),
getCachedCompanyCwData: mock(() => Promise.resolve(null)),