From 8bf64643ca6eb0b733408c4349a2fa65994bce96 Mon Sep 17 00:00:00 2001 From: Minojhini Valaiyapathi Date: Fri, 9 May 2025 10:48:09 -0400 Subject: [PATCH 1/2] CASH-535 - Moved saving the vuex code functionality from order helper to quote page for cashPriceSubTotal. --- .../heritage-integration/order-helper.js | 16 ---------------- src/layouts/quote/quote.vue | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 11750108c..76729e49f 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -83,22 +83,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.vue b/src/layouts/quote/quote.vue index 57c0178e3..47b3e7375 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -168,6 +168,7 @@ import { } from "@/helpers/heritage-integration/cookie-helper"; import { showFmgLoadingModal } from "@/helpers/loading-modal-helper"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; +import { storeMutations } from "@/constants/store-mutations"; defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); @@ -766,6 +767,22 @@ export default { this.$route ); } + + 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, () => { From ffe4c730440f238426202a4bc956a7bb50df5591 Mon Sep 17 00:00:00 2001 From: Minojhini Valaiyapathi Date: Sat, 10 May 2025 18:51:34 -0400 Subject: [PATCH 2/2] CASH-535 - Fixed unit test --- src/layouts/quote/quote.spec.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index fccb49432..f132f6de1 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: {