Merge pull request #2858 from Safelite/feature/CASH-1428
Feature/cash 1428
This commit is contained in:
commit
0b5e7eab0f
2 changed files with 16 additions and 186 deletions
|
|
@ -43,140 +43,15 @@ describe("payment-method.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
test("if the continue button is clicked, navigate forward", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
describe("forwardButtonAction", () => {
|
// Act
|
||||||
let wrapper;
|
await wrapper.vm.forwardButtonAction();
|
||||||
let mockDispatchStoreAction;
|
|
||||||
let mockGetCalcOrderAndTaxedLineItems;
|
|
||||||
let mockSubmitWorkOrder;
|
|
||||||
let mockRouter;
|
|
||||||
let mockLoadingModal;
|
|
||||||
let mockStoreGetters;
|
|
||||||
let mockLineItems;
|
|
||||||
let mockInactivePromos;
|
|
||||||
let mockIsRecalAckOptIn;
|
|
||||||
let mockPaymentMethod;
|
|
||||||
let mockPaymentMethods;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
// Assert
|
||||||
mockDispatchStoreAction = jest.fn().mockResolvedValue();
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||||
mockGetCalcOrderAndTaxedLineItems = jest.fn().mockResolvedValue({
|
|
||||||
glassParts: [],
|
|
||||||
supportingItems: [],
|
|
||||||
vaps: [],
|
|
||||||
promos: [],
|
|
||||||
});
|
|
||||||
mockSubmitWorkOrder = jest.fn().mockResolvedValue();
|
|
||||||
mockRouter = {
|
|
||||||
navigateWithoutSaving: jest.fn(),
|
|
||||||
navigateWithSaving: jest.fn(),
|
|
||||||
};
|
|
||||||
mockLoadingModal = { showModal: jest.fn(), hideModal: jest.fn() };
|
|
||||||
mockStoreGetters = {
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [],
|
|
||||||
supportingItems: [],
|
|
||||||
vaps: [],
|
|
||||||
},
|
|
||||||
payment: { isInsurance: false, piaType: null, isPia: false },
|
|
||||||
serviceLocation: {
|
|
||||||
provider: { providerNumber: "0000567" },
|
|
||||||
appointmentType: "Mobile",
|
|
||||||
city: "Anytown",
|
|
||||||
state: "OH",
|
|
||||||
zipCode: "00000",
|
|
||||||
},
|
|
||||||
schedule: {
|
|
||||||
date: "2024-01-01",
|
|
||||||
startTime: "09:00",
|
|
||||||
endTime: "10:00",
|
|
||||||
jobMaxMinutes: 60,
|
|
||||||
jobMinMinutes: 60,
|
|
||||||
},
|
|
||||||
customer: {
|
|
||||||
firstName: "Test",
|
|
||||||
lastName: "User",
|
|
||||||
phoneNumber: "555-555-5555",
|
|
||||||
emailAddress: "test@example.com",
|
|
||||||
},
|
|
||||||
policy: { currentDeductible: 123, isNoComp: false, isItac: false },
|
|
||||||
},
|
|
||||||
payment: { insuranceCoverage: { coverageStatus: "VERIFIED" } },
|
|
||||||
policy: { currentDeductible: 123 },
|
|
||||||
};
|
|
||||||
mockLineItems = { glassParts: [], supportingItems: [], vaps: [], promos: [] };
|
|
||||||
mockInactivePromos = [];
|
|
||||||
mockIsRecalAckOptIn = false;
|
|
||||||
mockPaymentMethod = "LATER";
|
|
||||||
mockPaymentMethods = { LATER: "LATER", INSURANCE: "INSURANCE" };
|
|
||||||
|
|
||||||
wrapper = {
|
|
||||||
$refs: { loadingModal: mockLoadingModal },
|
|
||||||
$router: mockRouter,
|
|
||||||
$store: { getters: mockStoreGetters },
|
|
||||||
dispatchStoreAction: mockDispatchStoreAction,
|
|
||||||
getCalcOrderAndTaxedLineItems: mockGetCalcOrderAndTaxedLineItems,
|
|
||||||
lineItems: mockLineItems,
|
|
||||||
inactivePromos: mockInactivePromos,
|
|
||||||
isRecalAckOptIn: mockIsRecalAckOptIn,
|
|
||||||
paymentMethod: mockPaymentMethod,
|
|
||||||
paymentMethods: mockPaymentMethods,
|
|
||||||
storeActions: require("@/constants/store-actions"),
|
|
||||||
navigationScenarios: {
|
|
||||||
CLICKED_FORWARD: "CLICKED_FORWARD",
|
|
||||||
CLICKED_INSURANCE: "CLICKED_INSURANCE",
|
|
||||||
CLICKED_PAY_NOW: "CLICKED_PAY_NOW",
|
|
||||||
},
|
|
||||||
pageName: "payment-method",
|
|
||||||
setupPia: jest.fn(),
|
|
||||||
customCtaCopy: "Continue",
|
|
||||||
};
|
|
||||||
|
|
||||||
jest.mock("@/helpers/heritage-integration/order-helper.js", () => ({
|
|
||||||
submitWorkOrder: mockSubmitWorkOrder,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should call all expected methods and navigate when paymentMethod is LATER", async () => {
|
|
||||||
wrapper.paymentMethod = mockPaymentMethods.LATER;
|
|
||||||
const submitWorkOrder =
|
|
||||||
require("@/helpers/heritage-integration/order-helper.js").submitWorkOrder;
|
|
||||||
await require("@/layouts/payment-method/payment-method.vue").default.methods.forwardButtonAction.call(
|
|
||||||
wrapper
|
|
||||||
);
|
|
||||||
expect(mockLoadingModal.showModal).toHaveBeenCalled();
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"savePaymentMethodChoice",
|
|
||||||
wrapper.paymentMethod,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(mockGetCalcOrderAndTaxedLineItems).toHaveBeenCalled();
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"saveGlassPartsSuppressingStateResetting",
|
|
||||||
mockLineItems.glassParts,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"saveSupportingItemsSuppressingStateResetting",
|
|
||||||
mockLineItems.supportingItems,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"saveVaps",
|
|
||||||
mockLineItems.vaps,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"saveActiveAndOrInactivePromos",
|
|
||||||
{ activePromos: mockLineItems.promos, inactivePromos: mockInactivePromos },
|
|
||||||
false
|
|
||||||
);
|
|
||||||
expect(mockDispatchStoreAction).toHaveBeenCalledWith(
|
|
||||||
"saveIsRecalAckOptIn",
|
|
||||||
mockIsRecalAckOptIn
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ export default {
|
||||||
: (resultMap.wipers.filter((wiper) => wiper.partType == partTypeStrings.REAR_WIPER) ??
|
: (resultMap.wipers.filter((wiper) => wiper.partType == partTypeStrings.REAR_WIPER) ??
|
||||||
[]);
|
[]);
|
||||||
|
|
||||||
const lineItemsToTax = [
|
const allLineItems = [
|
||||||
resultMap.rainDefense,
|
resultMap.rainDefense,
|
||||||
...supportingItems,
|
...supportingItems,
|
||||||
...availableFrontWipers,
|
...availableFrontWipers,
|
||||||
|
|
@ -273,6 +273,10 @@ export default {
|
||||||
...vaps,
|
...vaps,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const lineItemsToTax = Array.from(
|
||||||
|
new Map(allLineItems.map((item) => [item.partNumber, item])).values()
|
||||||
|
);
|
||||||
|
|
||||||
const availableVaps = [
|
const availableVaps = [
|
||||||
resultMap.rainDefense,
|
resultMap.rainDefense,
|
||||||
...availableFrontWipers,
|
...availableFrontWipers,
|
||||||
|
|
@ -488,46 +492,6 @@ export default {
|
||||||
getInactivePromosFromStore() {
|
getInactivePromosFromStore() {
|
||||||
return this.$store.getters.order.payment.inactivePromos;
|
return this.$store.getters.order.payment.inactivePromos;
|
||||||
},
|
},
|
||||||
async getCalcOrderAndTaxedLineItems(lineItemsToTax) {
|
|
||||||
const lineItemsFromStore = deepClone(store.getters.order.lineItems);
|
|
||||||
const pricedLineItemsToTax = await baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
|
||||||
{
|
|
||||||
availableLineItems: lineItemsToTax,
|
|
||||||
},
|
|
||||||
"payment-method",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
const promoCodeFromQueryString = consumeQueryFromStash(queryStrings.PROMO);
|
|
||||||
const { validatePromoResponse, revalidatePromoResponse } =
|
|
||||||
await revalidatePromosAndValidateQueryStringPromo(
|
|
||||||
promoCodeFromQueryString,
|
|
||||||
pricedLineItemsToTax,
|
|
||||||
"payment-method"
|
|
||||||
);
|
|
||||||
|
|
||||||
const newValidatedPromos = validatePromoResponse?.orderPromos ?? [];
|
|
||||||
newValidatedPromos.push(
|
|
||||||
...(revalidatePromoResponse ? revalidatePromoResponse.promoLineItems : [])
|
|
||||||
);
|
|
||||||
pricedLineItemsToTax.push(...newValidatedPromos);
|
|
||||||
|
|
||||||
const taxedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
|
||||||
{
|
|
||||||
billToAccountNumber: store.getters.payment.billToAccountNumber,
|
|
||||||
providerNumber: store.getters.order.serviceLocation.provider.providerNumber,
|
|
||||||
appointmentType: store.getters.order.serviceLocation.appointmentType,
|
|
||||||
serviceLocationCity: store.getters.order.serviceLocation.city,
|
|
||||||
serviceLocationState: store.getters.order.serviceLocation.state,
|
|
||||||
serviceLocationZipCode: store.getters.order.serviceLocation.zipCode,
|
|
||||||
pricedLineItems: pricedLineItemsToTax,
|
|
||||||
},
|
|
||||||
"payment-method",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
return mapTaxedLineItemsToStoreFormat(taxedLineItems, lineItemsFromStore);
|
|
||||||
},
|
|
||||||
async revalidatePromos() {
|
async revalidatePromos() {
|
||||||
this.$refs.loadingModal.showModal();
|
this.$refs.loadingModal.showModal();
|
||||||
const revalidatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
const revalidatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
|
@ -615,31 +579,22 @@ export default {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// recalulate pricing and tax with line items from store
|
|
||||||
const lineItemsFromStore = deepClone(store.getters.order.lineItems);
|
|
||||||
const lineItemsToTax = [
|
|
||||||
...(lineItemsFromStore.glassParts ?? []),
|
|
||||||
...(lineItemsFromStore.supportingItems ?? []),
|
|
||||||
...(lineItemsFromStore.vaps ?? []),
|
|
||||||
];
|
|
||||||
const taxedLineItems = await this.getCalcOrderAndTaxedLineItems(lineItemsToTax);
|
|
||||||
|
|
||||||
// save lineitems as they now have salestax added
|
// save lineitems as they now have salestax added
|
||||||
await this.dispatchStoreAction(
|
await this.dispatchStoreAction(
|
||||||
storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING,
|
storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING,
|
||||||
taxedLineItems.glassParts,
|
this.lineItems.glassParts,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
await this.dispatchStoreAction(
|
await this.dispatchStoreAction(
|
||||||
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||||
taxedLineItems.supportingItems,
|
this.lineItems.supportingItems,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_VAPS, taxedLineItems.vaps, false);
|
await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false);
|
||||||
this.dispatchStoreAction(
|
this.dispatchStoreAction(
|
||||||
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
||||||
{
|
{
|
||||||
activePromos: taxedLineItems.promos,
|
activePromos: this.lineItems.promos,
|
||||||
inactivePromos: this.inactivePromos,
|
inactivePromos: this.inactivePromos,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue