Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions __tests__/njord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
]);
});

Expand All @@ -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';

Expand Down
3 changes: 3 additions & 0 deletions src/schema/njord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ export const resolvers: IResolvers<unknown, BaseContext> = {
(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'`,
)
Expand Down
Loading