Skip to content

Commit c07c0b5

Browse files
committed
fix: add opportunity exposure
1 parent 49a6574 commit c07c0b5

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

__tests__/schema/opportunity.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,68 @@ describe('query userOpportunityMatches', () => {
14101410
period: 1, // ANNUAL
14111411
});
14121412
});
1413+
1414+
it('should include opportunity details when requested', async () => {
1415+
loggedUser = '1';
1416+
1417+
const GET_USER_MATCHES_WITH_OPPORTUNITY_QUERY = /* GraphQL */ `
1418+
query GetUserOpportunityMatchesWithOpportunity($first: Int) {
1419+
userOpportunityMatches(first: $first) {
1420+
edges {
1421+
node {
1422+
userId
1423+
opportunityId
1424+
status
1425+
updatedAt
1426+
opportunity {
1427+
id
1428+
title
1429+
state
1430+
location {
1431+
city
1432+
country
1433+
}
1434+
organization {
1435+
id
1436+
name
1437+
}
1438+
}
1439+
}
1440+
}
1441+
}
1442+
}
1443+
`;
1444+
1445+
const res = await client.query(GET_USER_MATCHES_WITH_OPPORTUNITY_QUERY, {
1446+
variables: {
1447+
first: 10,
1448+
},
1449+
});
1450+
1451+
expect(res.errors).toBeFalsy();
1452+
expect(res.data.userOpportunityMatches.edges).toHaveLength(2);
1453+
1454+
const matchWithOpportunity = res.data.userOpportunityMatches.edges.find(
1455+
(e: { node: { opportunityId: string } }) =>
1456+
e.node.opportunityId === '550e8400-e29b-41d4-a716-446655440001',
1457+
);
1458+
1459+
expect(matchWithOpportunity.node.opportunity).toEqual({
1460+
id: '550e8400-e29b-41d4-a716-446655440001',
1461+
title: 'Senior Full Stack Developer',
1462+
state: 2, // LIVE
1463+
location: [
1464+
{
1465+
city: null,
1466+
country: 'Norway',
1467+
},
1468+
],
1469+
organization: {
1470+
id: '550e8400-e29b-41d4-a716-446655440000',
1471+
name: 'Daily Dev Inc',
1472+
},
1473+
});
1474+
});
14131475
});
14141476

14151477
describe('query getCandidatePreferences', () => {

src/schema/opportunity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export const typeDefs = /* GraphQL */ `
221221
createdAt: DateTime!
222222
updatedAt: DateTime!
223223
user: User!
224+
opportunity: Opportunity
224225
candidatePreferences: UserCandidatePreference
225226
screening: [ScreeningAnswer!]!
226227
feedback: [ScreeningAnswer!]!

0 commit comments

Comments
 (0)