From 6d354c084049e0dac2b1593748663689eab00ff9 Mon Sep 17 00:00:00 2001 From: Chris Bongers Date: Wed, 10 Dec 2025 10:23:39 +0200 Subject: [PATCH 1/2] fix: test cases for opportunity preview --- __tests__/schema/opportunity.ts | 126 ++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/__tests__/schema/opportunity.ts b/__tests__/schema/opportunity.ts index 5d5a05c416..9500f538fe 100644 --- a/__tests__/schema/opportunity.ts +++ b/__tests__/schema/opportunity.ts @@ -5715,3 +5715,129 @@ describe('mutation createSharedSlackChannel', () => { expect(res.errors).toBeTruthy(); }); }); + +describe('query opportunityPreview', () => { + const OPPORTUNITY_PREVIEW_QUERY = /* GraphQL */ ` + query OpportunityPreview($first: Int, $after: String) { + opportunityPreview(first: $first, after: $after) { + edges { + node { + id + anonId + topTags + } + cursor + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + result { + tags + companies { + name + favicon + } + squads { + id + handle + } + totalCount + opportunityId + } + } + } + `; + + beforeEach(async () => { + trackingId = 'test-anon-user-123'; + }); + + afterEach(() => { + trackingId = undefined; + }); + + it('should return preview with opportunityId', async () => { + // Create an opportunity with cached preview data + await con.getRepository(OpportunityJob).update( + { id: opportunitiesFixture[0].id }, + { + flags: { + anonUserId: 'test-anon-user-123', + preview: { + userIds: ['1', '2'], + totalCount: 2, + }, + }, + }, + ); + + const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, { + variables: { first: 10 }, + }); + + expect(res.errors).toBeFalsy(); + expect(res.data.opportunityPreview).toBeDefined(); + expect(res.data.opportunityPreview.result).toBeDefined(); + expect(res.data.opportunityPreview.result.opportunityId).toBe( + opportunitiesFixture[0].id, + ); + expect(res.data.opportunityPreview.result.totalCount).toBe(2); + }); + + it('should handle pagination with first parameter', async () => { + await con.getRepository(OpportunityJob).update( + { id: opportunitiesFixture[0].id }, + { + flags: { + anonUserId: 'test-anon-user-123', + preview: { + userIds: ['1', '2', '3'], + totalCount: 3, + }, + }, + }, + ); + + const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, { + variables: { first: 2 }, + }); + + expect(res.errors).toBeFalsy(); + expect(res.data.opportunityPreview.edges).toHaveLength(2); + expect(res.data.opportunityPreview.result.opportunityId).toBe( + opportunitiesFixture[0].id, + ); + }); + + it('should return opportunity preview result structure', async () => { + await con.getRepository(OpportunityJob).update( + { id: opportunitiesFixture[0].id }, + { + flags: { + anonUserId: 'test-anon-user-123', + preview: { + userIds: ['1'], + totalCount: 1, + }, + }, + }, + ); + + const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, { + variables: { first: 10 }, + }); + + expect(res.errors).toBeFalsy(); + const result = res.data.opportunityPreview.result; + expect(result).toMatchObject({ + opportunityId: opportunitiesFixture[0].id, + totalCount: 1, + tags: expect.any(Array), + companies: expect.any(Array), + squads: expect.any(Array), + }); + }); +}); From 8b62af57945819925b9d453dee2b9f0d720df331 Mon Sep 17 00:00:00 2001 From: Chris Bongers Date: Wed, 10 Dec 2025 10:40:55 +0200 Subject: [PATCH 2/2] fix: remove useless test --- __tests__/schema/opportunity.ts | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/__tests__/schema/opportunity.ts b/__tests__/schema/opportunity.ts index 9500f538fe..07b88ff79c 100644 --- a/__tests__/schema/opportunity.ts +++ b/__tests__/schema/opportunity.ts @@ -5787,31 +5787,6 @@ describe('query opportunityPreview', () => { expect(res.data.opportunityPreview.result.totalCount).toBe(2); }); - it('should handle pagination with first parameter', async () => { - await con.getRepository(OpportunityJob).update( - { id: opportunitiesFixture[0].id }, - { - flags: { - anonUserId: 'test-anon-user-123', - preview: { - userIds: ['1', '2', '3'], - totalCount: 3, - }, - }, - }, - ); - - const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, { - variables: { first: 2 }, - }); - - expect(res.errors).toBeFalsy(); - expect(res.data.opportunityPreview.edges).toHaveLength(2); - expect(res.data.opportunityPreview.result.opportunityId).toBe( - opportunitiesFixture[0].id, - ); - }); - it('should return opportunity preview result structure', async () => { await con.getRepository(OpportunityJob).update( { id: opportunitiesFixture[0].id },