Merge pull request #802 from Safelite/defect/digital/SSR-1431

SSR-1431 Bailout for heavy truck on vin-lookup page
This commit is contained in:
Josh Dassinger 2024-07-25 10:24:08 -05:00 committed by GitHub
commit 034b708e5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 53 additions and 3 deletions

View file

@ -24,7 +24,17 @@ const lookupVehicleByVin = {
methodName: 'lookupVehicleByVin',
mockResponse: {
data: {
carId: mockCarId
carId: mockCarId,
canSafeliteService: true
}
}
};
const lookupVehicleByVinCannotService = {
methodName: 'lookupVehicleByVin',
mockResponse: {
data: {
carId: mockCarId,
canSafeliteService: false
}
}
};
@ -484,6 +494,41 @@ describe('vin-lookup.vue', () => {
);
});
});
test('Bailout if entered vin cannot be serviced', async () => {
const user = userEvent.setup();
mountOptions.global.stubs.vinQuestion = false;
mountOptions.data = () => ({
vinWithNonMatchingCarId: false,
isCarIdDifferentFromTheStore: false,
vin: mockValidVin
});
getPartsOrQuestions.mockResponse = vehicleWithNoAdditionalPartsOrQuestionsMockResponse;
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
.mockResolvedValue(lookupVehicleByVinCannotService.mockResponse);
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
.mockResolvedValue(getPartsOrQuestions.mockResponse);
const { container } = render(VinLookupComponent, mountOptions);
const vinInput = container.querySelector(vinInputSelector);
await user.type(vinInput, mockValidVin);
const continueButton = container.querySelector(continueButtonQuerySelector);
await user.click(continueButton);
await flushPromises();
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
mockRoute
);
});
});
// eslint-disable-next-line max-len
test('Policy Vehicle with invalid vin corrected. Click "Continue", execute navigate with navigationScenario.CORRECTED_VIN_FROM_POLICY_VEHICLE', async () => {

View file

@ -185,8 +185,7 @@ export default {
const vehicleLookupResponse = await this.lookupVehicleByVin(this.vin);
if (vehicleLookupResponse.error) {
this.activeVehicleLookupAlertType =
vehicleLookupAlertTypes.NOT_FOUND;
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
this.mainStore.setBailout(bailoutMessage.vehicleNotFound(this.vin));
this.resetVehicleFromLookup();
this.$refs.siteFooter.removeLoader();
@ -197,6 +196,12 @@ export default {
return;
}
if (!vehicleLookupResponse.data.canSafeliteService) {
this.mainStore.setBailout(bailoutMessage.HeavyTruckVehicle(vehicleLookupResponse.data.carId));
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, this.$route);
return;
}
this.mainStore.resetBailout();
// Add vin bcs the response from the service doesn't contain vin