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:
commit
034b708e5d
2 changed files with 53 additions and 3 deletions
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue