Skip to content

Commit f1e3fa2

Browse files
authored
fix: test cases for opportunity preview (#3336)
1 parent 790c29e commit f1e3fa2

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

__tests__/schema/opportunity.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5815,3 +5815,104 @@ describe('mutation createSharedSlackChannel', () => {
58155815
expect(res.errors).toBeTruthy();
58165816
});
58175817
});
5818+
5819+
describe('query opportunityPreview', () => {
5820+
const OPPORTUNITY_PREVIEW_QUERY = /* GraphQL */ `
5821+
query OpportunityPreview($first: Int, $after: String) {
5822+
opportunityPreview(first: $first, after: $after) {
5823+
edges {
5824+
node {
5825+
id
5826+
anonId
5827+
topTags
5828+
}
5829+
cursor
5830+
}
5831+
pageInfo {
5832+
hasNextPage
5833+
hasPreviousPage
5834+
startCursor
5835+
endCursor
5836+
}
5837+
result {
5838+
tags
5839+
companies {
5840+
name
5841+
favicon
5842+
}
5843+
squads {
5844+
id
5845+
handle
5846+
}
5847+
totalCount
5848+
opportunityId
5849+
}
5850+
}
5851+
}
5852+
`;
5853+
5854+
beforeEach(async () => {
5855+
trackingId = 'test-anon-user-123';
5856+
});
5857+
5858+
afterEach(() => {
5859+
trackingId = undefined;
5860+
});
5861+
5862+
it('should return preview with opportunityId', async () => {
5863+
// Create an opportunity with cached preview data
5864+
await con.getRepository(OpportunityJob).update(
5865+
{ id: opportunitiesFixture[0].id },
5866+
{
5867+
flags: {
5868+
anonUserId: 'test-anon-user-123',
5869+
preview: {
5870+
userIds: ['1', '2'],
5871+
totalCount: 2,
5872+
},
5873+
},
5874+
},
5875+
);
5876+
5877+
const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, {
5878+
variables: { first: 10 },
5879+
});
5880+
5881+
expect(res.errors).toBeFalsy();
5882+
expect(res.data.opportunityPreview).toBeDefined();
5883+
expect(res.data.opportunityPreview.result).toBeDefined();
5884+
expect(res.data.opportunityPreview.result.opportunityId).toBe(
5885+
opportunitiesFixture[0].id,
5886+
);
5887+
expect(res.data.opportunityPreview.result.totalCount).toBe(2);
5888+
});
5889+
5890+
it('should return opportunity preview result structure', async () => {
5891+
await con.getRepository(OpportunityJob).update(
5892+
{ id: opportunitiesFixture[0].id },
5893+
{
5894+
flags: {
5895+
anonUserId: 'test-anon-user-123',
5896+
preview: {
5897+
userIds: ['1'],
5898+
totalCount: 1,
5899+
},
5900+
},
5901+
},
5902+
);
5903+
5904+
const res = await client.query(OPPORTUNITY_PREVIEW_QUERY, {
5905+
variables: { first: 10 },
5906+
});
5907+
5908+
expect(res.errors).toBeFalsy();
5909+
const result = res.data.opportunityPreview.result;
5910+
expect(result).toMatchObject({
5911+
opportunityId: opportunitiesFixture[0].id,
5912+
totalCount: 1,
5913+
tags: expect.any(Array),
5914+
companies: expect.any(Array),
5915+
squads: expect.any(Array),
5916+
});
5917+
});
5918+
});

0 commit comments

Comments
 (0)