-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: removes a/b match email experiment, defaults to old email
- Loading branch information
1 parent
3ae2751
commit 7663d0f
Showing
8 changed files
with
24 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,8 @@ import type { SupportRequest, ZendeskTicket, ZendeskUser } from "../../types"; | |
import * as zendeskClient from "../../zendeskClient"; | ||
import * as emailClient from "../../emailClient"; | ||
import * as getCurrentDate from "../../utils/getCurrentDate"; | ||
import * as saveBusaraABExperiment from "../../utils/saveBusaraABExperiment"; | ||
import { prismaMock } from "../../setupTests"; | ||
import { AB_TRANSACTIONAL_EMAIL_IDS, AGENT } from "../../constants"; | ||
import { AGENT, TRANSACTIONAL_EMAIL_IDS } from "../../constants"; | ||
|
||
const getCurrentDateMock = jest.spyOn(getCurrentDate, "default"); | ||
const createTicketMock = jest.spyOn(zendeskClient, "createTicket"); | ||
|
@@ -18,10 +17,6 @@ const sendEmailToVolunteerMock = jest.spyOn( | |
emailClient, | ||
"sendEmailToVolunteer" | ||
); | ||
const saveBusaraABExperimentMock = jest.spyOn( | ||
saveBusaraABExperiment, | ||
"default" | ||
); | ||
jest.spyOn(global.Math, "random").mockReturnValue(0.7); | ||
|
||
const mockVolunteerZendeskTicket = { | ||
|
@@ -50,7 +45,6 @@ const mockMsrFromZendesk = { | |
email: "[email protected]", | ||
} as ZendeskUser; | ||
const mockCurrentDate = "2023-12-28"; | ||
const mockMatchId = 1; | ||
|
||
describe("createAndUpdateZendeskMatchTickets", () => { | ||
getCurrentDateMock.mockImplementation(() => mockCurrentDate); | ||
|
@@ -64,8 +58,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
await expect( | ||
createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
) | ||
).rejects.toThrow("Couldn't fetch volunteer from db or msr from zendesk"); | ||
}); | ||
|
@@ -77,8 +70,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
await expect( | ||
createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
) | ||
).rejects.toThrow("Couldn't fetch volunteer from db or msr from zendesk"); | ||
}); | ||
|
@@ -91,8 +83,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
await expect( | ||
createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
) | ||
).rejects.toThrow("Couldn't create volunteer match ticket"); | ||
}); | ||
|
@@ -117,8 +108,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
it("should return correct volunteer zendesk ticket id", async () => { | ||
const volunteerZendeskTicketId = await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(volunteerZendeskTicketId).toStrictEqual(123123123); | ||
}); | ||
|
@@ -157,8 +147,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
}; | ||
await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(createTicketMock).toHaveBeenNthCalledWith(1, volunteerTicket); | ||
}); | ||
|
@@ -193,47 +182,30 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
}; | ||
await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(updateTicketMock).toHaveBeenNthCalledWith(1, msrTicket); | ||
}); | ||
|
||
it("should call send email to MSR with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(sendEmailToMsrMock).toHaveBeenCalledWith( | ||
{ | ||
...mockMsrFromZendesk, | ||
zendeskTicketId: legalSupportRequest["zendeskTicketId"], | ||
}, | ||
mockVolunteerFromDB, | ||
AB_TRANSACTIONAL_EMAIL_IDS["legal"]["b"] | ||
); | ||
}); | ||
|
||
it("should call saveBusaraABExperiment with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
TRANSACTIONAL_EMAIL_IDS["legal"]["msr"] | ||
); | ||
expect(saveBusaraABExperimentMock).toHaveBeenCalledWith({ | ||
msrId: legalSupportRequest.msrId, | ||
supportRequestId: legalSupportRequest.supportRequestId, | ||
transactionalId: AB_TRANSACTIONAL_EMAIL_IDS["legal"]["b"], | ||
matchId: mockMatchId, | ||
}); | ||
}); | ||
|
||
it("should call send email to volunteer with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
legalSupportRequest, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(sendEmailToVolunteerMock).toHaveBeenCalledWith( | ||
{ | ||
|
@@ -261,8 +233,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
it("should return correct volunteer zendesk ticket id", async () => { | ||
const volunteerZendeskTicketId = await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(volunteerZendeskTicketId).toStrictEqual(123123123); | ||
}); | ||
|
@@ -274,8 +245,7 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
}; | ||
await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(createTicketMock).toHaveBeenNthCalledWith( | ||
1, | ||
|
@@ -313,47 +283,30 @@ describe("createAndUpdateZendeskMatchTickets", () => { | |
}; | ||
await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(updateTicketMock).toHaveBeenNthCalledWith(1, msrTicket); | ||
}); | ||
|
||
it("should call send email to MSR with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(sendEmailToMsrMock).toHaveBeenCalledWith( | ||
{ | ||
...mockMsrFromZendesk, | ||
zendeskTicketId: baseSupportRequestPayload["zendeskTicketId"], | ||
}, | ||
mockVolunteerFromDB, | ||
AB_TRANSACTIONAL_EMAIL_IDS["psychological"]["b"] | ||
); | ||
}); | ||
|
||
it("should call saveBusaraABExperiment with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
TRANSACTIONAL_EMAIL_IDS["psychological"]["msr"] | ||
); | ||
expect(saveBusaraABExperimentMock).toHaveBeenCalledWith({ | ||
msrId: baseSupportRequestPayload.msrId, | ||
supportRequestId: baseSupportRequestPayload.supportRequestId, | ||
transactionalId: AB_TRANSACTIONAL_EMAIL_IDS["psychological"]["b"], | ||
matchId: mockMatchId, | ||
}); | ||
}); | ||
|
||
it("should call send email to volunteer with correct params", async () => { | ||
await createAndUpdateZendeskMatchTickets( | ||
baseSupportRequestPayload, | ||
mockVolunteerId, | ||
mockMatchId | ||
mockVolunteerId | ||
); | ||
expect(sendEmailToVolunteerMock).toHaveBeenCalledWith( | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.