diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 5d681f17f..3a8614661 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -7,6 +7,7 @@ import { applicationConfig } from "@/constants/application-config"; */ export function updateOrCreateFunnelCookie() { const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration; + const shouldSuppressConceptFunnel = getFunnelCookie()?.SuppressConceptFunnel; // Create the cookie document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`; @@ -21,7 +22,8 @@ export function updateOrCreateFunnelCookie() { ReferralDate: store.getters.order.referralDate, ReferralCorrelationId: store.getters.order.referralCorrelationId, ReferralParentAccountNumber: store.getters.order.accountNumber, - HasDelayedClaimRegistration: wasClaimRegistrationDelayed + HasDelayedClaimRegistration: wasClaimRegistrationDelayed, + SuppressConceptFunnel: shouldSuppressConceptFunnel }); } diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 03fca51b5..a5857fd74 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -21,7 +21,8 @@ describe("cookies", () => { ReferralDate: testReferralDate, ReferralCorrelationId: testReferralCorrelationId, ShouldResetState: testShouldResetState, - DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast + DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast, + SuppressConceptFunnel: true } setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) }); diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 8d46f6e4e..3ebb7ded8 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -39,9 +39,11 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita Used to navigate to the heritage funnel with the correct query string and url. */ -export async function navigateToHeritageFunnel() { +export async function navigateToHeritageFunnel(shouldSaveOrder = true) { // Create the order (or save existing order) when navigating to Heritage Funnel. - await saveOrder(); + if (shouldSaveOrder) { + await saveOrder(); + } router.navigateToExternalUrl( externalUrls.HERITAGE_FUNNEL, diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index e78782d7c..1b33c0a6f 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -331,7 +331,7 @@ describe("navigateToHeritageFunnel", () => { // Assert expect(saveOrderFunction).toHaveBeenCalled(); - // Should alway save before we navigate to heritage + // Should save before we navigate to heritage by default const saveOrderFunctionCallOrder = saveOrderFunction.mock.invocationCallOrder[0]; const routerNavigateFunctionCallOrder = router.navigateToExternalUrl.mock.invocationCallOrder[0]; expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder); @@ -373,4 +373,32 @@ describe("navigateToHeritageFunnel", () => { }) ); }); + + test("should not save order, but should still navigate", async () => { + // Arrange + const mockReferralNumber = "2"; + const mockCorrelationId = "55"; + const mockReferralDate = "2022"; + + const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate); + + const mockData = { + actionList: [{ + actionName: storeActions.SAVE_ORDER, + data: mockOrderInfo, + }] + } + + setupMocksForJsFiles(mockData); + const saveOrderFunction = jest.spyOn(orderHelper, "saveOrder"); + router.navigateToExternalUrl = jest.fn(); + + // Act + await navigateToHeritageFunnel(false); + + // Assert + expect(saveOrderFunction).not.toHaveBeenCalled(); + expect(router.navigateToExternalUrl).toHaveBeenCalled(); + saveOrderFunction.mockRestore(); + }); }); \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 8b9328db0..b09f734a2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -30,6 +30,11 @@ const routes = [ await analyticsMixin.methods.initSession(); } + if (getFunnelCookie()?.SuppressConceptFunnel) { + await navigateToHeritageFunnel(false); + return next(false); + } + // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); @@ -196,7 +201,7 @@ function navigateToUrl(url, optionalQuery = {}) { for (const queryKey in optionalQuery) { externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); } - + window.location.assign(externalUrl); }