diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index 096728af8..ba1343d7c 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -220,6 +220,28 @@ describe("vin-lookup.vue", () => { expect(wrapper.vm.displayInvalidZipAlert).toEqual(true); expect(wrapper.findComponent({ ref: "alertInvalidZip" }).exists()).toBe(true); }); + + test("alerts are displayed and continue button is clicked with issues fixed => alerts are reset", async () => { + // Arrange + const { wrapper } = setupMocks({}); + mockOutPromises({ isZipValid: true, isZipServiceable: true, carId: "CARID" }); + await wrapper.setData({ + displayInvalidZipAlert: true, + displayMatchedDifferentVehicleAlert: true, + displayNonServiceableZipAlert: true, + displayVinNotFoundAlert: true, + }); + + // sanity check that there are alerts + expect(wrapper.findAllComponents({ name: "alert" }).length).toBe(4); + + // Act + wrapper.vm.forwardButtonAction(); + await wrapper.vm.$nextTick(); + + // Assert + expect(wrapper.findAllComponents({ name: "alert" }).length).toBe(0); + }); }); }); @@ -244,8 +266,8 @@ function mockOutPromises({ carId, isZipValid = true, isZipServiceable = true }) carId: carId, }, zipCodeData: { - isValid: true, - isServiceable: true, + isValid: isZipValid, + isServiceable: isZipServiceable, state: "OH", }, }; diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index f4543f7c2..429075a40 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -226,6 +226,8 @@ export default { } }, async forwardButtonAction() { + this.resetAlerts(); + // If this is a new VIN Lookup, do both a Vehicle Lookup and a Zip Validation if (!this.vinPopulatedOnPageLoad) { const vehicleLookupResponse = this.dispatchStoreAction( @@ -372,6 +374,12 @@ export default { await this.navigateForwardWithSingleCarMatch(); } }, + resetAlerts() { + this.displayMatchedDifferentVehicleAlert = false; + this.displayNonServiceableZipAlert = false; + this.displayInvalidZipAlert = false; + this.displayVinNotFoundAlert = false; + }, }, mounted() { this.attachCustomEvents();