Merge pull request #766 from Safelite/defect/digital/SSR-1373

SSR-1373 Fix License-place-lookup bugs
This commit is contained in:
Josh Dassinger 2024-06-24 14:52:02 -05:00 committed by GitHub
commit 8be7d75be4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 52 deletions

View file

@ -28,8 +28,6 @@ function setupMocks({
isZipServiceable = true, isZipServiceable = true,
lookupVinByPlateResponse, lookupVinByPlateResponse,
partsOrQuestions = [], partsOrQuestions = [],
vehicle = {},
vin = null,
carId = 'C0000', carId = 'C0000',
vinLookupResponseError = null, vinLookupResponseError = null,
route = null route = null
@ -47,7 +45,8 @@ function setupMocks({
vehicle: { vehicle: {
carId: 'CARID' carId: 'CARID'
} }
} },
error: vinLookupResponseError
})); }));
useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => Promise.resolve({ useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => Promise.resolve({
@ -78,19 +77,7 @@ function setupMocks({
}) })
); );
const apiResponses = { settleAllPromises.mockImplementation(() => Promise.resolve({}));
serviceZipValidationResponse: {
isValid: isZipValid,
isServiceable: isZipServiceable
},
vinLookupResponse: {
vin,
vehicle,
error: vinLookupResponseError
}
};
settleAllPromises.mockImplementation(() => apiResponses);
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => '');
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();

View file

@ -262,18 +262,8 @@ export default {
this.licenseState this.licenseState
); );
// Settle promises and get results
const promiseResultMap = [
{
resultKey: 'vinLookupResponse',
promise: vinLookupResponse
}
];
const resultMap = await settleAllPromises(promiseResultMap);
// No VIN found // No VIN found
if (resultMap.vinLookupResponse.error) { if (vinLookupResponse.error) {
this.displayVinNotFoundAlert = true; this.displayVinNotFoundAlert = true;
this.previouslyEnteredCarId = null; this.previouslyEnteredCarId = null;
this.$refs.siteFooter.disableForwardButton(); this.$refs.siteFooter.disableForwardButton();
@ -281,14 +271,12 @@ export default {
} }
// Vehicle found from VIN lookup // Vehicle found from VIN lookup
const vehicleFromLookup = resultMap.vinLookupResponse.vehicle; const vehicleFromLookup = vinLookupResponse.data.vehicle;
// Check if the CarId has changed // Check if the CarId has changed
this.isCarIdDifferent = this.isCarIdDifferent = vehicleFromLookup.carId !== useMainStore().order.vehicle.carId;
vehicleFromLookup.carId !== useMainStore().order.vehicle.carId;
// Handle changing car // Handle changing car
if ( if (this.isCarIdDifferent
this.isCarIdDifferent
&& vehicleFromLookup.carId !== this.previouslyEnteredCarId && vehicleFromLookup.carId !== this.previouslyEnteredCarId
) { ) {
// Display Alert // Display Alert
@ -302,8 +290,7 @@ export default {
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
} }
this.isSelectedGlassAvailableForVehicle = this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleFromLookup.carId);
await isGlassAvailableForCarId(vehicleFromLookup.carId);
// Update button "Continue with..." // Update button "Continue with..."
this.$refs.siteFooter this.$refs.siteFooter
@ -313,10 +300,8 @@ export default {
} }
// Save vehicle, license plate, and registration information // Save vehicle, license plate, and registration information
await useMainStore().saveRegistrationLicensePlateLookup( useMainStore().saveRegistrationLicensePlateLookup({
{ isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
isSelectedGlassAvailableForVehicle:
this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, { vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, {
vin: vinLookupResponse.data.vin vin: vinLookupResponse.data.vin
}), }),
@ -324,9 +309,7 @@ export default {
licensePlate: this.licensePlate, licensePlate: this.licensePlate,
state: this.licenseState state: this.licenseState
} }
}, });
false
);
return this.navigateForward(); return this.navigateForward();
}, },
@ -334,8 +317,7 @@ export default {
// If a different vehicle is found than the one entered and the selected glass is // 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" // not available for that vehicle then navigate back to "vehicle-damage"
// display vehicle changed alert on that page. // display vehicle changed alert on that page.
if ( if (this.isCarIdDifferent
this.isCarIdDifferent
&& !this.isSelectedGlassAvailableForVehicle && !this.isSelectedGlassAvailableForVehicle
) { ) {
this.$router.navigate( this.$router.navigate(

View file

@ -1858,6 +1858,13 @@ export const useMainStore = defineStore({
this.order.vehicle.imageUrl = null; this.order.vehicle.imageUrl = null;
this.order.vehicle.imageVifNumber = null; this.order.vehicle.imageVifNumber = null;
this.order.vehicle.imageColor = 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() { resetGlassPartsState() {