diff --git a/jest.config.js b/jest.config.js index b594d4aef..82b2b587e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -19,15 +19,17 @@ module.exports = { "!src/layouts/part-questions/**/*.vue", "!src/layouts/reveal/**/*.vue", "!src/layouts/estimate/**/*.vue", - // REMOVE THESE AFTER WRITING UNIT TESTS + // TODO REMOVE THESE AFTER WRITING UNIT TESTS "!src/layouts/address-lookup/address-lookup.vue", "!src/layouts/address-lookup/customer-questions/customer-questions.vue", "!src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue", + "!src/layouts/address-vehicles/address-vehicles.vue", + "!src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue", "!src/common-components/dropdown-question/dropdown-question.vue", "!src/common-components/textbox-question/textbox-question.vue", "!src/helpers/validation-rules.js", // END - ], //! means exclude from coverage. + ], // ! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index bd6ce8b22..369bf1c06 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -1,8 +1,8 @@ @@ -160,7 +160,7 @@ export default { }; - diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index abac8a91f..a09aa9cd2 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -30,10 +30,10 @@ @@ -51,7 +51,6 @@ export default { isForwardActionDisabled: Boolean, isBackButtonHidden: {type: Boolean, default: false}, cmsWidgetName: String, - }, components: { textLink, @@ -106,7 +105,7 @@ export default { linkClick() { this.$emit("BackClicked"); }, - } + }, }; diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index a9f09326b..a064cfecb 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -23,6 +23,7 @@ const errorMessages = { VIN_REQUIRED: "Please enter your VIN", VIN_FORMAT: "Invalid VIN. Please make sure that you entered the correct 17-digit, alpha-numeric number. VINs do not contain the letters I, O, or Q", OPTION_REQUIRED: "Please select an option", + VEHICLE_REQUIRED: "Please select a vehicle", }; export { errorMessages }; diff --git a/src/helpers/damage-helper.js b/src/helpers/damage-helper.js index f47499bed..a3b9a2878 100644 --- a/src/helpers/damage-helper.js +++ b/src/helpers/damage-helper.js @@ -5,7 +5,10 @@ import { storeActions } from "@/constants/store-actions"; export function getDamageString() { const damageLocations = store.getters.damage.glassToReplace; let returnString; - if(damageLocations.length > 1){ + if (!damageLocations) { + return; + } + if (damageLocations.length > 1) { returnString = "match" } else { switch(damageLocations[0]?.location) { diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 54f096896..0d60df06a 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -290,9 +290,7 @@ export default { navigateAfterSaveToHeritageFunnel(this.$route); } else { // and there is no match, navigate to "address-vehicles" page - this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, - this.$route, {}, {}, - carsFound); + this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound); } } diff --git a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js1 b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js1 new file mode 100644 index 000000000..05fd2a0eb --- /dev/null +++ b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js1 @@ -0,0 +1,113 @@ +import { shallowMount } from "@vue/test-utils"; +import addressVehiclesQuestion from "@/layouts/address-vehicles/address-vehicles-question/address-vehicles-question"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +// import store from "@/store"; + +// jest.mock("@/store", () => { return {}; }, { virtual: true }); + +describe("addressVehiclesQuestion.vue", () => { + + it("Should include button-question component", () => { + // Arrange + const wrapper = shallowMount(addressVehiclesQuestion, { + propsData: { + // vehicles: [ + // { + // "Name": "testname", + // "Text": "testtext", + // } + // ] + } + }); + + // console.log('wrapper.html: ', wrapper.html()); + + // Assert + const buttonQuestion = wrapper.find('button-question-stub'); + expect(buttonQuestion).toBe; + }); + + it("on initialize should pass in questionText", () => { + // Arrange + const wrapper = shallowMount(addressVehiclesQuestion, { + propsData: {}, + }); + + //Act + addressVehiclesQuestion.methods.initializeComponent.call(wrapper.vm, {QuestionText: 'Testing question text'}); + + // console.log('wrapper.html: ', wrapper.html()); + // console.log('wrapper.vm.questionText: ', wrapper.vm.questionText); + + // Assert + expect(wrapper.vm.questionText).toEqual('Testing question text'); + }); + + // it("Alert should show if prop isCarIdDifferent is true", () => { + // // Arrange + // const wrapper = shallowMount(addressVehiclesQuestion, setupMountOptions({ + // propsData: { + // isCarIdDifferent: true, + // } + // })); + + // //Act + // const alert = wrapper.find('alert'); + // console.log('wrapper.html: ', wrapper.html()); + // console.log('wrapper.vm.questionText: ', wrapper.vm.questionText); + + // // Assert + // // expect(wrapper.vm.questionText).toEqual('Testing question text'); + // }); + +}); + + + +function setupMountOptions(mountOptionsMockData = {}) { + // //Mock store + // store.dispatch = jest.fn(() => {}); + // store.getters = {}; + + // const mockMixin = { + // methods: { + // getCmsContent: jest.fn().mockImplementation(() => { + // return ''; + // }), + // getDamageString: jest.fn().mockImplementation(() => { + // return ''; + // }) + // }, + // store: { + // dispatch: store.dispatch, + // getters: store.getters, + // }, + // } + + const mockGetCmsContent = jest.fn(); + mockGetCmsContent((cmsWidget, field) => { + return field + }); + const defaultMountOptions = { + // route: { query: { fmgPage: 'page-name' } }, + mixins: { + methods: { + getCmsContent: mockGetCmsContent, + }, + }, + global: { + mocks: { + store: { + dispatch: store.dispatch, + getters: store.getters, + }, + }, + }, + }; + const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData)); + const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions); + + console.log('what are allMountOptions??? ', allMountOptions); + + return allMountOptions; +} \ No newline at end of file diff --git a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue new file mode 100644 index 000000000..95d2b1fd0 --- /dev/null +++ b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue @@ -0,0 +1,94 @@ + + + + + \ No newline at end of file diff --git a/src/layouts/address-vehicles/address-vehicles.spec.js1 b/src/layouts/address-vehicles/address-vehicles.spec.js1 new file mode 100644 index 000000000..f4dab360c --- /dev/null +++ b/src/layouts/address-vehicles/address-vehicles.spec.js1 @@ -0,0 +1,26 @@ +import { shallowMount } from "@vue/test-utils"; +import addressVehicles from "@/layouts/address-vehicles/address-vehicles"; + +describe("addressVehicles.vue", () => { + + it("Should include address-vehicles-question component", () => { + // Arrange + const wrapper = shallowMount(addressVehicles, { + propsData: { + vehicles: [ + { + "Name": "testname", + "Text": "testtext", + } + ] + } + }); + + // console.log('wrapper.html: ', wrapper.html()); + + // Assert + const addressVehiclesQuestion = wrapper.find('address-vehicles-question-stub'); + expect(addressVehiclesQuestion).toBe; + }); + +}); diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue new file mode 100644 index 000000000..f21015061 --- /dev/null +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -0,0 +1,243 @@ + + + + + \ No newline at end of file diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index cd2d876b3..9404fcfa2 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -139,8 +139,22 @@ const routingTable = [ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, }, ], - }, - {fmgPageValue: fmgPageValues.ESTIMATE, + }, + { + fmgPageValue: fmgPageValues.ADDRESS_VEHICLES, + maps: [ + { + scenario: navigationScenarios.CLICKED_BACK, + destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD, + destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, + }, + ], + }, + { + fmgPageValue: fmgPageValues.ESTIMATE, maps: [ { scenario: navigationScenarios.CLICKED_BACK, diff --git a/src/ux-components/alert/alert.vue b/src/ux-components/alert/alert.vue index 3dc64e497..0722d8bbb 100644 --- a/src/ux-components/alert/alert.vue +++ b/src/ux-components/alert/alert.vue @@ -41,7 +41,7 @@ export default { isDismissible: Boolean, /* alertClass class names: - alert-sucess (green) + alert-success (green) alert-danger (red) alert-warning (yellow) alert-info (blue)