From 3f004a588e4ba9824c401af90e0530ad7d9f2133 Mon Sep 17 00:00:00 2001 From: Chris Bongers Date: Tue, 21 Jul 2026 15:43:02 +0200 Subject: [PATCH] fix(njord): exclude non-award products from the products catalog Streak freeze products share the product table and were leaking into the award picker, which only filtered on the restricted flag. Co-Authored-By: Claude Fable 5 --- __tests__/njord.ts | 23 +++++++++++++++++++++++ src/schema/njord.ts | 3 +++ 2 files changed, 26 insertions(+) diff --git a/__tests__/njord.ts b/__tests__/njord.ts index 9e923b2cbd..1064ad05e1 100644 --- a/__tests__/njord.ts +++ b/__tests__/njord.ts @@ -814,6 +814,16 @@ describe('query products', () => { restricted: true, }, }, + { + id: 'e1c2a9d0-5b4f-4f8a-8c3d-7f6e9a0b1c2d', + name: 'Streak freeze 3-pack', + image: 'https://daily.dev/freeze.jpg', + type: ProductType.StreakFreeze, + value: 80, + flags: { + quantity: 3, + }, + }, ]); }); @@ -830,6 +840,19 @@ describe('query products', () => { ).not.toContain('b3d9d8b1-1f2e-4c3a-9d6f-2a5e7c1b0f4d'); }); + it('should exclude non-award products from the catalog', async () => { + loggedUser = 't-awpm-1'; + + const res = await client.query(QUERY); + + expect(res.errors).toBeFalsy(); + expect( + res.data.products.edges.map( + ({ node }: { node: { id: string } }) => node.id, + ), + ).not.toContain('e1c2a9d0-5b4f-4f8a-8c3d-7f6e9a0b1c2d'); + }); + it('should return products sorted by value', async () => { loggedUser = 't-awpm-1'; diff --git a/src/schema/njord.ts b/src/schema/njord.ts index 3b9958f688..9af9ac38ca 100644 --- a/src/schema/njord.ts +++ b/src/schema/njord.ts @@ -321,6 +321,9 @@ export const resolvers: IResolvers = { (node, index) => pageGenerator.nodeToCursor(page, args, node, index), (builder) => { builder.queryBuilder + .andWhere(`${builder.alias}.type = :type`, { + type: ProductType.Award, + }) .andWhere( `(${builder.alias}.flags->>'restricted') IS DISTINCT FROM 'true'`, )