diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index b74757b1e..1c0922ba0 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -73,22 +73,6 @@ export async function saveSession({ if (!store.getters.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) { await saveSessionPromise; } - - const lineItems = store.getters.order?.lineItems ?? {}; - const combinedLineItems = [ - ...(lineItems.glassParts || []), - ...(lineItems.supportingItems || []), - ...(lineItems.vaps || []), - ...(lineItems.promos || []), - ]; - - const cashPriceSubtotal = combinedLineItems.length - ? baseMixin.methods - .getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false) - .toFixed(2) - : ""; - - store.commit(storeMutations.UPDATE_CASH_PRICE_SUBTOTAL, cashPriceSubtotal); } export async function submitWorkOrder({ diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index 6cc06b023..c162017c1 100644 --- a/src/layouts/quote/quote.spec.js +++ b/src/layouts/quote/quote.spec.js @@ -12,8 +12,30 @@ import baseMixin from "@/mixins/base-mixin.js"; import { containsLineItemWithPartType } from "../../helpers/service-package-helper"; jest.mock("@/store", () => ({ - commit: jest.fn(), + commit: jest.fn(), // Mock store.commit dispatch: jest.fn(), + getters: { + order: { + lineItems: { + glassParts: [], + supportingItems: [], + vaps: [], + promos: [], + }, + payment: { + insuranceCoverage: {}, + isInsurance: false, + parentAccountNumber: 167132, + }, + }, + payment: { + insuranceCoverage: {}, + isInsurance: false, + }, + customer: { + emailAddress: "test@test.com", + }, + }, })); // Mock fetchCmsContentForPage @@ -157,6 +179,7 @@ afterEach(() => { describe("quote.vue", () => { test("IsInsurance false should navigateWithSaving", async () => { //Arrange + store.commit = jest.fn(); // Ensure store.commit is mocked store.getters.payment = { insuranceCoverage: {}, isInsurance: false, @@ -785,6 +808,7 @@ describe("quote.vue", () => { }); test("On forward button action save promos", async () => { //Arrange + store.commit = jest.fn(); // Ensure store.commit is mocked store.getters.payment = { insuranceCoverage: {}, isInsurance: false, @@ -809,7 +833,8 @@ describe("quote.vue", () => { expect(wrapper.vm.lineItems.promos !== null).toBe(true); }); test("On forward button action save supporting lineItems", async () => { - //Arrange + // Arrange + store.commit = jest.fn(); // Ensure store.commit is mocked store.getters.payment = { insuranceCoverage: {}, isInsurance: false, @@ -820,6 +845,7 @@ describe("quote.vue", () => { parentAccountNumber: 167132, }, }; + const { wrapper } = setupMocks({ customMountOptions: { router: { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 3ada84dde..e15e8b8c3 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -169,6 +169,7 @@ import { import { showFmgLoadingModal } from "@/helpers/loading-modal-helper"; import { routeData } from "@/router/constants/routes"; import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; +import { storeMutations } from "@/constants/store-mutations"; defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); @@ -777,6 +778,22 @@ export default { this.pageName ); } + + const lineItems = store.getters.order?.lineItems ?? {}; + const combinedLineItems = [ + ...(lineItems.glassParts || []), + ...(lineItems.supportingItems || []), + ...(lineItems.vaps || []), + ...(lineItems.promos || []), + ]; + + const cashPriceSubtotal = combinedLineItems.length + ? baseMixin.methods + .getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false) + .toFixed(2) + : ""; + + store.commit(storeMutations.UPDATE_CASH_PRICE_SUBTOTAL, cashPriceSubtotal); }, attachCustomEventsForAnalytics() { this.prependActionToMethod(this, this.forwardButtonAction, () => {