Merge pull request #2500 from Safelite/feature/CASH-535
CASH-535 - Moved saving the vuex code functionality from order helper…
This commit is contained in:
commit
59a55efd2e
3 changed files with 45 additions and 18 deletions
|
|
@ -73,22 +73,6 @@ export async function saveSession({
|
||||||
if (!store.getters.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) {
|
if (!store.getters.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) {
|
||||||
await saveSessionPromise;
|
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({
|
export async function submitWorkOrder({
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,30 @@ import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { containsLineItemWithPartType } from "../../helpers/service-package-helper";
|
import { containsLineItemWithPartType } from "../../helpers/service-package-helper";
|
||||||
|
|
||||||
jest.mock("@/store", () => ({
|
jest.mock("@/store", () => ({
|
||||||
commit: jest.fn(),
|
commit: jest.fn(), // Mock store.commit
|
||||||
dispatch: jest.fn(),
|
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
|
// Mock fetchCmsContentForPage
|
||||||
|
|
@ -157,6 +179,7 @@ afterEach(() => {
|
||||||
describe("quote.vue", () => {
|
describe("quote.vue", () => {
|
||||||
test("IsInsurance false should navigateWithSaving", async () => {
|
test("IsInsurance false should navigateWithSaving", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
store.commit = jest.fn(); // Ensure store.commit is mocked
|
||||||
store.getters.payment = {
|
store.getters.payment = {
|
||||||
insuranceCoverage: {},
|
insuranceCoverage: {},
|
||||||
isInsurance: false,
|
isInsurance: false,
|
||||||
|
|
@ -785,6 +808,7 @@ describe("quote.vue", () => {
|
||||||
});
|
});
|
||||||
test("On forward button action save promos", async () => {
|
test("On forward button action save promos", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
store.commit = jest.fn(); // Ensure store.commit is mocked
|
||||||
store.getters.payment = {
|
store.getters.payment = {
|
||||||
insuranceCoverage: {},
|
insuranceCoverage: {},
|
||||||
isInsurance: false,
|
isInsurance: false,
|
||||||
|
|
@ -809,7 +833,8 @@ describe("quote.vue", () => {
|
||||||
expect(wrapper.vm.lineItems.promos !== null).toBe(true);
|
expect(wrapper.vm.lineItems.promos !== null).toBe(true);
|
||||||
});
|
});
|
||||||
test("On forward button action save supporting lineItems", async () => {
|
test("On forward button action save supporting lineItems", async () => {
|
||||||
//Arrange
|
// Arrange
|
||||||
|
store.commit = jest.fn(); // Ensure store.commit is mocked
|
||||||
store.getters.payment = {
|
store.getters.payment = {
|
||||||
insuranceCoverage: {},
|
insuranceCoverage: {},
|
||||||
isInsurance: false,
|
isInsurance: false,
|
||||||
|
|
@ -820,6 +845,7 @@ describe("quote.vue", () => {
|
||||||
parentAccountNumber: 167132,
|
parentAccountNumber: 167132,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
customMountOptions: {
|
customMountOptions: {
|
||||||
router: {
|
router: {
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ import {
|
||||||
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
|
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
|
||||||
import { routeData } from "@/router/constants/routes";
|
import { routeData } from "@/router/constants/routes";
|
||||||
import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash";
|
import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash";
|
||||||
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
|
|
||||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
||||||
|
|
@ -777,6 +778,22 @@ export default {
|
||||||
this.pageName
|
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() {
|
attachCustomEventsForAnalytics() {
|
||||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue