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 b9cd7e02..905b5c9e 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 @@ -24,7 +24,7 @@ describe("address-vehicles-question.vue", () => { }); // Assert - expect(wrapper.vm.differentVehicleAlertHeader).toEqual("FoundWindshieldTestReturn"); + expect(wrapper.vm.differentVehicleAlertHeader).toEqual("AlertMatchedDifferentVehicleWidgetTestReturn"); }); test("Should return content for differentVehicleAlertBody", () => { // Arrange @@ -37,15 +37,40 @@ describe("address-vehicles-question.vue", () => { }); // Assert - expect(wrapper.vm.differentVehicleAlertBody).toEqual("FoundWindshieldTestReturn"); + expect(wrapper.vm.differentVehicleAlertBody).toEqual("AlertMatchedDifferentVehicleWidgetTestReturn"); + }); + test("Should return content for AlertMatchedTwoIdenticalYMMVehicleHeader", () => { + // Arrange + const wrapper = shallowMount(addressVehiclesQuestion, { + mixins: [mockMixin], + }); + + // Assert + expect(wrapper.vm.AlertMatchedTwoIdenticalYMMVehicleHeader).toEqual("AlertMatchedTwoIdenticalYMMVehicleWidgetTestReturn"); + }); + test("Should return content for AlertMatchedTwoIdenticalYMMVehicleBody", () => { + // Arrange + const wrapper = shallowMount(addressVehiclesQuestion, { + mixins: [mockMixin], + propsData: { + vehicles: ["1", "2"], + modelValue: ["1", "2"], + }, + }); + + // Assert + expect(wrapper.vm.AlertMatchedTwoIdenticalYMMVehicleBody).toEqual("AlertMatchedTwoIdenticalYMMVehicleWidgetTestReturn"); }); }); const mockMixin = { methods: { getCmsContent: jest.fn((contentName) => { - if (contentName === "FoundWindshield") { - return "FoundWindshieldTestReturn"; + if (contentName === "AlertMatchedDifferentVehicleWidget") { + return "AlertMatchedDifferentVehicleWidgetTestReturn"; + } + if (contentName === "AlertMatchedTwoIdenticalYMMVehicleWidget") { + return "AlertMatchedTwoIdenticalYMMVehicleWidgetTestReturn"; } return null; }), 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 798007a7..42d13c2d 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 @@ -2,14 +2,24 @@
+
vin === this.selectedVehicleVin); }, + vehicleSelected(){ + return this.vehicleSelected; + } }, components: { buttonQuestion, diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue index 33dbf9a6..11c982da 100644 --- a/src/layouts/address-vehicles/address-vehicles.vue +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -31,9 +31,13 @@ ref="addressVehiclesQuestion" cmsWidgetName="VehicleConfirmationQuestion" :vehicles="VehiclesForQuestions" + :vehicleSelected ="VehicleSelected" validationRules="vehicle-required" v-model="selectedVehicleVin" :isCarIdDifferent="isCarIdDifferent" + :displayMatchedDifferentVehicleAlert = "displayMatchedDifferentVehicleAlert" + :displayMatchedTwoIdenticalYMMVehicleAlert = "displayMatchedTwoIdenticalYMMVehicleAlert" + />
vin === this.selectedVehicleVin ); }, + VehicleSelected(){ + return this.mainStore.order.vehicle; + } }, methods: { doesCopyContainRouterLink, @@ -226,16 +242,32 @@ export default { await this.navigateForwardWithSingleCarMatch(); } }, + resetWarningsAndErrors() { + this.displayMatchedDifferentVehicleAlert = false; + this.displayMatchedTwoIdenticalYMMVehicleAlert = false; + this.forwardButtonCarStyle = ""; + } }, watch: { selectedVehicleVin: { handler() { + this.resetWarningsAndErrors(); // does this vehicle match the previously selected carId? this.isCarIdDifferent = this.selectedVehicle?.vehicle.carId !== useMainStore().vehicle.carId; - if (this.isCarIdDifferent) { + if (this.isCarIdDifferent && + this.selectedVehicle?.vehicle.carId !== this.previouslyEnteredCarId) { + this.previouslyEnteredCarId = this.selectedVehicle?.vehicle.carId; + if(this.isTwoIdenticalYMMVehicleFound){ + const carStyle = this.selectedVehicle?.vehicle.style; + this.displayMatchedTwoIdenticalYMMVehicleAlert = true; + this.forwardButtonCarStyle= carStyle; + } + else{ + this.displayMatchedDifferentVehicleAlert = true; + } this.$refs.siteFooter.updateButtonText( - `Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}` + `Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model} ${this.forwardButtonCarStyle}` ); } else { this.$refs.siteFooter.updateButtonText(