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
53 changes: 51 additions & 2 deletions __tests__/workers/newNotificationV2Mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2823,7 +2823,7 @@ describe('recruiter_new_candidate notification', () => {
opportunityId: opportunitiesFixture[0].id,
userId: candidate!.id,
applicationRank: {
score: 85,
score: 8.6799,
description: 'Strong JS skills',
},
});
Expand Down Expand Up @@ -2855,7 +2855,56 @@ describe('recruiter_new_candidate notification', () => {
candidate_name: 'Ido',
profile_picture: 'https://daily.dev/ido.jpg',
job_title: 'Senior Full Stack Developer',
score: '85%',
score: '8.7/10',
matching_content: 'Strong JS skills',
candidate_link: `http://localhost:5002/recruiter/${opportunitiesFixture[0].id}/matches`,
});
});

it('should show N/A label when no application score', async () => {
await saveFixtures(con, DatasetLocation, datasetLocationsFixture);
await saveFixtures(con, Organization, organizationsFixture);
await saveFixtures(con, Opportunity, opportunitiesFixture);

const candidate = await con.getRepository(User).findOneBy({ id: '1' });

// Create match with application rank score
await con.getRepository(OpportunityMatch).save({
opportunityId: opportunitiesFixture[0].id,
userId: candidate!.id,
applicationRank: {
description: 'Strong JS skills',
},
});

const ctx: NotificationRecruiterNewCandidateContext = {
userIds: ['2'],
opportunityId: opportunitiesFixture[0].id,
candidate: candidate!,
};

const notificationId = await saveNotificationV2Fixture(
con,
NotificationType.RecruiterNewCandidate,
ctx,
);

await expectSuccessfulBackground(worker, {
notification: {
id: notificationId,
userId: '2',
},
});

expect(sendEmail).toHaveBeenCalledTimes(1);
const args = jest.mocked(sendEmail).mock
.calls[0][0] as SendEmailRequestWithTemplate;

expect(args.message_data).toEqual({
candidate_name: 'Ido',
profile_picture: 'https://daily.dev/ido.jpg',
job_title: 'Senior Full Stack Developer',
score: 'N/A',
matching_content: 'Strong JS skills',
candidate_link: `http://localhost:5002/recruiter/${opportunitiesFixture[0].id}/matches`,
});
Expand Down
4 changes: 2 additions & 2 deletions src/workers/newNotificationV2Mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,8 @@ const notificationToTemplateData: Record<NotificationType, TemplateDataFunc> = {
const candidateName = candidateAvatar.name;
const candidatePicture = candidateAvatar.image;
const matchScore = match?.applicationRank?.score
? `${Math.round(match.applicationRank.score)}%`
: '';
? `${match.applicationRank.score.toFixed(1)}/10`
: 'N/A';
const matchingContent = match?.applicationRank?.description || '';

return {
Expand Down
Loading