CASH-1428 - Un did my previous changes and just removing the duplicates from being sent to Api end point
This commit is contained in:
parent
e8d7ee5353
commit
49258daa8c
2 changed files with 16 additions and 186 deletions
|
|
@ -43,140 +43,15 @@ describe("payment-method.vue", () => {
|
|||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
test("if the continue button is clicked, navigate forward", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
describe("forwardButtonAction", () => {
|
||||
let wrapper;
|
||||
let mockDispatchStoreAction;
|
||||
let mockGetCalcOrderAndTaxedLineItems;
|
||||
let mockSubmitWorkOrder;
|
||||
let mockRouter;
|
||||
let mockLoadingModal;
|
||||
let mockStoreGetters;
|
||||
let mockLineItems;
|
||||
let mockInactivePromos;
|
||||
let mockIsRecalAckOptIn;
|
||||
let mockPaymentMethod;
|
||||
let mockPaymentMethods;
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
beforeEach(() => {
|
||||
mockDispatchStoreAction = jest.fn().mockResolvedValue();
|
||||
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
|
||||
);
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ export default {
|
|||
: (resultMap.wipers.filter((wiper) => wiper.partType == partTypeStrings.REAR_WIPER) ??
|
||||
[]);
|
||||
|
||||
const lineItemsToTax = [
|
||||
const allLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...supportingItems,
|
||||
...availableFrontWipers,
|
||||
|
|
@ -273,6 +273,10 @@ export default {
|
|||
...vaps,
|
||||
];
|
||||
|
||||
const lineItemsToTax = Array.from(
|
||||
new Map(allLineItems.filter(Boolean).map((item) => [item.partNumber, item])).values()
|
||||
);
|
||||
|
||||
const availableVaps = [
|
||||
resultMap.rainDefense,
|
||||
...availableFrontWipers,
|
||||
|
|
@ -488,46 +492,6 @@ export default {
|
|||
getInactivePromosFromStore() {
|
||||
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() {
|
||||
this.$refs.loadingModal.showModal();
|
||||
const revalidatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
|
|
@ -615,31 +579,22 @@ export default {
|
|||
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
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING,
|
||||
taxedLineItems.glassParts,
|
||||
this.lineItems.glassParts,
|
||||
false
|
||||
);
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||
taxedLineItems.supportingItems,
|
||||
this.lineItems.supportingItems,
|
||||
false
|
||||
);
|
||||
await this.dispatchStoreAction(storeActions.SAVE_VAPS, taxedLineItems.vaps, false);
|
||||
await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false);
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
||||
{
|
||||
activePromos: taxedLineItems.promos,
|
||||
activePromos: this.lineItems.promos,
|
||||
inactivePromos: this.inactivePromos,
|
||||
},
|
||||
false
|
||||
|
|
|
|||
Loading…
Reference in a new issue