fix: resolve CI test failures — explicit cache mock exports, hoisted service mocks, pinned Bun 1.3.6
This commit is contained in:
@@ -25,17 +25,49 @@ function createStablePrismaMock(
|
||||
);
|
||||
}
|
||||
|
||||
/** Build a complete cache mock — any unspecified export returns a mock fn. */
|
||||
/**
|
||||
* Build a complete cache mock with explicit named exports.
|
||||
*
|
||||
* Uses concrete properties instead of a Proxy so that Bun's ESM mock
|
||||
* resolution can discover every named export at module-link time
|
||||
* (some Bun versions do not enumerate Proxy keys for static imports).
|
||||
*/
|
||||
function buildCacheMock(overrides: Record<string, any> = {}) {
|
||||
return new Proxy(overrides, {
|
||||
get(target, prop: string) {
|
||||
if (prop in target) return target[prop];
|
||||
// Key helpers return strings; everything else returns a mock fn
|
||||
if (prop.endsWith("CacheKey") || prop.endsWith("DataCacheKey"))
|
||||
return mock((...args: any[]) => `mock:${prop}:${args.join(":")}`);
|
||||
return mock(() => Promise.resolve(null));
|
||||
},
|
||||
});
|
||||
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),
|
||||
// Read helpers
|
||||
getCachedActivities: mock(() => Promise.resolve(null)),
|
||||
getCachedCompanyCwData: mock(() => Promise.resolve(null)),
|
||||
getCachedNotes: mock(() => Promise.resolve(null)),
|
||||
getCachedContacts: mock(() => Promise.resolve(null)),
|
||||
getCachedProducts: mock(() => Promise.resolve(null)),
|
||||
getCachedSite: mock(() => Promise.resolve(null)),
|
||||
getCachedOppCwData: mock(() => Promise.resolve(null)),
|
||||
// Write / fetch helpers
|
||||
fetchAndCacheActivities: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheCompanyCwData: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheNotes: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheContacts: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheProducts: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheSite: mock(() => Promise.resolve(null)),
|
||||
fetchAndCacheOppCwData: mock(() => Promise.resolve(null)),
|
||||
// Invalidation helpers
|
||||
invalidateNotesCache: mock(() => Promise.resolve()),
|
||||
invalidateContactsCache: mock(() => Promise.resolve()),
|
||||
invalidateProductsCache: mock(() => Promise.resolve()),
|
||||
invalidateAllOpportunityCaches: mock(() => Promise.resolve()),
|
||||
// Background refresh
|
||||
refreshOpportunityCache: mock(() => Promise.resolve()),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user