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,
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();

View file

@ -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(

View file

@ -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) {