From 943b5c8d762d9b69a198d32e1a570db018ef3f2e Mon Sep 17 00:00:00 2001 From: Sneha Date: Fri, 11 Aug 2023 14:54:24 +0530 Subject: [PATCH 1/2] CSR-1425 Removing existing YMMS --- src/constants/store-actions.js | 4 - .../heritage-integration/navigation-helper.js | 18 +- .../navigation-helper.spec.js | 102 +------ .../make-question/make-question.spec.js | 79 ------ .../make-question/make-question.vue | 59 ---- src/layouts/vehicle-make/vehicle-make.spec.js | 228 ---------------- src/layouts/vehicle-make/vehicle-make.vue | 95 ------- .../model-question/model-question.spec.js | 79 ------ .../model-question/model-question.vue | 60 ---- .../vehicle-model/vehicle-model.spec.js | 147 ---------- src/layouts/vehicle-model/vehicle-model.vue | 98 ------- .../style-question/style-question.spec.js | 79 ------ .../style-question/style-question.vue | 61 ----- .../vehicle-style/vehicle-style.spec.js | 256 ------------------ src/layouts/vehicle-style/vehicle-style.vue | 137 ---------- src/layouts/vehicle-year/vehicle-year.spec.js | 122 --------- src/layouts/vehicle-year/vehicle-year.vue | 110 -------- .../year-question/year-question.spec.js | 78 ------ .../year-question/year-question.vue | 55 ---- src/router/router-constants/fmgPage-values.js | 4 - .../router-constants/navigation-scenarios.js | 6 - src/router/router-constants/routing-table.js | 49 +--- src/store/index.js | 82 ------ src/store/store.spec.js | 162 ----------- 24 files changed, 14 insertions(+), 2156 deletions(-) delete mode 100644 src/layouts/vehicle-make/make-question/make-question.spec.js delete mode 100644 src/layouts/vehicle-make/make-question/make-question.vue delete mode 100644 src/layouts/vehicle-make/vehicle-make.spec.js delete mode 100644 src/layouts/vehicle-make/vehicle-make.vue delete mode 100644 src/layouts/vehicle-model/model-question/model-question.spec.js delete mode 100644 src/layouts/vehicle-model/model-question/model-question.vue delete mode 100644 src/layouts/vehicle-model/vehicle-model.spec.js delete mode 100644 src/layouts/vehicle-model/vehicle-model.vue delete mode 100644 src/layouts/vehicle-style/style-question/style-question.spec.js delete mode 100644 src/layouts/vehicle-style/style-question/style-question.vue delete mode 100644 src/layouts/vehicle-style/vehicle-style.spec.js delete mode 100644 src/layouts/vehicle-style/vehicle-style.vue delete mode 100644 src/layouts/vehicle-year/vehicle-year.spec.js delete mode 100644 src/layouts/vehicle-year/vehicle-year.vue delete mode 100644 src/layouts/vehicle-year/year-question/year-question.spec.js delete mode 100644 src/layouts/vehicle-year/year-question/year-question.vue diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index c4efe9d45..f23a167e1 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -58,10 +58,6 @@ const storeActions = { RESET_STATE: "resetState", // SAVE COMPONENT STATE - SAVE_VEHICLE_YEAR: "saveVehicleYear", - SAVE_VEHICLE_MAKE: "saveVehicleMake", - SAVE_VEHICLE_MODEL: "saveVehicleModel", - SAVE_VEHICLE_STYLE: "saveVehicleStyle", SAVE_VEHICLE: "saveVehicle", SAVE_VEHICLE_DAMAGE: "saveVehicleDamage", SAVE_VIN_LOOKUP: "saveVinLookup", diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 913fbcb1b..d522a5e6d 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -102,9 +102,6 @@ async function getLatestPageForRedirection() { // If this is a non-CTA navigation, determine where to send the user based on page prerequisites. // This also works if a user has a 'fmg' start_type query string but no current order. // That shouldn't happen, but it's possible. - const vehicleMakeComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MAKE); - const vehicleModelComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MODEL); - const vehicleStyleComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_STYLE); const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE); const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); @@ -118,14 +115,8 @@ async function getLatestPageForRedirection() { const skipVin = await skipVinLookup(); - if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_YEAR; - } else if (!vehicleModelComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_MAKE; - } else if (!vehicleStyleComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_MODEL; - } else if (!vehicleDamageComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_STYLE; + if (!vehicleDamageComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.VEHICLE; } else if (!estimateComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_DAMAGE; } else { @@ -163,10 +154,7 @@ function overrideYmmsDirectionIfNeeded(toRoute) { if (store.getters.payment.insuranceCoverage.isVerified) { switch (fmgPageValue) { - case fmgPageValues.VEHICLE_YEAR: - case fmgPageValues.VEHICLE_MAKE: - case fmgPageValues.VEHICLE_MODEL: - case fmgPageValues.VEHICLE_STYLE: { + case fmgPageValues.VEHICLE: { return fmgPageValues.VEHICLE_DAMAGE; } default: { diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index d08ce92ec..cb0664f78 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -20,7 +20,7 @@ jest.mock("@/router/dynamic-routing/component-loader.js", () => ({ })); describe("getPageToRouteExistingOrderTo", () => { - test("should return vehicle-year", async () => { + test("should return vehicle", async () => { // Arrange const toRoute = { query: {}, @@ -31,75 +31,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE_YEAR); - }); - - test("should return vehicle-make", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE_MAKE); - }); - - test("should return vehicle-model", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE_MODEL); - }); - - test("should return vehicle-style", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: false, }); @@ -107,7 +39,7 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe(fmgPageValues.VEHICLE_STYLE); + expect(result).toBe(fmgPageValues.VEHICLE); }); test("should return vehicle-damage", async () => { @@ -121,9 +53,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: false, }); @@ -156,9 +86,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: false, @@ -186,9 +114,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: false, @@ -216,9 +142,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: true, @@ -246,9 +170,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: false, @@ -276,9 +198,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: false, @@ -306,9 +226,7 @@ describe("getPageToRouteExistingOrderTo", () => { // Mock out the lazy load calls for all components. mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE_MAKE]: true, - [fmgPageValues.VEHICLE_MODEL]: true, - [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE]: true, [fmgPageValues.VEHICLE_DAMAGE]: true, [fmgPageValues.ESTIMATE]: true, [fmgPageValues.CAPABILITY_QUESTIONS]: false, diff --git a/src/layouts/vehicle-make/make-question/make-question.spec.js b/src/layouts/vehicle-make/make-question/make-question.spec.js deleted file mode 100644 index 7025c118c..000000000 --- a/src/layouts/vehicle-make/make-question/make-question.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import makeQuestion from "@/layouts/vehicle-make/make-question/make-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import store from "@/store"; -jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } -); - -describe("make-question.vue", () => { - test("Selected make is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "honda" }); - const makeToSelect = "ford"; - - //Act - wrapper.setValue({ selectedMake: makeToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ selectedMake: "ford" }]); - }); -}); - -describe("make-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["honda", "ford", "dodge"], - }); - - //Act - const initialData = makeQuestion.methods.loadInitialData.call(wrapper.vm); - makeQuestion.methods.initializeComponent.call(wrapper.vm, initialData); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe("honda,ford,dodge"); - }); -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - store.dispatch = jest.fn(() => dataFromStoreApi); - store.getters = { vehicle: { year: 2019 } }; - const mountOptions = getMountOptions({ - store: { - dispatch: store.dispatch, - getters: store.getters, - }, - }); - - //Mock props - const mockMixin = { - methods: { - getCmsContent: jest.fn(), - }, - }; - mountOptions.propsData = { - modelValue: modelValueProp, - }; - mountOptions.mixins = [mockMixin]; - const wrapper = shallowMount(makeQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue deleted file mode 100644 index 2d3551c53..000000000 --- a/src/layouts/vehicle-make/make-question/make-question.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - diff --git a/src/layouts/vehicle-make/vehicle-make.spec.js b/src/layouts/vehicle-make/vehicle-make.spec.js deleted file mode 100644 index 3b169a9b9..000000000 --- a/src/layouts/vehicle-make/vehicle-make.spec.js +++ /dev/null @@ -1,228 +0,0 @@ -// Supporting Files -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { nextTick } from "vue"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; -import store from "@/store"; - -// Components -import vehicleMake from "@/layouts/vehicle-make/vehicle-make.vue"; -import makeQuestion from "@/layouts/vehicle-make/make-question/make-question"; - -jest.mock("@/store", () => ({ - commit: jest.fn(), - dispatch: jest.fn(), - // getters: jest.fn().mockImplementation(() => ({ - // vehicle: { - // year: 2019, - // }, - // })), -})); - -// Mock fetchCmsContentForPage -jest.mock("@/helpers/cms-content-helper", () => ({ - fetchCmsContentForPage: jest.fn(), -})); - -// Mock our module for promises. -jest.mock("@/helpers/layout-helper.js", () => ({ - settleAllPromises: jest.fn(), -})); - -describe("vehicle-make.vue", () => { - test("Make question component is initized with api data", async (done) => { - //Arrange - const makeQuestionInitialData = ["honda", "ford", "dodge"]; - const { wrapper, apiPromise } = setupMocks({ - makeQuestionInitialData: makeQuestionInitialData, - }); - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - apiPromise.finally(() => { - expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith( - makeQuestionInitialData - ); - done(); - }); - }); -}); - -describe("vehicle-make.vue", () => { - test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a make to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - navigateWithoutSaving: jest.fn(), - }, - }, - }); - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - - //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled(); - done(); - }); - }); -}); - -describe("vehicle-make.vue", () => { - describe("arePagePrerequisitesValue", () => { - test("Year set, arePagePrerequisitesValid should be true", async () => { - //Arrange - const { wrapper } = setupMocks({ - vehicleData: { - year: 2019, - }, - }); - - //Act - vehicleMake.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); - - test("Year not set, arePagePrerequisitesValid should be false", async () => { - //Arrange - store.getters.vehicle.year = jest.fn().mockReturnValueOnce(undefined); - const { wrapper } = setupMocks({}); - - //Act - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - - //Assert - expect(arePagePrerequisitesValid).toBe(false); - }); - }); - - test("selectedMake changes => save make in store", async () => { - //Arrange - const { wrapper } = setupMocks({ - mountOptionsMockData: { - router: { - navigate: jest.fn(), - navigateWithSaving: jest.fn(), - }, - }, - }); - - // Act - await wrapper.setData({ - selectedMake: "Make", - }); - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledTimes(1); - expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith( - "saveVehicleMake", - "Make", - false - ); - }); - - test("selectedMake changes => navigate with saving", async () => { - //Arrange - const { wrapper } = setupMocks({ - mountOptionsMockData: { - router: { - navigate: jest.fn(), - navigateWithSaving: jest.fn(), - }, - route: { - fmgPage: "test", - }, - }, - }); - - // Act - await wrapper.setData({ - selectedMake: "Make", - }); - - // Assert - expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith( - "SELECTED_MAKE", - expect.anything() - ); - }); -}); - -function setupMocks({ - vehicleMakeQuestionCmsContent = {}, - makeQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, - vehicleData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - FunnelSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleMakeQuestion: vehicleMakeQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3", - }, - FunnelHeaderWidget: { - LogoImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3", - }, - }, - makeQuestionInitialData: makeQuestionInitialData, - }; - - const apiPromise = Promise.resolve(apiResponses); - - store.getters = { - vehicle: vehicleData, - }; - - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - settleAllPromises.mockImplementation(() => apiPromise); - - //Mock make question methods - makeQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleMake, mountOptions); - const makeQuestionWrapper = wrapper.findComponent({ name: "makeQuestion" }); - makeQuestionWrapper.vm.initializeComponent = makeQuestion.methods.initializeComponent; - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue deleted file mode 100644 index a50440e35..000000000 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - diff --git a/src/layouts/vehicle-model/model-question/model-question.spec.js b/src/layouts/vehicle-model/model-question/model-question.spec.js deleted file mode 100644 index 16ca638d9..000000000 --- a/src/layouts/vehicle-model/model-question/model-question.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import modelQuestion from "@/layouts/vehicle-model/model-question/model-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import store from "@/store"; -jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } -); - -describe("model-question.vue", () => { - test("Selected model is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "Accord" }); - const modelToSelect = "Civic"; - - //Act - wrapper.setValue({ selectedModel: modelToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ selectedModel: "Civic" }]); - }); -}); - -describe("model-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["accord", "civic", "insight"], - }); - - //Act - const initialData = modelQuestion.methods.loadInitialData.call(wrapper.vm); - modelQuestion.methods.initializeComponent.call(wrapper.vm, initialData); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe("accord,civic,insight"); - }); -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - store.dispatch = jest.fn(() => dataFromStoreApi); - store.getters = { vehicle: { year: 2019, make: "honda" } }; - const mountOptions = getMountOptions({ - store: { - dispatch: store.dispatch, - getters: store.getters, - }, - }); - - //Mock props - const mockMixin = { - methods: { - getCmsContent: jest.fn(), - }, - }; - mountOptions.propsData = { - modelValue: modelValueProp, - }; - mountOptions.mixins = [mockMixin]; - const wrapper = shallowMount(modelQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue deleted file mode 100644 index 5ca926abc..000000000 --- a/src/layouts/vehicle-model/model-question/model-question.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - diff --git a/src/layouts/vehicle-model/vehicle-model.spec.js b/src/layouts/vehicle-model/vehicle-model.spec.js deleted file mode 100644 index 33b74482d..000000000 --- a/src/layouts/vehicle-model/vehicle-model.spec.js +++ /dev/null @@ -1,147 +0,0 @@ -// Components -import vehicleModel from "@/layouts/vehicle-model/vehicle-model.vue"; -import modelQuestion from "@/layouts/vehicle-model/model-question/model-question"; - -// Supporting files -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { nextTick } from "vue"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; - -// Mock our module for promises. -jest.mock("@/helpers/layout-helper.js", () => ({ - settleAllPromises: jest.fn(), -})); - -// Mock fetchCmsContentForPage -jest.mock("@/helpers/cms-content-helper", () => ({ - fetchCmsContentForPage: jest.fn(), -})); - -// Mock Store -jest.mock("@/store", () => ({ - commit: jest.fn(), - dispatch: jest.fn(), - getters: { - vehicle: { - make: "Acura", - }, - }, -})); - -describe("vehicle-model.vue", () => { - test("Model question component is initized with api data", async (done) => { - //Arange - const modelQuestionInitialData = ["accord", "civic", "insight"]; - const { wrapper, apiPromise } = setupMocks({ - modelQuestionInitialData: modelQuestionInitialData, - }); - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - //Assert - apiPromise.finally(() => { - expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith( - modelQuestionInitialData - ); - done(); - }); - }); -}); - -describe("vehicle-model.vue", () => { - test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a model to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - navigateWithoutSaving: jest.fn(), - }, - }, - }); - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled(); - done(); - }); - }); -}); -describe("vehicle-model.vue", () => { - test("Make set, arePagePrerequisitesValid should be true ", async () => { - //Arrange - const { wrapper } = setupMocks({}); - - //Act - vehicleModel.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-model" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - await nextTick(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); -}); - -function setupMocks({ - buttonQuestionContent = {}, - modelQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - FunnelSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleModelQuestion: buttonQuestionContent, - VehicleBannerWidget: { - GenericVehicleImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3", - }, - FunnelHeaderWidget: { - LogoImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3", - }, - }, - modelQuestionInitialData: modelQuestionInitialData, - }; - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock model question methods - modelQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleModel, mountOptions); - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - const modelQuestionWrapper = wrapper.findComponent({ name: "modelQuestion" }); - modelQuestionWrapper.vm.initializeComponent = modelQuestion.methods.initializeComponent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-model/vehicle-model.vue b/src/layouts/vehicle-model/vehicle-model.vue deleted file mode 100644 index d15c170c6..000000000 --- a/src/layouts/vehicle-model/vehicle-model.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - diff --git a/src/layouts/vehicle-style/style-question/style-question.spec.js b/src/layouts/vehicle-style/style-question/style-question.spec.js deleted file mode 100644 index c02301316..000000000 --- a/src/layouts/vehicle-style/style-question/style-question.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import styleQuestion from "@/layouts/vehicle-style/style-question/style-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import store from "@/store"; -jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } -); - -describe("style-question.vue", () => { - test("Selected style is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "2 Door" }); - const styleToSelect = "4 Door"; - - //Act - wrapper.setValue({ selectedStyle: styleToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ selectedStyle: "4 Door" }]); - }); -}); - -describe("style-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["2 Door", "4 Door"], - }); - - //Act - const initialData = styleQuestion.methods.loadInitialData.call(wrapper.vm); - styleQuestion.methods.initializeComponent.call(wrapper.vm, initialData); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe("2 Door,4 Door"); - }); -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - store.dispatch = jest.fn(() => dataFromStoreApi); - store.getters = { vehicle: { year: 2019, make: "honda", model: "civc" } }; - const mountOptions = getMountOptions({ - store: { - dispatch: store.dispatch, - getters: store.getters, - }, - }); - - //Mock props - const mockMixin = { - methods: { - getCmsContent: jest.fn(), - }, - }; - mountOptions.propsData = { - modelValue: modelValueProp, - }; - mountOptions.mixins = [mockMixin]; - const wrapper = shallowMount(styleQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-style/style-question/style-question.vue b/src/layouts/vehicle-style/style-question/style-question.vue deleted file mode 100644 index 0bfd00f7c..000000000 --- a/src/layouts/vehicle-style/style-question/style-question.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - diff --git a/src/layouts/vehicle-style/vehicle-style.spec.js b/src/layouts/vehicle-style/vehicle-style.spec.js deleted file mode 100644 index f7dacb6b4..000000000 --- a/src/layouts/vehicle-style/vehicle-style.spec.js +++ /dev/null @@ -1,256 +0,0 @@ -// Components -import vehicleStyle from "@/layouts/vehicle-style/vehicle-style.vue"; -import styleQuestion from "@/layouts/vehicle-style/style-question/style-question"; - -// Supporting files -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { nextTick } from "vue"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { storeActions } from "@/constants/store-actions"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; -import router from "@/router"; -import store from "@/store"; -import { storeMutations } from "@/constants/store-mutations"; - -// Mock our module for promises. -jest.mock("@/helpers/layout-helper.js", () => ({ - settleAllPromises: jest.fn(), -})); - -// Mock fetchCmsContentForPage -jest.mock("@/helpers/cms-content-helper", () => ({ - fetchCmsContentForPage: jest.fn(), -})); - -// Mock fetchCmsContentForPage -jest.mock("@/router", () => ({ - overrideNavigation: jest.fn(), -})); - -describe("vehicle-style.vue", () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - test("Style question component is initized with api data", async (done) => { - //Arrange - const styleQuestionInitialData = ["2 Door", "4 Door"]; - const { wrapper, apiPromise } = setupMocks({ - styleQuestionInitialData: styleQuestionInitialData, - }); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - apiPromise.finally(() => { - expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith( - styleQuestionInitialData - ); - done(); - }); - }); - - test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a style to get started", - mountOptionsMockData: { - router: { - navigate: jest.fn(), - navigateWithSaving: jest.fn(), - navigateWithoutSaving: jest.fn(), - }, - }, - }); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.backButtonAction(); - await nextTick(); - - //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled(); - done(); - }); - }); - - test("setVehicle triggers a dispatchStoreAction commit", async (done) => { - //Arrange - const { wrapper, apiPromise } = setupMocks({ - pageHeaderWidgetHeaderText: "Select a style to get started", - mountOptionsMockData: { - actionList: [ - { - actionName: storeActions.SET_VEHICLE, - data: "mockData", - }, - ], - }, - }); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - wrapper.vm.setVehicle(); - await nextTick(); - - //Assert - apiPromise.finally(() => { - expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled(); - done(); - }); - }); - - test("Model set, arePagePrerequisitesValid should be true ", async () => { - //Arrange - const { wrapper } = setupMocks({}); - - //Act - vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - await nextTick(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); - - test("there is only one vehicle style => autoselect and move to vehicle damage", async () => { - //Arrange - const { wrapper } = setupMocks({ - styleQuestionInitialData: ["2 door sedan"], - }); - - // Act - await vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - // Assert - expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_STYLE, "2 door sedan"); - expect(router.overrideNavigation).toHaveBeenCalled(); - }); - - test("there is only one vehicle style and vehicle-damage was visited => don't autoselect or move to vehicle damage", async () => { - //Arrange - const { wrapper } = setupMocks({ - styleQuestionInitialData: ["2 door sedan"], - mountOptionsMockData: { - store: { - getters: { - applicationUser: { - pageData: { - "part-questions": null, - "vehicle-make": {}, - "vehicle-model": {}, - "vehicle-style": {}, - "vehicle-damage": {}, - }, - }, - }, - }, - }, - }); - - // Act - await vehicleStyle.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-style" } }, - undefined, - (c) => c(wrapper.vm) - ); - - // Assert - expect(store.commit).not.toHaveBeenCalledWith(storeMutations.UPDATE_STYLE, "2 door sedan"); - expect(router.overrideNavigation).not.toHaveBeenCalled(); - }); -}); - -function setupMocks({ - vehicleStyleQuestionCmsContent = {}, - styleQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - FunnelSubHeaderWidget: pageHeaderWidgetHeaderText, - VehicleStyleQuestion: vehicleStyleQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3", - }, - FunnelHeaderWidget: { - LogoImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3", - }, - }, - styleQuestionInitialData: styleQuestionInitialData, - }; - - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock style question methods - styleQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - store.commit = jest.fn(); - store.dispatch = jest.fn(); - store.getters = mountOptionsMockData.store?.getters ?? { - vehicle: { - model: "TL", - }, - applicationUser: { - pageData: { - "part-questions": null, - "vehicle-make": {}, - "vehicle-model": {}, - "vehicle-style": {}, - }, - }, - }; - - const mountOptions = getMountOptions({ - ...mountOptionsMockData, - store, - }); - const wrapper = shallowMount(vehicleStyle, mountOptions); - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - const styleQuestionWrapper = wrapper.findComponent({ name: "styleQuestion" }); - styleQuestionWrapper.vm.initializeComponent = styleQuestion.methods.initializeComponent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue deleted file mode 100644 index 2d2a4a534..000000000 --- a/src/layouts/vehicle-style/vehicle-style.vue +++ /dev/null @@ -1,137 +0,0 @@ - - - diff --git a/src/layouts/vehicle-year/vehicle-year.spec.js b/src/layouts/vehicle-year/vehicle-year.spec.js deleted file mode 100644 index ad024f131..000000000 --- a/src/layouts/vehicle-year/vehicle-year.spec.js +++ /dev/null @@ -1,122 +0,0 @@ -import { shallowMount, flushPromises } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { settleAllPromises } from "@/helpers/layout-helper.js"; -import { nextTick } from "vue"; -import { storeMutations } from "@/constants/store-mutations"; -import { storeActions } from "@/constants/store-actions"; -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import baseMixin from "@/mixins/base-mixin.js"; - -import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue"; -import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; - -import store from "@/store"; - -jest.mock("@/store", () => ({ - commit: jest.fn(), - dispatch: jest.fn(), - getters: { - applicationUser: { - experiments: [], - }, - }, -})); - -// Mock our module for promises. -jest.mock("@/helpers/layout-helper.js", () => ({ - settleAllPromises: jest.fn(), -})); - -// Mock fetchCmsContentForPage -jest.mock("@/helpers/cms-content-helper", () => ({ - fetchCmsContentForPage: jest.fn(), -})); - -describe("vehicle-year.vue", () => { - test("Year question component is initized with api data", async (done) => { - //Arrange - const yearQuestionInitialData = ["2023", "2022", "2021"]; - const { wrapper, apiPromise } = setupMocks({ - yearQuestionInitialData: yearQuestionInitialData, - }); - - //Act - vehicleYear.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-year" } }, - undefined, - (c) => c(wrapper.vm) - ); - - //Assert - apiPromise.finally(() => { - expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith( - yearQuestionInitialData - ); - done(); - }); - }); -}); - -describe("vehicle-year.vue", () => { - test("arePagePrerequisitesValid should be true ", async () => { - //Arrange - const { wrapper } = setupMocks({}); - - //Act - vehicleYear.beforeRouteEnter.call( - wrapper.vm, - { query: { fmgPage: "vehicle-make" } }, - undefined, - (c) => c(wrapper.vm) - ); - - let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); - await nextTick(); - - //Assert - expect(arePagePrerequisitesValid).toBe(true); - }); -}); - -function setupMocks({ - vehicleYearQuestionCmsContent = {}, - yearQuestionInitialData = {}, - pageHeaderWidgetHeaderText = {}, - mountOptionsMockData = {}, -}) { - //Mock api responses - const apiResponses = { - cmsContent: { - FunnelSubHeaderWidget: { HeaderText: pageHeaderWidgetHeaderText }, - VehicleYearQuestion: vehicleYearQuestionCmsContent, - VehicleBannerWidget: { - GenericVehicleImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3", - }, - FunnelHeaderWidget: { - LogoImage: - "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3", - }, - }, - yearQuestionInitialData: yearQuestionInitialData, - }; - const apiPromise = Promise.resolve(apiResponses); - - settleAllPromises.mockImplementation(() => apiPromise); - fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - - //Mock year question methods - yearQuestion.methods = { - loadInitialData: jest.fn(), - initializeComponent: jest.fn(), - }; - - const mountOptions = getMountOptions(mountOptionsMockData); - const wrapper = shallowMount(vehicleYear, mountOptions); - const yearQuestionWrapper = wrapper.findComponent({ name: "yearQuestion" }); - yearQuestionWrapper.vm.initializeComponent = yearQuestion.methods.initializeComponent; - wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; - - return { wrapper, apiPromise }; -} diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue deleted file mode 100644 index 5b166151a..000000000 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - diff --git a/src/layouts/vehicle-year/year-question/year-question.spec.js b/src/layouts/vehicle-year/year-question/year-question.spec.js deleted file mode 100644 index f6a1e5e71..000000000 --- a/src/layouts/vehicle-year/year-question/year-question.spec.js +++ /dev/null @@ -1,78 +0,0 @@ -import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; -import { shallowMount } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import store from "@/store"; -jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } -); - -describe("year-question.vue", () => { - test("Selected year is emitted upon selection.", async () => { - //Arrange - const { wrapper } = setupMocks({ modelValueProp: "2020" }); - const yearToSelect = "2021"; - - //Act - wrapper.setValue({ modelValue: yearToSelect }); - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: "2021" }]); - }); -}); - -describe("year-question.vue", () => { - test("Data from store api are used as radio question answers.", async () => { - //Arrange - const { wrapper, cmsContent } = setupMocks({ - dataFromStoreApi: ["2023", "2022", "2021"], - }); - - //Act - const initialData = yearQuestion.methods.loadInitialData.call(wrapper.vm); - yearQuestion.methods.initializeComponent.call(wrapper.vm, initialData); - - //Assert - const buttonQuestionComponent = await wrapper.findComponent({ - name: "buttonQuestion", - }); - expect(buttonQuestionComponent.attributes("answers")).toBe("2023,2022,2021"); - }); -}); - -function setupMocks({ - modelValueProp = "1900", - cmsQuestionText = "CMS text goes here", - dataFromStoreApi = [], -}) { - //Mock store - store.dispatch = jest.fn(() => dataFromStoreApi); - const mountOptions = getMountOptions({ - store: { - dispatch: store.dispatch, - }, - }); - - //Mock props - const mockMixin = { - methods: { - getCmsContent: jest.fn(), - }, - }; - mountOptions.propsData = { - modelValue: modelValueProp, - }; - mountOptions.mixins = [mockMixin]; - - const wrapper = shallowMount(yearQuestion, mountOptions); - - //Mock CMS content - const cmsContent = { - QuestionText: cmsQuestionText, - }; - return { wrapper, cmsContent }; -} diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue deleted file mode 100644 index 6d8110216..000000000 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/src/router/router-constants/fmgPage-values.js b/src/router/router-constants/fmgPage-values.js index fc8841c13..ba931f77d 100644 --- a/src/router/router-constants/fmgPage-values.js +++ b/src/router/router-constants/fmgPage-values.js @@ -1,8 +1,4 @@ const fmgPageValues = { - VEHICLE_YEAR: "vehicle-year", - VEHICLE_MAKE: "vehicle-make", - VEHICLE_MODEL: "vehicle-model", - VEHICLE_STYLE: "vehicle-style", VEHICLE: "vehicle", VEHICLE_DAMAGE: "vehicle-damage", ADDRESS_LOOKUP: "address-lookup", diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index ce2f32134..bf89f4f3f 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -12,12 +12,6 @@ const navigationScenarios = { CLICKED_FORWARD: "CLICKED_FORWARD", CLICKED_FORWARD_WITH_CASH: "CLICKED_FORWARD_WITH_CASH", - // YMMS - SELECTED_YEAR: "SELECTED_YEAR", - SELECTED_MODEL: "SELECTED_MODEL", - SELECTED_MAKE: "SELECTED_MAKE", - SELECTED_STYLE: "SELECTED_STYLE", - // Vin selection CLICKED_BACK_WITH_VIN: "CLICKED_BACK_WITH_VIN", CLICKED_FORWARD_WITH_VIN: "CLICKED_FORWARD_WITH_VIN", diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index f1f83b445..b90806e94 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -13,54 +13,7 @@ const routingTable = function (store) { }, ], }, - { - fmgPageValue: fmgPageValues.VEHICLE_YEAR, - maps: [ - { - scenario: navigationScenarios.SELECTED_YEAR, - destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, - }, - ], - }, - { - fmgPageValue: fmgPageValues.VEHICLE_MAKE, - maps: [ - { - scenario: navigationScenarios.SELECTED_MAKE, - destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, - }, - { - scenario: navigationScenarios.CLICKED_BACK, - destinationFmgPageValue: fmgPageValues.VEHICLE_YEAR, - }, - ], - }, - { - fmgPageValue: fmgPageValues.VEHICLE_MODEL, - maps: [ - { - scenario: navigationScenarios.SELECTED_MODEL, - destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, - }, - { - scenario: navigationScenarios.CLICKED_BACK, - destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, - }, - ], - }, - { - fmgPageValue: fmgPageValues.VEHICLE_STYLE, - maps: [ - { - scenario: navigationScenarios.SELECTED_STYLE, - destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, - }, - { - scenario: navigationScenarios.CLICKED_BACK, - destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, - }, - ], - }, + { fmgPageValue: fmgPageValues.VEHICLE_DAMAGE, maps: [ diff --git a/src/store/index.js b/src/store/index.js index 635d685b4..4345daf01 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1568,88 +1568,6 @@ export const actions = { // Business domain actions // Vehicle - saveVehicleYear(context, year) { - //Reset dependent state when changing - if (context.state.order.vehicle.year !== year) { - context.commit(storeMutations.UPDATE_MAKE, null); - context.commit(storeMutations.UPDATE_MODEL, null); - context.commit(storeMutations.UPDATE_STYLE, null); - context.commit(storeMutations.UPDATE_CAR_ID, null); - context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - - context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); - - //Save new values - context.commit(storeMutations.UPDATE_YEAR, year); - } - }, - - saveVehicleMake(context, make) { - //Reset dependent state when changing - if (context.state.order.vehicle.make !== make) { - context.commit(storeMutations.UPDATE_MODEL, null); - context.commit(storeMutations.UPDATE_STYLE, null); - context.commit(storeMutations.UPDATE_CAR_ID, null); - context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - - context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); - - //Save new values - context.commit(storeMutations.UPDATE_MAKE, make); - } - }, - - saveVehicleModel(context, model) { - //Reset dependent state when changing - if (context.state.order.vehicle.model !== model) { - context.commit(storeMutations.UPDATE_STYLE, null); - context.commit(storeMutations.UPDATE_CAR_ID, null); - context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - - context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); - - //Save new values - context.commit(storeMutations.UPDATE_MODEL, model); - } - }, - - saveVehicleStyle(context, style) { - //Reset dependent state when changing - if (context.state.order.vehicle.style !== style) { - context.commit(storeMutations.UPDATE_CAR_ID, null); - context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - - context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); - - //Save new values - context.commit(storeMutations.UPDATE_STYLE, style); - } - }, - saveVehicle(context, { year, make, model, style, vehicle }) { context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); diff --git a/src/store/store.spec.js b/src/store/store.spec.js index e072eb164..186cf2d31 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1572,168 +1572,6 @@ describe("Actions", () => { expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); }); - it("saveVehicleYear, should wipe out vehicle info if year changes", () => { - // Arrange - const context = state; - - context.state = { - order: { - vehicle: { - year: "2015", - }, - }, - }; - - const commit = jest.fn(); - const dispatch = jest.fn(); - - context.commit = commit; - context.dispatch = dispatch; - - // Act - actions.saveVehicleYear(context, "2016"); - - // Assert - expect(dispatch).toHaveBeenNthCalledWith( - 1, - storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES - ); - expect(dispatch).toHaveBeenNthCalledWith( - 2, - storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES - ); - - expect(commit).toBeCalledWith(storeMutations.UPDATE_MAKE, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - }); - - it("saveVehicleMake, should wipe out vehicle info if make changes", () => { - // Arrange - const context = state; - - context.state = { - order: { - vehicle: { - make: "Honda", - }, - }, - }; - - const commit = jest.fn(); - const dispatch = jest.fn(); - - context.commit = commit; - context.dispatch = dispatch; - - // Act - actions.saveVehicleMake(context, "Toyota"); - - // Assert - expect(dispatch).toHaveBeenNthCalledWith( - 1, - storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES - ); - expect(dispatch).toHaveBeenNthCalledWith( - 2, - storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES - ); - - expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - }); - - it("saveVehicle model, should wipe out vehicle info if model changes", () => { - // Arrange - const context = state; - - context.state = { - order: { - vehicle: { - model: "Civic", - }, - }, - }; - - const commit = jest.fn(); - const dispatch = jest.fn(); - - context.commit = commit; - context.dispatch = dispatch; - - // Act - actions.saveVehicleModel(context, "Accord"); - - // Assert - expect(dispatch).toHaveBeenNthCalledWith( - 1, - storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES - ); - expect(dispatch).toHaveBeenNthCalledWith( - 2, - storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES - ); - - expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - }); - - it("saveVehicleStyle, should wipe out vehicle info if style changes", () => { - // Arrange - const context = state; - - context.state = { - order: { - vehicle: { - style: "Sedan", - }, - }, - }; - - const commit = jest.fn(); - const dispatch = jest.fn(); - - context.commit = commit; - context.dispatch = dispatch; - - // Act - actions.saveVehicleStyle(context, "SUV"); - - // Assert - expect(dispatch).toHaveBeenNthCalledWith( - 1, - storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES - ); - expect(dispatch).toHaveBeenNthCalledWith( - 2, - storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES - ); - - expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); - expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); - }); - it("saveVehicle, should save vehicle info", () => { // Arrange const context = state; From 435572ecc510d53550683d3730f14bbe38e91273 Mon Sep 17 00:00:00 2001 From: Sneha Date: Mon, 21 Aug 2023 18:09:25 +0530 Subject: [PATCH 2/2] Update index.js --- src/store/index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 4345daf01..35b4c266e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1568,8 +1568,12 @@ export const actions = { // Business domain actions // Vehicle - saveVehicle(context, { year, make, model, style, vehicle }) { - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); + saveVehicle( + context, + { year, make, model, style, carId, category, imageUrl, imageVifNumber, imageVifColor } + ) { + context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); if (context.state.order.vehicle.year !== year) { context.commit(storeMutations.UPDATE_YEAR, year); @@ -1583,11 +1587,11 @@ export const actions = { if (context.state.order.vehicle.style !== style) { context.commit(storeMutations.UPDATE_STYLE, style); } - context.commit(storeMutations.UPDATE_CAR_ID, vehicle.carId); - context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, vehicle.category); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, vehicle.imageUrl); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, vehicle.imageVifNumber); - context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, vehicle.imageVifColor); + context.commit(storeMutations.UPDATE_CAR_ID, carId); + context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, category); + context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, imageUrl); + context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, imageVifNumber); + context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, imageVifColor); }, saveVehicleDamage(