diff --git a/jest.config.js b/jest.config.js index 07bc61459..82b2b587e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -24,6 +24,7 @@ module.exports = { "!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", 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.js1 similarity index 100% rename from src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js rename to src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.spec.js1 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 7013ea160..95d2b1fd0 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 @@ -29,19 +29,12 @@ import { getDamageString } from "@/helpers/damage-helper"; export default { name: "address-vehicles-question", - data() { - return { - questionText: String, - customAlertData: {}, - }; - }, props: { vehicles: Array, modelValue: String, cmsWidgetName: String, validationRules: String, isCarIdDifferent: Boolean, - selectedVehicle: Object, }, computed: { differentVehicleAlertHeader() { @@ -66,18 +59,19 @@ export default { this.selectedVehicle?.vehicle.model ); }, - selectedVehicleVin: { - get: function() { - return this.modelValue; - }, - set: function(newValue) { - this.$emit("update:modelValue", newValue); - } + questionText() { + return this.getCmsContent("VehicleConfirmationQuestion", "QuestionText"); }, - }, - methods: { - initializeComponent(VehicleConfirmationQuestion) { - this.questionText = VehicleConfirmationQuestion.QuestionText; + selectedVehicleVin: { + get: function() { + return this.modelValue; + }, + set: function(newValue) { + this.$emit("update:modelValue", newValue); + } + }, + selectedVehicle() { + return this.vehicles.find( ({ vin }) => vin === this.selectedVehicleVin[0] ); }, }, components: { diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue index d68eaf84a..f21015061 100644 --- a/src/layouts/address-vehicles/address-vehicles.vue +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -24,7 +24,6 @@ :vehicles="VehiclesForQuestions" validationRules="vehicle-required" v-model="selectedVehicleVin" - :selectedVehicle="selectedVehicle" :isCarIdDifferent="isCarIdDifferent" />
@@ -92,7 +91,6 @@ export default { // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); - vm.$refs.addressVehiclesQuestion.initializeComponent(resultMap.cmsContent.VehicleConfirmationQuestion); }); }, props: { @@ -101,7 +99,6 @@ export default { data() { return { selectedVehicleVin: null, - selectedVehicle: {}, isCarIdDifferent: false, isSelectedGlassAvailableForVehicle: true, }; @@ -122,7 +119,6 @@ export default { return this.AlertProvideVinBody.split(/{(.*?)}/g); }, VehiclesForQuestions() { - const vehiclesData = this.VehiclesFromApi; // Map API result data, to address-vehicles data structure @@ -130,7 +126,6 @@ export default { const maskSymbol = "X"; const vinStart = maskSymbol.repeat(v.vin.length-4); const vinEnd = v.vin.substring(v.vin.length-4); - return { vin: v.vin, vehicle: v.vehicle, @@ -138,7 +133,6 @@ export default { Name: v.vin, SubText: "VIN " + vinStart + vinEnd, }; - }); return mappedData; @@ -146,6 +140,9 @@ export default { VehiclesFromApi() { return store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES); }, + selectedVehicle() { + return this.VehiclesForQuestions.find( ({ vin }) => vin === this.selectedVehicleVin[0] ); + }, }, methods: { arePagePrerequisitesValid() { @@ -214,8 +211,6 @@ export default { watch: { selectedVehicleVin(vehicleVin) { - const selectedVin = vehicleVin[0]; - this.selectedVehicle = this.VehiclesForQuestions.find( ({ vin }) => vin === selectedVin ); // 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}`);