CSR-2087
Custom query strings
This commit is contained in:
parent
5b904e323b
commit
2e12fb3c90
18 changed files with 537 additions and 22 deletions
|
|
@ -25,6 +25,14 @@ const queryStrings = {
|
|||
REFERRAL_NUMBER: "rn",
|
||||
PARENT_ACCOUNT: "pa",
|
||||
CORRELATION_ID: "ci",
|
||||
VEHICLE_YEAR: "vehicleyear",
|
||||
VEHICLE_MAKE: "vehiclemake",
|
||||
VEHICLE_MODEL: "vehiclemodel",
|
||||
VEHICLE_STYLE: "vehiclestyle",
|
||||
VEHICLE_DAMAGE: "vehicledamage",
|
||||
SERVICE_ZIP: "servicezip",
|
||||
EMAIL: "email",
|
||||
IS_INSURANCE: "isinsurance",
|
||||
};
|
||||
|
||||
export { queryStrings };
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ const storeActions = {
|
|||
|
||||
CREATE_SUBMITTED_ORDER: "createSubmittedOrder",
|
||||
RESET_SUBMITTED_ORDER: "resetSubmittedOrder",
|
||||
RESET_IS_LEAD_GEN: "resetIsLeadGen",
|
||||
};
|
||||
|
||||
export { storeActions };
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ const storeMutations = {
|
|||
Customer_Portal_Login_Token: "updateCustomerPortalLoginToken",
|
||||
LOCK_TOKEN: "updateLockToken",
|
||||
UPDATE_SETTLED_TENDER_AMOUNT: "updateSettledTenderAmount",
|
||||
UPDATE_IS_LEAD_GEN: "updateIsLeadGen",
|
||||
|
||||
// EVENT BUS MUTATIONS
|
||||
ADD_EVENT_TO_BUS: "addEventToBus",
|
||||
|
|
|
|||
|
|
@ -212,6 +212,33 @@ describe("estimate.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("estimate.vue", () => {
|
||||
test("should call forwardButtonAction if isLeadGen is true", async () => {
|
||||
// update store with isLeadGen as true
|
||||
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Set selectedVinLookupMethod to decline
|
||||
wrapper.setData({ selectedVinLookupMethod: vinLookupMethodSelections.DECLINE });
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await estimate.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "estimate" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(nextFunction).toHaveBeenCalled();
|
||||
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks({
|
||||
groupName = "estimate",
|
||||
skipVin = false,
|
||||
|
|
|
|||
|
|
@ -145,6 +145,13 @@ export default {
|
|||
}
|
||||
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
if (store.getters.isLeadGen) {
|
||||
vm.selectedVinLookupMethod = vinLookupMethodSelections.DECLINE;
|
||||
vm.forwardButtonAction();
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ export default {
|
|||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.originalList = resultMap.insuranceCompanyList;
|
||||
if (store.getters.isLeadGen) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import { Form, defineRule } from "vee-validate";
|
|||
import { required } from "@/helpers/validation-rules";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule("questions-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
|
@ -53,6 +55,10 @@ export default {
|
|||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
if (store.getters.isLeadGen) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -640,12 +640,122 @@ describe("quote.vue", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describe("quote.vue", () => {
|
||||
test("should call forwardButtonAction if isLeadGen is true and Insurance is true", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
|
||||
store.getters = {
|
||||
lineItems: {
|
||||
glassParts: ["item", "item2"],
|
||||
},
|
||||
order: {
|
||||
lineItems: {
|
||||
glassParts: ["item", "item2"],
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "12345",
|
||||
zipCodeCtu: "value",
|
||||
},
|
||||
damage: {
|
||||
isRepair: false,
|
||||
},
|
||||
referralNumber: "1234567",
|
||||
payment: {
|
||||
isInsurance: true,
|
||||
inactivePromos: [],
|
||||
},
|
||||
},
|
||||
isLeadGen: true,
|
||||
payment: {
|
||||
isInsurance: true,
|
||||
inactivePromos: [],
|
||||
},
|
||||
vehicle: {
|
||||
cardId: "123",
|
||||
},
|
||||
experimentSettings: {
|
||||
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||
},
|
||||
};
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.$route = { query: null };
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await quote.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "quote" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(nextFunction).toHaveBeenCalled();
|
||||
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||
});
|
||||
test("should not call forwardButtonAction if isLeadGen is true and Insurance is false", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters = {
|
||||
lineItems: {
|
||||
glassParts: ["item", "item2"],
|
||||
},
|
||||
order: {
|
||||
lineItems: {
|
||||
glassParts: ["item", "item2"],
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "12345",
|
||||
zipCodeCtu: "value",
|
||||
},
|
||||
damage: {
|
||||
isRepair: false,
|
||||
},
|
||||
referralNumber: "1234567",
|
||||
payment: {
|
||||
isInsurance: null,
|
||||
inactivePromos: [],
|
||||
},
|
||||
},
|
||||
isLeadGen: true,
|
||||
payment: {
|
||||
isInsurance: null,
|
||||
inactivePromos: [],
|
||||
},
|
||||
vehicle: {
|
||||
cardId: "123",
|
||||
},
|
||||
experimentSettings: {
|
||||
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||
},
|
||||
};
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.$route = { query: null };
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await quote.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "quote" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks({ customMountOptions }) {
|
||||
const mountOptions = getMountOptions({
|
||||
...customMountOptions,
|
||||
});
|
||||
|
||||
baseMixin.methods.hideFmgLoadingModal = jest.fn();
|
||||
mountOptions.global.mocks["$store"] = store;
|
||||
mountOptions["attachTo"] = document.body;
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,17 @@ export default {
|
|||
validateAlerts[0].shouldAutoFade
|
||||
);
|
||||
}
|
||||
if (store.getters.isLeadGen) {
|
||||
if (store.getters.order.payment.isInsurance == true) {
|
||||
vm.forwardButtonAction();
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -390,12 +390,66 @@ describe("service-zip.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("service-zip.vue", () => {
|
||||
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const wrapper = setupMocks({});
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Mock the isFormValid method
|
||||
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => {
|
||||
return true;
|
||||
});
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await serviceZip.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "service-zip" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(nextFunction).toHaveBeenCalled();
|
||||
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||
});
|
||||
test("should not call forwardButtonAction if isLeadGen is true and form is invalid", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const wrapper = setupMocks({});
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Mock the isFormValid method
|
||||
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await serviceZip.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "service-zip" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks({ customMountOptions, customZipQuery, customZipDataResponse }) {
|
||||
const route = { query: { fmgPage: "service-zip" }, params: {} };
|
||||
if (customZipQuery) {
|
||||
route.query.zipcode = customZipQuery;
|
||||
}
|
||||
|
||||
baseMixin.methods.hideFmgLoadingModal = jest.fn();
|
||||
const mountOptions = getMountOptions({
|
||||
...customMountOptions,
|
||||
route: route,
|
||||
|
|
|
|||
|
|
@ -131,8 +131,17 @@ export default {
|
|||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
next((vm) => {
|
||||
next(async (vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
if (store.getters.isLeadGen) {
|
||||
const isValid = await vm.isFormValid();
|
||||
if (isValid) {
|
||||
vm.forwardButtonAction();
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -175,12 +184,20 @@ export default {
|
|||
|
||||
if (!zipCodeData.isValid) {
|
||||
this.displayInvalidZipAlert = true;
|
||||
if (store.getters.isLeadGen) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
return this.$refs.navbar.removeLoader();
|
||||
}
|
||||
this.displayInvalidZipAlert = false;
|
||||
|
||||
if (!zipCodeData.isServiceable) {
|
||||
this.displayNonServiceableZipAlert = true;
|
||||
if (store.getters.isLeadGen) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
return this.$refs.navbar.removeLoader();
|
||||
}
|
||||
this.displayNonServiceableZipAlert = false;
|
||||
|
|
@ -233,6 +250,11 @@ export default {
|
|||
await this.navigateForwardWithSingleCarMatch();
|
||||
}
|
||||
},
|
||||
async isFormValid() {
|
||||
const form = this.$refs.theForm;
|
||||
const formValidateResponse = await form.validate();
|
||||
return formValidateResponse?.valid;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
AlertNonServiceableZipHeader() {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ jest.mock("@/store", () => ({
|
|||
glassToReplace: [],
|
||||
},
|
||||
},
|
||||
isLeadGen: false,
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
@ -760,6 +761,56 @@ describe("vehicle-damage.vue", () => {
|
|||
expect(wrapper.vm.shouldHideBackButton).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("should call forwardButtonAction if isLeadGen is true and selectedDamageLocations is not empty", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Set selectedDamageLocations
|
||||
wrapper.setData({ selectedDamageLocations: ["windshield"] });
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(nextFunction).toHaveBeenCalled();
|
||||
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||
});
|
||||
test("should not call forwardButtonAction if isLeadGen is true and selectedDamageLocations is empty", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Set selectedDamageLocations to empty
|
||||
wrapper.setData({ selectedDamageLocations: [] });
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCookie = {} }) {
|
||||
|
|
@ -783,6 +834,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo
|
|||
isVerified: false,
|
||||
},
|
||||
},
|
||||
isLeadGen: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -795,6 +847,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo
|
|||
//Mock api responses
|
||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
||||
baseMixin.methods.dispatchStoreActionWithLogging = jest.fn();
|
||||
baseMixin.methods.hideFmgLoadingModal = jest.fn();
|
||||
const apiResponses = {
|
||||
cmsContent: {
|
||||
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||
|
|
|
|||
|
|
@ -149,6 +149,17 @@ export default {
|
|||
vm.$refs.backGlassOptions.initializeComponent(
|
||||
resultMap.damageOptions.backGlassOptions.availableReplacementOptions
|
||||
);
|
||||
if (store.getters.isLeadGen) {
|
||||
if (vm.selectedDamageLocations?.length > 0) {
|
||||
vm.forwardButtonAction();
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
import vehicle from "@/layouts/vehicle/vehicle.vue";
|
||||
|
||||
// Supporting Files
|
||||
import store from "@/store";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { nextTick } from "vue";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import baseMixin from "../../mixins/base-mixin";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
|
|
@ -18,6 +20,32 @@ jest.mock("@/helpers/cms-content-helper", () => ({
|
|||
fetchCmsContentForPage: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock Store
|
||||
jest.mock("@/store", () => ({
|
||||
commit: jest.fn(),
|
||||
dispatch: jest.fn(),
|
||||
getters: {
|
||||
applicationUser: {
|
||||
experiments: [{ universeName: "ConceptFunnel" }],
|
||||
},
|
||||
isLeadGen: false,
|
||||
vehicle: {
|
||||
carId: "C00000000",
|
||||
image: "test.jpg",
|
||||
},
|
||||
order: {
|
||||
vehicle: {
|
||||
year: 2018,
|
||||
make: "Honda",
|
||||
model: "Accord",
|
||||
style: "4 door sedan",
|
||||
carId: "C00000000",
|
||||
image: "test.jpg",
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
describe("vehicle.vue", () => {
|
||||
test("arePagePrerequisitesValid should be true ", async () => {
|
||||
//Arrange
|
||||
|
|
@ -58,25 +86,101 @@ describe("vehicle.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
function setupMocks() {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn(),
|
||||
navigate: jest.fn(),
|
||||
navigateWithSaving: jest.fn(),
|
||||
navigateWithoutSaving: jest.fn(),
|
||||
},
|
||||
});
|
||||
describe("vehicle.vue", () => {
|
||||
test("should call forwardButtonAction if isLeadGen is true and displayNoServiceAlert is false", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks();
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Set displayNoServiceAlert to false
|
||||
wrapper.setData({ displayNoServiceAlert: false });
|
||||
|
||||
// Mock the getVehicleDetails method
|
||||
wrapper.vm.getVehicleDetails = jest.fn();
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await vehicle.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(nextFunction).toHaveBeenCalled();
|
||||
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||
});
|
||||
test("should not call forwardButtonAction if isLeadGen is true and displayNoServiceAlert is true", async () => {
|
||||
// Set up the store with isLeadGen as true
|
||||
store.getters.isLeadGen = true;
|
||||
|
||||
// Set up the component
|
||||
const { wrapper } = setupMocks();
|
||||
wrapper.vm.forwardButtonAction = jest.fn();
|
||||
const nextFunction = jest.fn((c) => {
|
||||
c(wrapper.vm);
|
||||
});
|
||||
|
||||
// Set displayNoServiceAlert to false
|
||||
wrapper.setData({ displayNoServiceAlert: true });
|
||||
|
||||
// Mock the getVehicleDetails method
|
||||
wrapper.vm.getVehicleDetails = jest.fn();
|
||||
|
||||
// Call the method that contains the if-else logic
|
||||
await vehicle.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle" } },
|
||||
undefined,
|
||||
nextFunction
|
||||
);
|
||||
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks() {
|
||||
const groupName = "vehicle";
|
||||
const cmsQuestionText = "Vehicle Year";
|
||||
const cmsAnswers = [{ Name: "Vehicle year" }];
|
||||
const FunnelFooterWidget = { ForwardButtonText: "vehicle button" };
|
||||
|
||||
//Mock CMS Content
|
||||
const cmsContent = {
|
||||
groupName: groupName,
|
||||
QuestionText: cmsQuestionText,
|
||||
Answers: cmsAnswers,
|
||||
FunnelFooterWidget: FunnelFooterWidget,
|
||||
};
|
||||
//Mock props
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn(),
|
||||
},
|
||||
};
|
||||
const mountOptionsMockData = {
|
||||
router: {
|
||||
navigate: jest.fn(),
|
||||
navigateWithSaving: jest.fn(),
|
||||
navigateWithoutSaving: jest.fn(),
|
||||
},
|
||||
route: {
|
||||
query: {},
|
||||
},
|
||||
};
|
||||
const apiPromise = Promise.resolve({ cmsContent });
|
||||
settleAllPromises.mockImplementation(() => apiPromise);
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
...mountOptionsMockData,
|
||||
mixins: [baseMixin, mockMixin],
|
||||
});
|
||||
mountOptions["attachTo"] = document.body;
|
||||
|
||||
mountOptions.mixins = [mockMixin];
|
||||
const wrapper = shallowMount(vehicle, mountOptions);
|
||||
|
||||
return { wrapper };
|
||||
wrapper.vm.isDisabled = jest.fn();
|
||||
return { wrapper, apiPromise };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ export default {
|
|||
let resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
next(async (vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.initializeYearComponent(resultMap.yearQuestionInitialData);
|
||||
|
||||
|
|
@ -232,6 +232,18 @@ export default {
|
|||
resultMap.modelQuestionInitialData,
|
||||
resultMap.styleQuestionInitialData
|
||||
);
|
||||
if (store.getters.isLeadGen) {
|
||||
await vm.getVehicleDetails();
|
||||
if (!vm.displayNoServiceAlert) {
|
||||
vm.forwardButtonAction();
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
} else {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
|
||||
baseMixin.methods.hideFmgLoadingModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { routerParams } from "@/router/router-constants/router-params";
|
|||
import { queryStrings } from "@/constants/query-strings";
|
||||
import { dynamicStrings } from "@/constants/dynamic-strings";
|
||||
import { partTypeStrings } from "../constants/part-type-strings";
|
||||
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -192,6 +193,9 @@ export default {
|
|||
const container = document.getElementsByClassName("page-container-grouped-styles")[0];
|
||||
container.scrollTo({ top: container.scrollHeight, left: 0, behavior: "smooth" });
|
||||
},
|
||||
hideFmgLoadingModal() {
|
||||
showFmgLoadingModal(false);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
storeActions() {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,14 @@ const routes = [
|
|||
);
|
||||
const parentAccount = getQuerystringParameter(queryStrings.PARENT_ACCOUNT);
|
||||
const correlationId = getQuerystringParameter(queryStrings.CORRELATION_ID);
|
||||
const vehicleYear = getQuerystringParameter(queryStrings.VEHICLE_YEAR);
|
||||
const vehicleMake = getQuerystringParameter(queryStrings.VEHICLE_MAKE);
|
||||
const vehicleModel = getQuerystringParameter(queryStrings.VEHICLE_MODEL);
|
||||
const vehicleStyle = getQuerystringParameter(queryStrings.VEHICLE_STYLE);
|
||||
const vehicleDamage = getQuerystringParameter(queryStrings.VEHICLE_DAMAGE);
|
||||
const serviceZip = getQuerystringParameter(queryStrings.SERVICE_ZIP);
|
||||
const email = getQuerystringParameter(queryStrings.EMAIL);
|
||||
const isInsurance = getQuerystringParameter(queryStrings.IS_INSURANCE);
|
||||
if (referralNumber) {
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||
store.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccount);
|
||||
|
|
@ -93,6 +101,50 @@ const routes = [
|
|||
);
|
||||
updateOrCreateFunnelCookie();
|
||||
}
|
||||
if (
|
||||
vehicleYear &&
|
||||
vehicleMake &&
|
||||
vehicleModel &&
|
||||
vehicleStyle &&
|
||||
vehicleDamage &&
|
||||
serviceZip &&
|
||||
email &&
|
||||
isInsurance
|
||||
) {
|
||||
if (!store.getters.applicationUser.triggeredSiteEntry) {
|
||||
store.commit(storeMutations.UPDATE_YEAR, vehicleYear);
|
||||
store.commit(storeMutations.UPDATE_MAKE, vehicleMake);
|
||||
store.commit(storeMutations.UPDATE_MODEL, vehicleModel);
|
||||
store.commit(storeMutations.UPDATE_STYLE, vehicleStyle);
|
||||
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
|
||||
if (vehicleDamage == "windshieldReplace") {
|
||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
|
||||
const glassToReplace = [
|
||||
{ glassLocation: "Windshield", glassName: "Single" },
|
||||
];
|
||||
store.commit(
|
||||
storeMutations.UPDATE_GLASS_TO_REPLACE,
|
||||
glassToReplace
|
||||
);
|
||||
} else if (vehicleDamage == "windshieldRepair") {
|
||||
store.commit(storeMutations.UPDATE_IS_REPAIR, true);
|
||||
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, 1);
|
||||
}
|
||||
const serviceZipInfo = {
|
||||
state: null,
|
||||
zipCode: serviceZip,
|
||||
zipCodeCtu: null,
|
||||
};
|
||||
store.commit(storeMutations.UPDATE_SERVICE_ZIP, serviceZipInfo);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email);
|
||||
if (isInsurance == "true") {
|
||||
store.commit(storeMutations.UPDATE_IS_INSURANCE, true);
|
||||
} else {
|
||||
store.commit(storeMutations.UPDATE_IS_INSURANCE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const loadSessionResponse = await loadSessionIfPresent(
|
||||
to.query.isInsurance != null
|
||||
|
|
@ -234,6 +286,22 @@ router.beforeEach(async (to, from, next) => {
|
|||
const notToPIAReturn = toQueryPage != fmgPageValues.PAYMENT_PIA_RETURN;
|
||||
const isInIframe = window !== window.top;
|
||||
|
||||
if (store.getters.isLeadGen) {
|
||||
// Check if alert event is on the bus
|
||||
const alertEvent = eventBus.readEventFromBus(
|
||||
globalEvents.Categories.GLOBAL_ALERT,
|
||||
globalEvents.SubCategories.PAGE_NOT_FOUND
|
||||
);
|
||||
//Uknown alerts most likely were added by a failed api call in global-methods
|
||||
const unknownAlertEvent = eventBus.readEventFromBus(
|
||||
globalEvents.Categories.GLOBAL_ALERT,
|
||||
globalEvents.SubCategories.UNKNOWN_ERROR
|
||||
);
|
||||
// If alert event is on the bus, then display the alert
|
||||
if (alertEvent !== undefined || unknownAlertEvent !== undefined) {
|
||||
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, false);
|
||||
}
|
||||
}
|
||||
// fromPaymentToConfirmation workaround for navigating from an iframe but
|
||||
// isInIframe evaluates to false for some reason when navigating from payment to confirmation
|
||||
const fromPaymentToConfirmation =
|
||||
|
|
@ -265,8 +333,9 @@ router.afterEach(async (to, from) => {
|
|||
await saveSession({ pageNameToLog: to.query.fmgPage });
|
||||
}
|
||||
}
|
||||
|
||||
showFmgLoadingModal(false);
|
||||
if (!store.getters.isLeadGen) {
|
||||
showFmgLoadingModal(false);
|
||||
}
|
||||
|
||||
// Push page view to GA
|
||||
analyticsMixin.methods.pushPageViewToGA();
|
||||
|
|
@ -487,7 +556,7 @@ async function DisplayPageError() {
|
|||
type: globalEventTypes.Danger,
|
||||
}
|
||||
);
|
||||
|
||||
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, false);
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
|
||||
const pageError = getQuerystringParameter(queryStrings.PAGE_ERROR);
|
||||
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ const getDefaultState = () => {
|
|||
customerPortalLoginToken: null,
|
||||
lockToken: null,
|
||||
settledTenderAmount: 0,
|
||||
isLeadGen: false,
|
||||
},
|
||||
applicationUser: {
|
||||
eventBus: [],
|
||||
|
|
@ -294,6 +295,9 @@ export const mutations = {
|
|||
updateSettledTenderAmount(state, settledTenderAmount) {
|
||||
state.order.settledTenderAmount = settledTenderAmount;
|
||||
},
|
||||
updateIsLeadGen(state, isLeadGen) {
|
||||
state.order.isLeadGen = isLeadGen;
|
||||
},
|
||||
updateCCToken(state, ccToken) {
|
||||
state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId;
|
||||
state.order.payment.ccToken.expMonth = ccToken.expMonth;
|
||||
|
|
@ -674,6 +678,7 @@ export const getters = {
|
|||
isOvernightDropOffAppointment: (state) => {
|
||||
return state.order.schedule.routeCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF);
|
||||
},
|
||||
isLeadGen: (state) => state.order.isLeadGen,
|
||||
isRecalibrationOnOrder: (state) => {
|
||||
return getHasRecalibrationPart(state);
|
||||
},
|
||||
|
|
@ -1927,10 +1932,13 @@ export const actions = {
|
|||
context.state.order.vehicle.year != year ||
|
||||
context.state.order.vehicle.make != make ||
|
||||
context.state.order.vehicle.model != model ||
|
||||
context.state.order.vehicle.style != style
|
||||
context.state.order.vehicle.style != style ||
|
||||
context.state.order.isLeadGen
|
||||
) {
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
if (!context.state.order.isLeadGen) {
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
|
||||
context.commit(storeMutations.UPDATE_YEAR, year);
|
||||
context.commit(storeMutations.UPDATE_MAKE, make);
|
||||
|
|
@ -2701,6 +2709,9 @@ export const actions = {
|
|||
// clear from local storage
|
||||
window.sessionStorage.removeItem("submittedOrder");
|
||||
},
|
||||
resetIsLeadGen(context) {
|
||||
context.commit(storeMutations.UPDATE_IS_LEAD_GEN, false);
|
||||
},
|
||||
};
|
||||
|
||||
export default createStore({
|
||||
|
|
|
|||
Loading…
Reference in a new issue