From 39451132873ff23b7affda248ae5ceb47fd3caf5 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Mar 2024 11:19:31 -0500 Subject: [PATCH 01/18] Navigation Logic Refactor --- .../heritage-integration/navigation-helper.js | 180 ++++++------------ 1 file changed, 63 insertions(+), 117 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index da21df752..a6fdd22b2 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -12,38 +12,74 @@ import { includesWindshieldReplacement } from "@/helpers/damage-helper"; import store from "@/store"; import router from "@/router"; -/* - If the user has visited the funnel before this method will determine the bets place to - 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 = {}) { - const fmgPage = getQuerystringParameter(queryStrings.FMG_PAGE.toLowerCase()); - if (fmgPage && fmgPage === fmgPageValues.SERVICE_LOCATION) { - const serviceLocationComponent = await getLazyLoadedComponent( - fmgPageValues.SERVICE_LOCATION - ); - if (serviceLocationComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.SERVICE_LOCATION; - } + const fmgQueryPage = toRoute.query[queryStrings.FMG_PAGE]; + const hasFmgQueryPage = !!fmgQueryPage; + + if (hasFmgQueryPage) { + return await getDirectNavigation(toRoute); + } else { + return await getImplicitNavigation(toRoute); + } +} + +/* + * Send the user to the specified page, except in specific scenarios. + */ +async function getDirectNavigation(toRoute) { + const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE]; + + // Override if Verified Insurance & Trying to go to vehicle + // so vehicle info cannot be overriden. + if ( + store.getters.payment.insuranceCoverage.isVerified && + fmgPageValue === fmgPageValues.VEHICLE + ) { + return fmgPageValues.VEHICLE_DAMAGE; } - // If the user is coming in via the Safelite.Com CTA - if (toRoute.query[queryStrings.START_TYPE] === "fmg") { - const latestPageRoute = await getLatestPageForRedirection(); - return latestPageRoute; - } + // Otherwise, respect navigation from query string. + return fmgPageValue; +} - // If navigating to a specific page, and that page is not part of the vin pages. - // Return that page, so that it can navigate like normal. - if (toRoute.query[queryStrings.FMG_PAGE] !== undefined && !isVinRelatedPage(toRoute)) { - return overrideYmmsDirectionIfNeeded(toRoute); - } +/* + * Determine which page in the flow the user should be sent to, based on their current order. + * General strategy: run through pages in reverse order, and select first where prerequisites are valid. + * QUOTE is the latest page to send to. + */ +async function getImplicitNavigation(toRoute) { + const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE); + const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); + const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); + const partQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.PART_QUESTIONS); + const vehiclePartsComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_PARTS); + const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS); + const capabilityQuestionsComponent = await getLazyLoadedComponent( + fmgPageValues.CAPABILITY_QUESTIONS + ); + const quoteComponent = await getLazyLoadedComponent(fmgPageValues.QUOTE); - // 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; + const skipVin = await skipVinLookup(); + + if (quoteComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.QUOTE; + } else if (capabilityQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.CAPABILITY_QUESTIONS; + } else if (moldingQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.MOLDING_QUESTIONS; + } else if (vehiclePartsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.VEHICLE_PARTS; + } else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.PART_QUESTIONS; + } else if (vinLookupComponent.methods.arePagePrerequisitesValid() && !skipVin) { + return fmgPageValues.VIN_LOOKUP; + } else if (estimateComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.ESTIMATE; + } else if (vehicleDamageComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.VEHICLE_DAMAGE; + } else { + return fmgPageValues.VEHICLE; + } } /* @@ -114,96 +150,6 @@ export async function skipVinLookupNotRepair() { ); } -/* - Logic for getting the last "valid" page a user visited. -*/ -async function getLatestPageForRedirection() { - // If this is a non-CTA navigation, determine where to send the user based on page prerequisites. - // This also works if a user has a 'fmg' start_type query string but no current order. - // That shouldn't happen, but it's possible. - const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE); - const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); - const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); - const partQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.PART_QUESTIONS); - const vehiclePartsComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_PARTS); - const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS); - const capabilityQuestionsComponent = await getLazyLoadedComponent( - fmgPageValues.CAPABILITY_QUESTIONS - ); - const quoteComponent = await getLazyLoadedComponent(fmgPageValues.QUOTE); - const serviceLocationComponent = await getLazyLoadedComponent(fmgPageValues.SERVICE_LOCATION); - const scheduleComponent = await getLazyLoadedComponent(fmgPageValues.SCHEDULE); - - const skipVin = await skipVinLookup(); - - if (!vehicleDamageComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE; - } else if (!estimateComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_DAMAGE; - } else { - if (quoteComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.QUOTE; - } else if (capabilityQuestionsComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.CAPABILITY_QUESTIONS; - } else if (moldingQuestionsComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.MOLDING_QUESTIONS; - } else if (vehiclePartsComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.VEHICLE_PARTS; - } else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.PART_QUESTIONS; - } else if ( - // capture vin - vinLookupComponent.methods.arePagePrerequisitesValid() && - !skipVin - ) { - return fmgPageValues.VIN_LOOKUP; - } else { - // do not capture vin - return fmgPageValues.ESTIMATE; - } - } -} - -/* - Overrides functionality to go to the YMMS pages in certain cases. - If this is not one of the cases, it returns the 'to' fmgPage value. -*/ - -/* istanbul ignore next */ -function overrideYmmsDirectionIfNeeded(toRoute) { - const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE]; - - if (store.getters.payment.insuranceCoverage.isVerified) { - switch (fmgPageValue) { - case fmgPageValues.VEHICLE: { - return fmgPageValues.VEHICLE_DAMAGE; - } - default: { - return fmgPageValue; - } - } - } else { - return fmgPageValue; - } -} - -/* - Determine if the page is a vin related page. -*/ - -/* istanbul ignore next */ -function isVinRelatedPage(toRoute) { - const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE]; - - return ( - fmgPageValue === fmgPageValues.VIN_LOOKUP || - fmgPageValue === fmgPageValues.LICENSE_PLATE_LOOKUP || - fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || - fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || - fmgPageValue === fmgPageValues.ESTIMATE - ); -} - async function getLazyLoadedComponent(pageName) { return (await lazyLoadComponent(pageName)()).default; } From 809d1838df77548adfe137913e8c84d1cabd48dd Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 7 Mar 2024 12:14:52 -0500 Subject: [PATCH 02/18] Update unit tests --- src/constants/store-mutations.js | 1 + .../heritage-integration/navigation-helper.js | 4 +- .../navigation-helper.spec.js | 540 +++++++++++------- 3 files changed, 340 insertions(+), 205 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 0b0338fef..2d4e0b4e7 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -49,6 +49,7 @@ const storeMutations = { UPDATE_BILL_TO_ACCT_NUMBER: "updateBillToAcctNumber", UPDATE_EON: "updateEON", UPDATE_IS_INSURANCE: "updateIsInsurance", + UPDATE_IS_VERIFIED_INSURANCE: "updateInsuranceVerifiedStatus", UPDATE_SAVED_SESSION_ID: "updateSavedSessionId", UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId", UPDATE_IS_PIA: "updateIsPia", diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index a6fdd22b2..79ba0fce7 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -26,7 +26,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}) { /* * Send the user to the specified page, except in specific scenarios. */ -async function getDirectNavigation(toRoute) { +export async function getDirectNavigation(toRoute) { const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE]; // Override if Verified Insurance & Trying to go to vehicle @@ -47,7 +47,7 @@ async function getDirectNavigation(toRoute) { * General strategy: run through pages in reverse order, and select first where prerequisites are valid. * QUOTE is the latest page to send to. */ -async function getImplicitNavigation(toRoute) { +export async function getImplicitNavigation(toRoute) { const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE); const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index e0bd51b95..89df1bd17 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -1,7 +1,4 @@ -import { - getPageToRouteExistingOrderTo, - navigateToHeritageFunnel, -} from "@/helpers/heritage-integration/navigation-helper"; +import * as navigationHelper from "@/helpers/heritage-integration/navigation-helper"; import * as orderHelper from "@/helpers/heritage-integration/order-helper"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; import { storeActions } from "@/constants/store-actions"; @@ -14,233 +11,370 @@ import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import store from "@/store"; import router from "@/router"; +const getPageToRouteExistingOrderTo = navigationHelper.getPageToRouteExistingOrderTo; +const navigateToHeritageFunnel = navigationHelper.navigateToHeritageFunnel; + // Mock Lazy Load jest.mock("@/router/dynamic-routing/component-loader.js", () => ({ lazyLoadComponent: jest.fn(), })); describe("getPageToRouteExistingOrderTo", () => { - test("should return vehicle", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE); - }); - - test("should return vehicle-damage", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); - }); - - test("user has YMMS and no vehicle questions > should return estimate", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - const mockExperimentsList = [ - { - universeName: "ConceptFunnel", - settings: { - SuppressVinCapture: false, + describe("Explicit vs. Implicit Routing", () => { + test("Should call explicit routing if `fmgPage` parameter is present in query", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: "schedule", }, - }, - ]; - store.commit(storeMutations.UPDATE_EXPERIMENTS, mockExperimentsList); + }; - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: false, - [fmgPageValues.MOLDING_QUESTIONS]: false, - [fmgPageValues.VEHICLE_PARTS]: false, - [fmgPageValues.PART_QUESTIONS]: false, - [fmgPageValues.VIN_LOOKUP]: true, + mockLazyLoadComponentReturnValues(); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + // If direct, should be "schedule". + // Otherwise, not. + expect(result).toBe("schedule"); }); - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); + test("Should call implicit routing if `fmgPage` parameter is NOT present in query", async () => { + // Arrange + const toRoute = { + query: {}, + }; - //Assert - expect(result).toBe(fmgPageValues.ESTIMATE); + mockLazyLoadComponentReturnValues(); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + // If direct, should be "schedule". + // Otherwise, not. + expect(result).not.toBe("schedule"); + }); }); - test("user has YMMS but no questions or carId > should return estimate", async () => { - // Arrange - const toRoute = { - query: {}, - }; + describe("Implicit Routing", () => { + test("should return vehicle", async () => { + // Arrange + const toRoute = { + query: {}, + }; - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: false, - [fmgPageValues.MOLDING_QUESTIONS]: false, - [fmgPageValues.VEHICLE_PARTS]: false, - [fmgPageValues.PART_QUESTIONS]: false, - [fmgPageValues.VIN_LOOKUP]: false, + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE); }); - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); + test("should return vehicle-damage", async () => { + // Arrange + const toRoute = { + query: {}, + }; - //Assert - expect(result).toBe(fmgPageValues.ESTIMATE); + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); + }); + + test("user has YMMS and no vehicle questions > should return estimate", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + const mockExperimentsList = [ + { + universeName: "ConceptFunnel", + settings: { + SuppressVinCapture: false, + }, + }, + ]; + store.commit(storeMutations.UPDATE_EXPERIMENTS, mockExperimentsList); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: true, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.ESTIMATE); + }); + + test("user has YMMS but no questions or carId > should return estimate", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.ESTIMATE); + }); + + test("user has capability questions and molding questions > should return capability questions", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: true, + [fmgPageValues.MOLDING_QUESTIONS]: true, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS); + }); + + test("user has molding questions and part questions > should return molding questions", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: true, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS); + }); + + test("user has vehicle parts questions > should return vehicle-parts", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: true, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE_PARTS); + }); + + test("user has part questions > should return part-questions", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.PART_QUESTIONS); + }); + + test("should return quote, if not verified insurance", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + [fmgPageValues.QUOTE]: true, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.QUOTE); + }); + + test("should not return pages beyond quote even if prerequisites are met", async () => { + // Arrange + const toRoute = { + query: {}, + }; + + store.commit(storeMutations.UPDATE_IS_REPAIR, false); + store.commit(storeMutations.UPDATE_MAKE, "acura"); + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + [fmgPageValues.QUOTE]: true, + [fmgPageValues.SERVICE_LOCATION]: true, + [fmgPageValues.SCHEDULE]: true, + }); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + //Assert + expect(result).toBe(fmgPageValues.QUOTE); + }); }); - test("user has capability questions and molding questions > should return capability questions", async () => { - // Arrange - const toRoute = { - query: {}, - }; + describe("Explicit Routing", () => { + test("Returns the value passed in in nominal case", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: "testValue", + }, + }; - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: true, - [fmgPageValues.MOLDING_QUESTIONS]: true, - [fmgPageValues.VEHICLE_PARTS]: false, - [fmgPageValues.PART_QUESTIONS]: false, - [fmgPageValues.VIN_LOOKUP]: false, + // Assert + expect(result).toBe("testValue"); }); - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); + test("For verified insurance users, replace navigation to `vehicle` with `vehicle-damage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.VEHICLE, + }, + }; - //Assert - expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS); - }); + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); - test("user has molding questions and part questions > should return molding questions", async () => { - // Arrange - const toRoute = { - query: {}, - }; + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: false, - [fmgPageValues.MOLDING_QUESTIONS]: true, - [fmgPageValues.VEHICLE_PARTS]: false, - [fmgPageValues.PART_QUESTIONS]: true, - [fmgPageValues.VIN_LOOKUP]: false, + // Assert + expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - //Assert - expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS); - }); - - test("user has vehicle parts questions > should return vehicle-parts", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: false, - [fmgPageValues.MOLDING_QUESTIONS]: false, - [fmgPageValues.VEHICLE_PARTS]: true, - [fmgPageValues.PART_QUESTIONS]: true, - [fmgPageValues.VIN_LOOKUP]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - //Assert - expect(result).toBe(fmgPageValues.VEHICLE_PARTS); - }); - - test("user has part questions > should return part-questions", async () => { - // Arrange - const toRoute = { - query: {}, - }; - - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Mock out the lazy load calls for all components. - mockLazyLoadComponentReturnValues({ - [fmgPageValues.VEHICLE]: true, - [fmgPageValues.VEHICLE_DAMAGE]: true, - [fmgPageValues.ESTIMATE]: true, - [fmgPageValues.CAPABILITY_QUESTIONS]: false, - [fmgPageValues.MOLDING_QUESTIONS]: false, - [fmgPageValues.VEHICLE_PARTS]: false, - [fmgPageValues.PART_QUESTIONS]: true, - [fmgPageValues.VIN_LOOKUP]: false, - }); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - //Assert - expect(result).toBe(fmgPageValues.PART_QUESTIONS); }); }); From 020908f8e9d8c85efa40b8e1d41f68c01ea890dc Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 7 Mar 2024 15:27:07 -0500 Subject: [PATCH 03/18] Route quote to heritage when verified insurance --- .../heritage-integration/navigation-helper.js | 25 +++++++++++++------ src/router/index.js | 6 +++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 79ba0fce7..7b0dec762 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -29,13 +29,17 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}) { export async function getDirectNavigation(toRoute) { const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE]; - // Override if Verified Insurance & Trying to go to vehicle - // so vehicle info cannot be overriden. - if ( - store.getters.payment.insuranceCoverage.isVerified && - fmgPageValue === fmgPageValues.VEHICLE - ) { - return fmgPageValues.VEHICLE_DAMAGE; + // Verified insurance users need to be routed around some pages + // vehicle -> vehicle-damage + // quote -> heritage + if (store.getters.payment.insuranceCoverage.isVerified) { + if (fmgPageValue === fmgPageValues.VEHICLE) { + return fmgPageValues.VEHICLE_DAMAGE; + } + + if (fmgPageValue === fmgPageValues.QUOTE) { + return fmgPageValues.HERITAGE; + } } // Otherwise, respect navigation from query string. @@ -62,7 +66,12 @@ export async function getImplicitNavigation(toRoute) { const skipVin = await skipVinLookup(); if (quoteComponent.methods.arePagePrerequisitesValid()) { - return fmgPageValues.QUOTE; + // Do not send to quote if verified insurance user. + if (store.getters.payment.insuranceCoverage.isVerified) { + return fmgPageValues.HERITAGE; + } else { + return fmgPageValues.QUOTE; + } } else if (capabilityQuestionsComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.CAPABILITY_QUESTIONS; } else if (moldingQuestionsComponent.methods.arePagePrerequisitesValid()) { diff --git a/src/router/index.js b/src/router/index.js index 63904343b..c5484be14 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -86,6 +86,12 @@ const routes = [ const pageToRedirectTo = await getPageToRouteExistingOrderTo(to); + // This logic may determine that the user should be sent to heritage -- if so, do that here. + if (pageToRedirectTo === fmgPageValues.HERITAGE) { + await navigateToHeritageFunnel({ shouldSaveSession: false }); + return next(false); + } + // Assign our fmgPage so it will load normally like the other pages. to.query.fmgPage = pageToRedirectTo; } From 5af18a36cfb4091d1f1dfde9bb73f6d8d0e7edcf Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 12 Mar 2024 12:20:00 -0400 Subject: [PATCH 04/18] Also route insurance-company to heritage for verified users + tests --- .../heritage-integration/navigation-helper.js | 6 +- .../navigation-helper.spec.js | 113 ++++++++++++++++-- 2 files changed, 106 insertions(+), 13 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 7b0dec762..6da22c37c 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -32,12 +32,16 @@ export async function getDirectNavigation(toRoute) { // Verified insurance users need to be routed around some pages // vehicle -> vehicle-damage // quote -> heritage + // insurance-company -> heritage if (store.getters.payment.insuranceCoverage.isVerified) { if (fmgPageValue === fmgPageValues.VEHICLE) { return fmgPageValues.VEHICLE_DAMAGE; } - if (fmgPageValue === fmgPageValues.QUOTE) { + if ( + fmgPageValue === fmgPageValues.QUOTE || + fmgPageValue === fmgPageValues.INSURANCE_COMPANY + ) { return fmgPageValues.HERITAGE; } } diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 89df1bd17..dd5aeed99 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -359,21 +359,110 @@ describe("getPageToRouteExistingOrderTo", () => { expect(result).toBe("testValue"); }); - test("For verified insurance users, replace navigation to `vehicle` with `vehicle-damage`", async () => { - // Arrange - const toRoute = { - query: { - fmgPage: fmgPageValues.VEHICLE, - }, - }; + describe("Verified users", () => { + test("Replace navigation to `vehicle` with `vehicle-damage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.VEHICLE, + }, + }; - store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); - // Assert - expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); + // Assert + expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); + }); + + test("Replace navigation to `quote` with `heritage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.QUOTE, + }, + }; + + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + expect(result).toBe(fmgPageValues.HERITAGE); + }); + + test("Replace navigation to `insurance-company` with `heritage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.INSURANCE_COMPANY, + }, + }; + + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + expect(result).toBe(fmgPageValues.HERITAGE); + }); + }); + + describe("Non-verified users", () => { + test("Don't replace navigation to `vehicle` with `vehicle-damage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.VEHICLE, + }, + }; + + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, false); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + expect(result).toBe(fmgPageValues.VEHICLE); + }); + + test("Don't replace navigation to `quote` with `heritage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.QUOTE, + }, + }; + + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, false); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + expect(result).toBe(fmgPageValues.QUOTE); + }); + + test("Don't replace navigation to `insurance-company` with `heritage`", async () => { + // Arrange + const toRoute = { + query: { + fmgPage: fmgPageValues.INSURANCE_COMPANY, + }, + }; + + store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, false); + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute); + + // Assert + expect(result).toBe(fmgPageValues.INSURANCE_COMPANY); + }); }); }); }); From 428d4e80fc3eb451a46ee875623a8ffa3c246ee2 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 12 Mar 2024 15:23:34 -0400 Subject: [PATCH 05/18] Bypass error handling --- src/global-methods.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global-methods.js b/src/global-methods.js index b756d7b34..c471a8c63 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -100,7 +100,7 @@ export default { // Do not route to error logic when no wipers found or no promo found (404s) if (error.response.status != "404") { - router.navigateError(); + //router.navigateError(); Emergency change for testing - skiener 03/12 } global.$logger.logError( From cc0d97ca7522ad4de53dfa2c06ac8b125946eda0 Mon Sep 17 00:00:00 2001 From: CarlNation <32103961+CarlNation@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:00:52 -0400 Subject: [PATCH 06/18] CSR-2005 CSR-2005 changes to select parent account and navigate to Heritage --- .../heritage-integration/navigation-helper.js | 5 +++++ src/helpers/heritage-integration/order-helper.js | 1 + src/layouts/insurance-company/insurance-company.vue | 12 ++++++++---- src/store/index.js | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index da21df752..03c5c368e 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -80,6 +80,11 @@ export async function navigateToHeritageFunnel({ shouldSaveSession, pageNameToLo heritageParms["forceEndToEndInsurance"] = true; } + // if they are going to heritage and already have a policy number then this is a nav back flow + if (store.getters.policy.policyNumber) { + heritageParms["insuranceNavBack"] = true; + } + router.navigateToExternalUrl(externalUrls.HERITAGE_FUNNEL, heritageParms); } diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 38f4161b9..07c469ae8 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -166,6 +166,7 @@ async function saveSessionHelper( customerPortalLoginToken: savedSessionInfo.data.customerPortalLoginToken, lockToken: savedSessionInfo.data.lockToken, settledTenderAmount: savedSessionInfo.data.settledTenderAmount, + billToAccountNumber: savedSessionInfo.data.billToAccountNumber, }, false ); diff --git a/src/layouts/insurance-company/insurance-company.vue b/src/layouts/insurance-company/insurance-company.vue index e880b1534..4fa86743f 100644 --- a/src/layouts/insurance-company/insurance-company.vue +++ b/src/layouts/insurance-company/insurance-company.vue @@ -119,6 +119,7 @@ export default { return { searchableInsuranceCompanyList: [], originalList: [], + selectedParentAccount: "", }; }, methods: { @@ -142,8 +143,11 @@ export default { // Go back to Quote page this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, - forwardButtonAction() { - this.dispatchStoreAction( + async forwardButtonAction() { + // await any pending save-sessions. if you don't, we will save the new parent account into vuex and then a pending async save-session response overwrites it + await store.getters.applicationUser.saveSessionPromise; + + await this.dispatchStoreAction( this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER, this.selectedParentAccount, false @@ -156,12 +160,12 @@ export default { }); }, selectParentAccountNumber(parentAccountName) { - if (!this.insuranceCompanyList) { + if (!this.searchableInsuranceCompanyList) { console.error("No insurance companies found"); return; } - var selectedItem = this.insuranceCompanyList.filter((item) => { + var selectedItem = this.searchableInsuranceCompanyList.filter((item) => { return item.accountName === parentAccountName; }); diff --git a/src/store/index.js b/src/store/index.js index 4fe96703e..e602cf209 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1069,6 +1069,7 @@ export const actions = { customerPortalLoginToken, lockToken, settledTenderAmount, + billToAccountNumber, } ) { context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber); @@ -1084,6 +1085,7 @@ export const actions = { context.commit(storeMutations.LOCK_TOKEN, lockToken); context.commit(storeMutations.Customer_Portal_Login_Token, customerPortalLoginToken); context.commit(storeMutations.UPDATE_SETTLED_TENDER_AMOUNT, settledTenderAmount); + context.commit(storeMutations.UPDATE_BILL_TO_ACCT_NUMBER, billToAccountNumber); }, logPageView( From bd10a8b8a6c3a4de453de0d5235999e09ad97695 Mon Sep 17 00:00:00 2001 From: Sneha Date: Fri, 15 Mar 2024 11:03:20 +0530 Subject: [PATCH 07/18] CSR-2008 --- .../afterpay-modal-banner.vue | 21 +++++++++++++++++-- src/layouts/quote/quote.vue | 4 +++- src/store/index.js | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue index 6eb8a5a87..09d9ddc15 100644 --- a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue +++ b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue @@ -29,6 +29,8 @@