Merge pull request #1773 from Safelite/rlsmerge/2024.03.07-to-develop
Rlsmerge/2024.03.07 to develop
This commit is contained in:
commit
f64b92228d
1 changed files with 124 additions and 0 deletions
|
|
@ -2929,6 +2929,130 @@ describe("Actions", () => {
|
|||
});
|
||||
});
|
||||
describe("validateOrderPromoAndSaveServerData", () => {
|
||||
it("should add GUIDs if not there to provided lineItemsToUse.vaps before sending the http call", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
const promoCode = "testPromo";
|
||||
const lineItemsToUse = { vaps: [{ partNumber: 1 }], promos: [2] };
|
||||
const addableVaps = [{ partNumber: "addableVap" }];
|
||||
|
||||
context["getters"] = {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
appointmentType: "test",
|
||||
state: "test",
|
||||
zipCodeCtu: "test",
|
||||
},
|
||||
vehicle: {
|
||||
carId: "test",
|
||||
year: "test",
|
||||
},
|
||||
referralCorrelationId: "test",
|
||||
eon: "test",
|
||||
damage: {
|
||||
isRepair: true,
|
||||
glassToReplace: null,
|
||||
},
|
||||
payment: {
|
||||
parentAccountNumber: "test",
|
||||
},
|
||||
referralSequenceNumber: "test",
|
||||
lineItems: {
|
||||
serverData: "test",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockResolvedValue({
|
||||
data: {},
|
||||
});
|
||||
|
||||
crypto.randomUUID = jest.fn(() => "GUID");
|
||||
|
||||
// Act
|
||||
actions.validateOrderPromoAndSaveServerData(context, {
|
||||
payload: {
|
||||
promoCode: promoCode,
|
||||
lineItemsToUse: lineItemsToUse,
|
||||
addableVaps: addableVaps,
|
||||
},
|
||||
pageNameToLog: "test",
|
||||
});
|
||||
|
||||
const firstCallArgs = globalMethods.callHttpClient.mock.calls[0];
|
||||
|
||||
// Assert
|
||||
const vapsItem = firstCallArgs[0].payload.order.lineItemsOnOrder.filter(
|
||||
(item) => item.partNumber == 1
|
||||
)[0];
|
||||
expect(vapsItem.id).toEqual("GUID");
|
||||
});
|
||||
it("should not duplicate ids during syncing if there are two identical vaps items", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
const promoCode = "testPromo";
|
||||
// AddableVaps will sync its ids to vaps already on the order
|
||||
const lineItemsToUse = {
|
||||
vaps: [
|
||||
{ partNumber: "SBB22", id: "GUID1" },
|
||||
{ partNumber: "SBB22", id: "GUID2" },
|
||||
],
|
||||
promos: [2],
|
||||
};
|
||||
const addableVaps = [{ partNumber: "SBB22" }, { partNumber: "SBB22" }];
|
||||
|
||||
context["getters"] = {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
appointmentType: "test",
|
||||
state: "test",
|
||||
zipCodeCtu: "test",
|
||||
},
|
||||
vehicle: {
|
||||
carId: "test",
|
||||
year: "test",
|
||||
},
|
||||
referralCorrelationId: "test",
|
||||
eon: "test",
|
||||
damage: {
|
||||
isRepair: true,
|
||||
glassToReplace: null,
|
||||
},
|
||||
payment: {
|
||||
parentAccountNumber: "test",
|
||||
},
|
||||
referralSequenceNumber: "test",
|
||||
lineItems: {
|
||||
serverData: "test",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockResolvedValue({
|
||||
data: {},
|
||||
});
|
||||
|
||||
crypto.randomUUID = jest.fn(() => "GUID");
|
||||
|
||||
// Act
|
||||
actions.validateOrderPromoAndSaveServerData(context, {
|
||||
payload: {
|
||||
promoCode: promoCode,
|
||||
lineItemsToUse: lineItemsToUse,
|
||||
addableVaps: addableVaps,
|
||||
},
|
||||
pageNameToLog: "test",
|
||||
});
|
||||
|
||||
const firstCallArgs = globalMethods.callHttpClient.mock.calls[0];
|
||||
|
||||
// Assert
|
||||
const vapsItems = firstCallArgs[0].payload.addableVaps.filter(
|
||||
(item) => item.partNumber == "SBB22"
|
||||
);
|
||||
expect(vapsItems[1].id).toEqual("GUID1");
|
||||
expect(vapsItems[0].id).toEqual("GUID2");
|
||||
});
|
||||
it("should add GUIDs if not there to provided addableVaps before sending the http call", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
|
|
|
|||
Loading…
Reference in a new issue