From 89510338eca0ed97ef504671b8049c039a27b45e Mon Sep 17 00:00:00 2001 From: Manjiri Jethe Date: Fri, 12 May 2023 17:58:34 +0530 Subject: [PATCH 1/2] VIN passed or input doesn't match a CarID in our system SSRR-462 --- src/layouts/vin-lookup/vin-lookup.spec.js | 36 ++++++++++++++++++++ src/layouts/vin-lookup/vin-lookup.vue | 11 ++++-- src/router/router-constants/routing-table.js | 4 +++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index 894ac297..35ae1377 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -26,6 +26,14 @@ const lookupVehicleByVin = { }, }, }; +const lookupVehicleByVinError = { + methodName: 'lookupVehicleByVin', + mockResponse: { + data: { + error: true, + }, + }, +}; const getPartsOrQuestions = { methodName: 'getPartsOrQuestions', mockResponse: null, @@ -457,6 +465,34 @@ describe('vin-lookup.vue', () => { ); }); }); + + test("Selected vehicle VIN do not match vehicles (CarIDs) in our system then navigate forward to bailout page.", async () => { + //Arrange + const user = userEvent.setup(); + lookupVehicleByVin.mockResponse.data.error = true; + + jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName) + .mockResolvedValue(lookupVehicleByVinError.mockResponse); + + mountOptions.data = () => ({ + needToLookupVehicle: true, + bailout: true, + vin: mockValidVin, + }); + + const { container } = render(VinLookupComponent, mountOptions); + 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 + ); + }); + }); }); }); }); diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 58356d9c..0bb282fc 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -71,6 +71,7 @@ export default { vin: this.getVinFromStore(), forwardButtonCarStyle:"", vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, + bailout: false, }; }, provide() { @@ -147,10 +148,16 @@ export default { // Temp solution to turn on 'disabled' style on the Continue button // because the form itself actually passes its client-side validation. // SSR-189 Scenario #4. - this.$refs.siteFooter.disableForwardButton(); - return; + this.$refs.siteFooter.enableForwardAction(); + this.bailout=true } + if(this.bailout){ + + return this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + this.$route); + } // Add vin bcs the response from the service doesn't contain vin this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.vin }); } diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index f57b253b..997886bb 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -141,6 +141,10 @@ const routingTable = function(store) { { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + destinationIssPageValue: issPageValues.BAILOUT_PAGE } ] }, From 228f565d2f16020d420cc5037707fb90b7967573 Mon Sep 17 00:00:00 2001 From: Manjiri Jethe Date: Fri, 12 May 2023 18:02:27 +0530 Subject: [PATCH 2/2] Update vin-lookup.vue --- src/layouts/vin-lookup/vin-lookup.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 0bb282fc..72c16127 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -152,8 +152,7 @@ export default { this.bailout=true } - if(this.bailout){ - + if(this.bailout){ return this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, this.$route);