diff --git a/jest.config.js b/jest.config.js index fe6eeb04d..7831629c1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -11,14 +11,10 @@ module.exports = { "!src/constants/*.js", "!src/router/**/*.js", "!src/helpers/unit-test-helper.js", - "!src/layouts/component-test/component-test.vue", - "!src/layouts/form-test/form-test.vue", - "!src/layouts/vin-lookup/vin-lookup.vue", "!src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue", "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", "!src/layouts/part-questions/**/*.vue", "!src/layouts/reveal/**/*.vue", - "!src/layouts/estimate/**/*.vue", // TODO REMOVE THESE AFTER WRITING UNIT TESTS "!src/ux-components/alert/alert.vue", "!src/helpers/validation-rules.js", diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index ef56c4041..8ab4ea4f1 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -24,7 +24,6 @@ export default { name: "questionChain", data() { return { - models: Array, currentQuestion: 1, answeredQuestions: [], }; diff --git a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js index d030c7c76..04bcdb366 100644 --- a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js +++ b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js @@ -39,7 +39,7 @@ describe("addressVehiclesQuestion.vue", () => { // Act const localThis = { $emit: jest.fn() } - addressVehiclesQuestion.computed.selectedVehicleVin.set.call(localThis, 'newValue'); + addressVehiclesQuestion.computed.selectedVehicleVinAsArray.set.call(localThis, ['newValue']); // Assert expect(localThis.$emit).toBeCalledWith("update:modelValue", "newValue"); 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 index 95d2b1fd0..0c7a75ea7 100644 --- a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue +++ b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue @@ -5,7 +5,7 @@ groupName="ChooseAddressVehicle" :questionText="questionText" :answers="vehicles" - v-model="selectedVehicleVin" + v-model="selectedVehicleVinAsArray" isRequired=true :validation-rules="validationRules" /> @@ -62,16 +62,18 @@ export default { questionText() { return this.getCmsContent("VehicleConfirmationQuestion", "QuestionText"); }, - selectedVehicleVin: { + selectedVehicleVinAsArray: { get: function() { - return this.modelValue; + const modelValueAsArray = this.modelValue ? [this.modelValue] : []; + return modelValueAsArray; }, set: function(newValue) { - this.$emit("update:modelValue", newValue); + const newValueAsScalar = newValue && newValue.length > 0 ? newValue[newValue.length-1] : null; + this.$emit("update:modelValue", newValueAsScalar); } }, - selectedVehicle() { - return this.vehicles.find( ({ vin }) => vin === this.selectedVehicleVin[0] ); + selectedVehicle() { // this computed is only needed for the computed differentVehicleAlertBody text above + return this.vehicles.find( ({ vin }) => vin === this.selectedVehicleVinAsArray[this.selectedVehicleVinAsArray.length-1] ); }, }, components: { diff --git a/src/layouts/address-vehicles/address-vehicles.spec.js b/src/layouts/address-vehicles/address-vehicles.spec.js index 74b8a02bb..fcccb1d94 100644 --- a/src/layouts/address-vehicles/address-vehicles.spec.js +++ b/src/layouts/address-vehicles/address-vehicles.spec.js @@ -57,7 +57,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', }); wrapper.vm.backButtonAction(); @@ -87,7 +87,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', }); await wrapper.vm.forwardButtonAction(); @@ -117,7 +117,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', }); await wrapper.vm.forwardButtonAction(); wrapper.vm.$nextTick(); @@ -144,7 +144,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', isSelectedGlassAvailableForVehicle: false, isCarIdDifferent: true, }); @@ -176,7 +176,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', isCarIdDifferent: false, }); await wrapper.vm.resetDependentState(); @@ -194,7 +194,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', isCarIdDifferent: false, }); await wrapper.vm.resetDependentState(); @@ -213,7 +213,7 @@ describe("addressVehicles.vue", () => { // Act await wrapper.setData({ - selectedVehicleVin: ['5NMS3CADXLH233004'], + selectedVehicleVin: '5NMS3CADXLH233004', isSelectedGlassAvailableForVehicle: false, isCarIdDifferent: true, }); diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue index c9bcb95bb..8a36bb51f 100644 --- a/src/layouts/address-vehicles/address-vehicles.vue +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -102,7 +102,7 @@ export default { }, data() { return { - selectedVehicleVin: null, + selectedVehicleVin: "", isCarIdDifferent: false, isSelectedGlassAvailableForVehicle: true, }; @@ -145,7 +145,7 @@ export default { return store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES); }, selectedVehicle() { - return this.VehiclesForQuestions.find( ({ vin }) => vin === this.selectedVehicleVin[0] ); + return this.VehiclesForQuestions.find( ({ vin }) => vin === this.selectedVehicleVin ); }, }, methods: { @@ -219,10 +219,13 @@ export default { }, watch: { - selectedVehicleVin() { - // does this vehicle match the previously selected carId? - this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId; - this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`); + selectedVehicleVin: { + handler() { + // does this vehicle match the previously selected carId? + this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId; + this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`); + }, + deep: true }, }, diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue deleted file mode 100644 index 6cc264405..000000000 --- a/src/layouts/component-test/component-test.vue +++ /dev/null @@ -1,1201 +0,0 @@ - - - diff --git a/src/layouts/form-test/form-test.vue b/src/layouts/form-test/form-test.vue deleted file mode 100644 index 8489f9558..000000000 --- a/src/layouts/form-test/form-test.vue +++ /dev/null @@ -1,244 +0,0 @@ - - - diff --git a/src/router/index.js b/src/router/index.js index b3cc73be1..e0b789f81 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,22 +18,7 @@ import eventBus from "@/helpers/event-bus/event-bus"; import store from "@/store"; import analyticsMixin from "@/mixins/analytics-mixin"; -// Components -import ComponentTest from "@/layouts/component-test/component-test.vue"; -import FormTest from "@/layouts/form-test/form-test.vue"; - - const routes = [ - { - path: "/component-test", // This is a temporary route for testing. - name: "ComponentTest", - component: ComponentTest, - }, - { - path: "/form-test", // This is a temporary route for testing. - name: "FormTest", - component: FormTest, - }, { path: "/", name: "root",