diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js index e71eaecf..f1f784a0 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js +++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js @@ -28,8 +28,6 @@ function setupMocks({ isZipServiceable = true, lookupVinByPlateResponse, partsOrQuestions = [], - vehicle = {}, - vin = null, carId = 'C0000', vinLookupResponseError = null, route = null @@ -47,7 +45,8 @@ function setupMocks({ vehicle: { carId: 'CARID' } - } + }, + error: vinLookupResponseError })); useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => Promise.resolve({ @@ -78,19 +77,7 @@ function setupMocks({ }) ); - const apiResponses = { - serviceZipValidationResponse: { - isValid: isZipValid, - isServiceable: isZipServiceable - }, - vinLookupResponse: { - vin, - vehicle, - error: vinLookupResponseError - } - }; - - settleAllPromises.mockImplementation(() => apiResponses); + settleAllPromises.mockImplementation(() => Promise.resolve({})); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.setCmsContent = jest.fn(); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 4b8e7e29..cca0a20a 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -262,18 +262,8 @@ export default { this.licenseState ); - // Settle promises and get results - const promiseResultMap = [ - { - resultKey: 'vinLookupResponse', - promise: vinLookupResponse - } - ]; - - const resultMap = await settleAllPromises(promiseResultMap); - // No VIN found - if (resultMap.vinLookupResponse.error) { + if (vinLookupResponse.error) { this.displayVinNotFoundAlert = true; this.previouslyEnteredCarId = null; this.$refs.siteFooter.disableForwardButton(); @@ -281,14 +271,12 @@ export default { } // Vehicle found from VIN lookup - const vehicleFromLookup = resultMap.vinLookupResponse.vehicle; + const vehicleFromLookup = vinLookupResponse.data.vehicle; // Check if the CarId has changed - this.isCarIdDifferent = - vehicleFromLookup.carId !== useMainStore().order.vehicle.carId; + this.isCarIdDifferent = vehicleFromLookup.carId !== useMainStore().order.vehicle.carId; // Handle changing car - if ( - this.isCarIdDifferent + if (this.isCarIdDifferent && vehicleFromLookup.carId !== this.previouslyEnteredCarId ) { // Display Alert @@ -302,8 +290,7 @@ export default { this.displayMatchedDifferentVehicleAlert = true; } - this.isSelectedGlassAvailableForVehicle = - await isGlassAvailableForCarId(vehicleFromLookup.carId); + this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleFromLookup.carId); // Update button "Continue with..." this.$refs.siteFooter @@ -313,20 +300,16 @@ export default { } // Save vehicle, license plate, and registration information - await useMainStore().saveRegistrationLicensePlateLookup( - { - isSelectedGlassAvailableForVehicle: - this.isSelectedGlassAvailableForVehicle, - vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, { - vin: vinLookupResponse.data.vin - }), - registrationInfo: { - licensePlate: this.licensePlate, - state: this.licenseState - } - }, - false - ); + useMainStore().saveRegistrationLicensePlateLookup({ + isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, + vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, { + vin: vinLookupResponse.data.vin + }), + registrationInfo: { + licensePlate: this.licensePlate, + state: this.licenseState + } + }); return this.navigateForward(); }, @@ -334,8 +317,7 @@ export default { // If a different vehicle is found than the one entered and the selected glass is // not available for that vehicle then navigate back to "vehicle-damage" // display vehicle changed alert on that page. - if ( - this.isCarIdDifferent + if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle ) { this.$router.navigate( diff --git a/src/store/index.js b/src/store/index.js index fa8e540f..1570bf3b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1858,6 +1858,13 @@ export const useMainStore = defineStore({ this.order.vehicle.imageUrl = null; this.order.vehicle.imageVifNumber = null; this.order.vehicle.imageColor = null; + this.order.vehicle.registration.licensePlate = null; + this.order.vehicle.registration.state = null; + this.order.vehicle.registration.address = null; + this.order.vehicle.registration.city = null; + this.order.vehicle.registration.zipCode = null; + this.order.vehicle.registration.firstName = null; + this.order.vehicle.registration.lastName = null; }, resetGlassPartsState() { @@ -2466,9 +2473,9 @@ export const useMainStore = defineStore({ } }, saveRegistrationLicensePlateLookup({ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }) { - // Reset dependent state when changing + // Reset dependent state when changing if (registrationInfo?.licensePlate !== this.order.vehicle.registration?.licensePlate - || registrationInfo?.state !== this.order.vehicle.registration?.state) { + || registrationInfo?.state !== this.order.vehicle.registration?.state) { this.resetRegistrationAndDependencies(); if (!isSelectedGlassAvailableForVehicle) {