From a3dff865ea696d3ca8c03154a413b6768f29172c Mon Sep 17 00:00:00 2001 From: CarlNation <32103961+CarlNation@users.noreply.github.com> Date: Fri, 8 Sep 2023 08:25:44 -0400 Subject: [PATCH 1/2] CSR-1625 router/index.js assumes a load-session successful response should always go to heritage. This may have been true in the initial version of NextGen but now we can load and direct it to the correct page. The incorrect routing to heritage was also failing here for returning users that already had a NextGen cookie. The error caused us to route to the beginning. Fixed that error by removing the default true in the navigateToHeritageFunnel and changing all calls to pass a true or false. --- .../heritage-integration/navigation-helper.js | 13 ++---- .../navigation-helper.spec.js | 42 ++++++------------- src/layouts/estimate/estimate.vue | 5 ++- src/layouts/quote/quote.vue | 5 ++- src/layouts/schedule/schedule.vue | 5 ++- src/mixins/vehicle-questions-mixin.js | 10 ++++- src/router/index.js | 12 +----- 7 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 8d22ee901..78080479e 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -17,15 +17,11 @@ import router from "@/router"; drop them so they don't start at the beginning again. This method will return 'heritage' if the user has an existing order and they come back in from the Safelite.com CTA. */ -export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHeritageOrder = false) { +export async function getPageToRouteExistingOrderTo(toRoute = {}) { // If the user is coming in via the Safelite.Com CTA if (toRoute.query[queryStrings.START_TYPE] === "fmg") { - // If they have an existing order, return 'heritage' for the page name. - if (existingHeritageOrder) { - return fmgPageValues.HERITAGE; - } - - return await getLatestPageForRedirection(); + const latestPageRoute = await getLatestPageForRedirection(); + return latestPageRoute; } // If navigating to a specific page, and that page is not part of the vin pages. @@ -42,7 +38,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita // If this is not a direct link to a page using fmgPage, not from Safelite.com CTA or this is a vin related page. // Get the latest page for redirection. const latestPageRoute = await getLatestPageForRedirection(); - return latestPageRoute; } @@ -50,7 +45,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita Used to navigate to the heritage funnel with the correct query string and url. */ -export async function navigateToHeritageFunnel({ shouldSaveSession = true, loadingModal }) { +export async function navigateToHeritageFunnel({ shouldSaveSession, loadingModal }) { // Create the order (or save existing order) when navigating to Heritage Funnel. if (shouldSaveSession) { await saveSession({ shouldAwaitSaveSessionQueue: true }); diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index d08ce92ec..c3bafc2da 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -35,7 +35,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_YEAR); @@ -57,7 +57,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_MAKE); @@ -80,7 +80,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_MODEL); @@ -104,7 +104,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_STYLE); @@ -129,7 +129,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); @@ -169,7 +169,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.ESTIMATE); @@ -199,7 +199,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.ESTIMATE); @@ -229,7 +229,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS); @@ -259,7 +259,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS); @@ -289,7 +289,7 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.VEHICLE_PARTS); @@ -319,29 +319,11 @@ describe("getPageToRouteExistingOrderTo", () => { }); // Act - const result = await getPageToRouteExistingOrderTo(toRoute, false); + const result = await getPageToRouteExistingOrderTo(toRoute); //Assert expect(result).toBe(fmgPageValues.PART_QUESTIONS); }); - - test("existing order > should return heritage", async () => { - // Arrange - const toRoute = { - query: { - [queryStrings.START_TYPE]: "fmg", - }, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute, true); - - // Assert - expect(result).toBe(fmgPageValues.HERITAGE); - }); }); describe("navigateToHeritageFunnel", () => { @@ -377,7 +359,7 @@ describe("navigateToHeritageFunnel", () => { router.navigateToExternalUrl = jest.fn(); // Act - await navigateToHeritageFunnel({}); + await navigateToHeritageFunnel({loadingModal:null, shouldSaveSession:true}); // Assert expect(saveSessionFunction).toHaveBeenCalled(); diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index d18af242c..5ae10cb9c 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -255,7 +255,10 @@ export default { const vehicleChangedDuringPolicyLookupInHeritage = payment.isInsurance && payment.insuranceCoverage.coverageStatus; if (vehicleChangedDuringPolicyLookupInHeritage) { - navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); + navigateToHeritageFunnel({ + shouldSaveSession: true, + loadingModal: this.$refs.loadingModal, + }); } else if (this.$store.getters.order.referralNumber?.length === 6) { await this.navigateForwardWithSingleCarMatch(); } else if (this.isRepair) { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 99d824af5..30d15ba4c 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -216,7 +216,10 @@ export default { const payment = this.$store.getters.payment; if (payment.isInsurance) { - navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); + navigateToHeritageFunnel({ + shouldSaveSession: true, + loadingModal: this.$refs.loadingModal, + }); } else { this.$router.navigateWithSaving( this.navigationScenarios.CLICKED_FORWARD_WITH_CASH, diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 1ff1c18e7..3fda3d7e0 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -418,7 +418,10 @@ export default { this.appointmentDateAndTime, false ); - navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); + navigateToHeritageFunnel({ + shouldSaveSession: true, + loadingModal: this.$refs.loadingModal, + }); }, updateSupportingItems() { diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 4b05067ea..fb54c059f 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -447,9 +447,15 @@ export default { const payment = store.getters.payment; if (store.getters.order.referralNumber?.length === 6) { - navigateToHeritageFunnel({ loadingModal: self.$refs.loadingModal }); + navigateToHeritageFunnel({ + shouldSaveSession: true, + loadingModal: self.$refs.loadingModal, + }); } else if (payment.isInsurance && payment.insuranceCoverage.isVerified) { - navigateToHeritageFunnel({ loadingModal: self.$refs.loadingModal }); + navigateToHeritageFunnel({ + shouldSaveSession: true, + loadingModal: self.$refs.loadingModal, + }); } else { self.$router.navigateWithSaving( self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, diff --git a/src/router/index.js b/src/router/index.js index 58a3059b5..76892f76c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -68,17 +68,7 @@ const routes = [ : null ); - const pageToRedirectTo = await getPageToRouteExistingOrderTo( - to, - loadSessionResponse - ); - - // If getPageToRouteExistingOrderTo determines that the return user needs to - // go back to heritage funnel, send them there and stop our current navigation. - if (pageToRedirectTo === "heritage") { - await navigateToHeritageFunnel(); - return next(false); - } + const pageToRedirectTo = await getPageToRouteExistingOrderTo(to); // Assign our fmgPage so it will load normally like the other pages. to.query.fmgPage = pageToRedirectTo; From 9e3e2a820bf6cad64f3b6225a7f1d067030a61cd Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 8 Sep 2023 08:29:47 -0400 Subject: [PATCH 2/2] CSR-1625 prettier --- src/helpers/heritage-integration/navigation-helper.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index c3bafc2da..145258c75 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -359,7 +359,7 @@ describe("navigateToHeritageFunnel", () => { router.navigateToExternalUrl = jest.fn(); // Act - await navigateToHeritageFunnel({loadingModal:null, shouldSaveSession:true}); + await navigateToHeritageFunnel({ loadingModal: null, shouldSaveSession: true }); // Assert expect(saveSessionFunction).toHaveBeenCalled();