diff --git a/src/layouts/address-lookup/address-lookup.spec.js b/src/layouts/address-lookup/address-lookup.spec.js index ebc75059..ae7658c5 100644 --- a/src/layouts/address-lookup/address-lookup.spec.js +++ b/src/layouts/address-lookup/address-lookup.spec.js @@ -7,7 +7,6 @@ import { shallowMount } from "@vue/test-utils"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { useMainStore } from "@/store"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; -import e from "express"; jest.mock("@/helpers/damage-helper", () => ({ isGlassAvailableForCarId: jest.fn().mockImplementation(() => true), @@ -21,48 +20,6 @@ jest.mock("@/helpers/layout-helper.js", () => ({ describe("address-lookup.vue", () => { describe("page level alerts", () => { - test("if the address is not serviceable display the Non-Serviceable Zip Alert", async () => { - // Arrange - const mockRegistrationAddress = { - streetAddress: "1234 Main St", - city: "Columbus", - state: "OH", - zipCode: "43215", - }; - - const { wrapper } = setupMocks({ - isZipValid: true, - isZipServiceable: false, - vinVehicles: [ - { - vin: "TEST_VIN", - vehicle: { - carId: "C0000", - }, - }, - { - vin: "TEST_VIN", - vehicle: { - carId: "C0000", - }, - }, - ], - }); - - await wrapper.setData({ - customerQuestions: { - addressQuestions: mockRegistrationAddress, - }, - - }); - - // Act - await wrapper.vm.forwardButtonAction(); - - // Assert - expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true); - }); - test("if the address matches a different vehicle display the Matched Different VehicleAlert", async () => { // Arrange const mockRegistrationAddress = { @@ -73,7 +30,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, vinVehicles: [ { vehicle: { @@ -110,7 +66,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, isStatePermissible: false, lookupVinbyAddressResponse: { isStatePermissible: false, @@ -158,7 +113,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, lookupVinbyAddressResponse: { isStatePermissible: true, vinVehicles: [], // Return no vehicles @@ -188,7 +142,6 @@ describe("address-lookup.vue", () => { test("if the back button is clicked, navigate back", async () => { // Arrange const { wrapper } = setupMocks({ - isZipServiceable: true, }); // Act @@ -198,7 +151,7 @@ describe("address-lookup.vue", () => { expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); }); - test("if the car entered matches one of the vehicles found and the zip is serviceable, navigate forward", async () => { + test("if the car entered matches one of the vehicles found navigate forward", async () => { // Arrange const mockRegistrationAddress = { streetAddress: "1234 Main St", @@ -208,7 +161,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, vinVehicles: [ { vehicle: { @@ -244,7 +196,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, isStatePermissible: true, vinVehicles: [ { @@ -299,52 +250,7 @@ describe("address-lookup.vue", () => { carsFound ); }); - - test("if the car entered matches one of the vehicles found but the zip is NOT serviceable, do not navigate forward", async () => { - // Arrange - const mockRegistrationAddress = { - streetAddress: "1234 Main St", - city: "Columbus", - state: "OH", - zipCode: "43215", - }; - - const { wrapper } = setupMocks({ - isZipServiceable: false, - isStatePermissible: true, - vinVehicles: [ - { - vin: "TEST_VIN", - vehicle: { - carId: "CARID", - }, - }, - { - vin: "TEST_VIN2", - vehicle: { - carId: "CARID2", - }, - }, - ], - }); - - useMainStore().order.vehicle.carId = "CARID"; - - await wrapper.setData({ - customerQuestions: { - addressQuestions: mockRegistrationAddress, - }, - }); - - wrapper.vm.navigateForward = jest.fn(); - - // Act - await wrapper.vm.forwardButtonAction(); - - // Assert - expect(wrapper.vm.navigateForward).toHaveBeenCalledTimes(0); - }); - + test("if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page", async () => { // Arrange const mockRegistrationAddress = { @@ -355,7 +261,6 @@ describe("address-lookup.vue", () => { }; const { wrapper } = setupMocks({ - isZipServiceable: true, isStatePermissible: true, }); @@ -450,135 +355,9 @@ describe("address-lookup.vue", () => { }); }); - - describe("registration and service zips", () => { - describe("if registration zip is serviceable", () => { - test("if registration address is provided => update service address on successful continue", async () => { - // Arrange - const mockRegistrationAddress = { - streetAddress: "1234 Main St", - city: "Columbus", - state: "OH", - zipCode: "43215", - }; - - const { wrapper } = setupMocks({ - isZipServiceable: true, - isStatePermissible: true, - vinVehicles: [ - { - vin: "TEST_VIN", - vehicle: { - carId: "CARID", - }, - }, - ], - route: { query: "address-lookup" }, - }); - - useMainStore().order.vehicle.carId = "CARID"; - useMainStore().saveRegistrationAddressLookup = jest.fn(); - - await wrapper.setData({ - customerQuestions: { - addressQuestions: mockRegistrationAddress, - }, - }); - - // Act - await wrapper.vm.forwardButtonAction(); - - // Assert - expect(useMainStore().saveRegistrationAddressLookup).toHaveBeenCalled(); - expect(useMainStore().validateZip).toHaveBeenCalledWith({ zip: "43215" }); - }); - }); - - describe("if registration zip is not serviceable", () => { - test("if registration address is provided and user clicks continue => show non-serviceable zip alert", async () => { - // Arrange - const mockRegistrationAddress = { - streetAddress: "1234 Main St", - city: "Columbus", - state: "OH", - zipCode: "43215", - }; - - const { wrapper } = setupMocks({ - isZipValid: true, - isZipServiceable: false, - vinVehicles: [ - { - vin: "TEST_VIN", - vehicle: { - carId: "C0000", - }, - }, - ], - }); - - useMainStore().order.vehicle.carId = "C0000"; - - await wrapper.setData({ - customerQuestions: { - addressQuestions: mockRegistrationAddress, - }, - }); - - expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).exists()).toBe( - false - ); - - // Act - await wrapper.vm.forwardButtonAction(); - - // Assert - expect(wrapper.vm.displayNonServiceableZipAlert).toBe(true); - expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).exists()).toBe( - true - ); - expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe( - true - ); - }); - - test("if registration address, service zip are provided, and user clicks continue => don't update service address", async () => { - // Arrange - const mockRegistrationAddress = { - streetAddress: "1234 Main St", - city: "Columbus", - state: "OH", - zipCode: "43215", - }; - - const { wrapper } = setupMocks({ - isZipServiceable: false, - }); - - useMainStore().order.vehicle.carId = "CARID"; - - await wrapper.setData({ - customerQuestions: { - addressQuestions: mockRegistrationAddress, - }, - }); - - useMainStore().saveRegistrationAddressLookup = jest.fn(); - - // Act - await wrapper.vm.forwardButtonAction(); - - // Assert - expect(useMainStore().saveRegistrationAddressLookup).not.toHaveBeenCalled(); - }); - }); - }); - }); function setupMocks({ - isZipValid = true, - isZipServiceable = true, lookupVinbyAddressResponse, partsOrQuestions = [], isStatePermissible = true, @@ -587,16 +366,6 @@ function setupMocks({ route = null, }) { - - useMainStore().validateZip = jest.fn().mockImplementation(() => { - return Promise.resolve({ - data: { - isValid: isZipValid, - isServiceable: isZipServiceable, - }, - }) - }); - useMainStore().lookupVinByAddress = jest.fn().mockImplementation(() => { return Promise.resolve({ data: lookupVinbyAddressResponse @@ -652,10 +421,6 @@ function setupMocks({ ); const apiResponses = { - serviceZipValidationResponse: { - isValid: isZipValid, - isServiceable: isZipServiceable, - }, vinLookupResponse: { isStatePermissible: isStatePermissible, vinVehicles: vinVehicles, diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index b88c10c6..77ee771a 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -28,21 +28,6 @@ :manualCopy="AlertMatchedDifferentVehicleBody" alertClass="alert-warning" v-bind:isDismissible="false" /> - - - -
-
-
- -
-
-
-
+ + 1) { + // If multiple cars were found and one and only one of them matches the carId entered, save the vehicle info - // so we can go to the Heritage Funnel directly const matchingCars = carsFound.filter( (vin) => vin.vehicle.carId === this.mainStore.order.vehicle.carId ); @@ -273,52 +218,26 @@ export default { return this.$refs.siteFooter.removeLoader(); } - // If the either the registration zip code or service zip code are not serviceable - this.isZipServiceable = resultMap.serviceZipValidationResponse.isServiceable; - if (!this.isZipServiceable) { - this.displayNonServiceableZipAlert = true; - this.$refs.siteFooter.disableForwardButton(); - this.showServiceZipField = true; - return this.$refs.siteFooter.removeLoader(); - } - - // If the registration zip code is serviceable and nothing was entered for the service zip code - // then set the service zip code to the registration zip code - if (!this.serviceZipCode) { - this.serviceZipCode = this.customerQuestions.addressQuestions.zipCode; - } - // Save vehicle, customer, service and registration information await useMainStore().saveRegistrationAddressLookup( { isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, vehicleInfo: Object.keys(vehicleInfoToCommit).length === 0 - ? this.mainStore.order.vehicle + ? useMainStore().order.vehicle : vehicleInfoToCommit, registrationInfo: { firstName: this.customerQuestions.firstName, lastName: this.customerQuestions.lastName, address: this.customerQuestions.addressQuestions.streetAddress, city: this.customerQuestions.addressQuestions.city, - state: resultMap.serviceZipValidationResponse.state, + state: this.customerQuestions.addressQuestions.state, zipCode: this.customerQuestions.addressQuestions.zipCode, }, }, false ); - await useMainStore().saveServiceLocation( - { - address: this.customerQuestions.addressQuestions.streetAddress, - city: this.customerQuestions.addressQuestions.city, - zipCode: this.serviceZipCode, - state: resultMap.serviceZipValidationResponse.state, - zipCodeCtu: resultMap.serviceZipValidationResponse.zipCodeCtu, - }, - false - ); - return await this.navigateForward(carsFound); }, async navigateForward(carsFound) { @@ -353,7 +272,6 @@ export default { }, resetWarningsAndErrors() { this.displayVinNotFoundAlert = false; - this.displayNonServiceableZipAlert = false; this.displayMatchedDifferentVehicleAlert = false; this.displayVinLookupByHomeAddressNotAllowedAlert = false; this.$refs.siteFooter.enableForwardAction(); @@ -364,19 +282,6 @@ export default { this.loadDefaultsFromStore(); }, computed: { - AlertNonServiceableZipHeader() { - const zipCode = this.serviceZipCode - ? this.serviceZipCode - : this.customerQuestions.addressQuestions.zipCode; - const text = this.getCmsContent( - "AlertNonServiceableZipWidget", - "HeadlineText" - ).replaceAll("{custom:serviceZip}", zipCode); - return text; - }, - AlertNonServiceableZipBody() { - return this.getCmsContent("AlertNonServiceableZipWidget", "BodyText"); - }, AlertMatchedDifferentVehicleHeader() { return this.getCmsContent( "AlertMatchedDifferentVehicleWidget", @@ -400,25 +305,10 @@ export default { this.$refs.siteFooter.updateButtonText( this.getCmsContent("siteFooterWidget", "ForwardButtonText") ); - this.showServiceZipField = false; this.resetWarningsAndErrors(); }, deep: true, - }, - serviceZipCode: { - handler(newValue) { - // If they modify the service zip code, then hide the error message. - this.resetWarningsAndErrors(); - }, - }, - showServiceZipField: { - handler(newValue) { - // If the Service Zip Code field is ever hidden, clear out it's value - if (!newValue) { - this.serviceZipCode = null; - } - }, - }, + } }, components: { siteHeader,