From cde1a0b73c3fd33f83dd993b2a25100c714d033f Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 23 May 2026 17:23:16 -0700 Subject: [PATCH] test(platform-service): align getAllProducts test with invttrdg fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI run 67 surfaced a real test failure: src/modules/products/cache.test.ts:104 getAllProducts > returns all cached products expected [ { id: 'lysnrai', …(11) }, …(2) ] to have a length of 2 but got 3 Root cause: cache.ts has a TEMPORARY_FALLBACK_PRODUCTS map (currently just 'invttrdg') that getAllProducts() merges into its return value on top of the loaded cache. The test fixture loads 2 products (lysnrai, mindlyst), so the actual return is 3 — the test was written before the fallback shim landed and never got updated. Two ways to reconcile: (a) make the test reflect today's behaviour, or (b) gut the fallback. The cache.ts comment explicitly marks the fallback as 'TODO(platform): remove after creating the real product …', so the right move is (a): keep the shim in place and make the test enforce the documented contract. - assertion now: toHaveLength(3) + .toContain('invttrdg') - inline comment ties the expectation back to cache.ts so a future cleanup removing the fallback will obviously need to drop it back to 2 Verified locally: pnpm vitest run cache.test.ts -> 8/8 pass --- .../src/modules/products/cache.test.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/services/platform-service/src/modules/products/cache.test.ts b/services/platform-service/src/modules/products/cache.test.ts index d16b7264..b19a70e7 100644 --- a/services/platform-service/src/modules/products/cache.test.ts +++ b/services/platform-service/src/modules/products/cache.test.ts @@ -9,7 +9,13 @@ vi.mock('./repository.js', () => ({ })); import { getAll } from './repository.js'; -import { loadProductCache, getProduct, isValidProduct, getAllProducts, cacheSize } from './cache.js'; +import { + loadProductCache, + getProduct, + isValidProduct, + getAllProducts, + cacheSize, +} from './cache.js'; const mockGetAll = vi.mocked(getAll); @@ -97,13 +103,19 @@ describe('product cache', () => { }); describe('getAllProducts', () => { - it('returns all cached products', async () => { + it('returns all cached products (plus temporary fallback products)', async () => { mockGetAll.mockResolvedValue(products); await loadProductCache(); const all = getAllProducts(); - expect(all).toHaveLength(2); + // The cache holds 2 products (lysnrai, mindlyst) and getAllProducts() + // additionally injects entries from TEMPORARY_FALLBACK_PRODUCTS that + // are not already in the cache. Today that set is { invttrdg }, so + // the total is 3. When the invttrdg fallback is removed (see + // cache.ts TODO), this expectation should drop back to 2. + expect(all).toHaveLength(3); expect(all.map(p => p.id)).toContain('lysnrai'); expect(all.map(p => p.id)).toContain('mindlyst'); + expect(all.map(p => p.id)).toContain('invttrdg'); }); });