diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index f8cf05174..cee400e0c 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -42,6 +42,7 @@ export function getFunnelCookie() { Removes cookie from browser. */ export function deleteFunnelCookie() { + console.log("hi there") document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; ${getCookieDomainValue()}`; } diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index aaf0db740..8dddb5436 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -10,6 +10,7 @@ import baseMixin from "@/mixins/base-mixin"; */ export async function loadOrderIfPresent() { const funnelCookie = getFunnelCookie(); + console.log(funnelCookie) // Do nothing if there is no cookie or no correlation id. if (funnelCookie == null || funnelCookie.ReferralCorrelationId == null) { @@ -20,6 +21,7 @@ export async function loadOrderIfPresent() { if (funnelCookie.ShouldResetState) { baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE); deleteFunnelCookie(); + console.log("sup") return null; } diff --git a/src/helpers/heritage-integration/order-helper.spec.js b/src/helpers/heritage-integration/order-helper.spec.js index d53afc232..cbe54ba25 100644 --- a/src/helpers/heritage-integration/order-helper.spec.js +++ b/src/helpers/heritage-integration/order-helper.spec.js @@ -13,18 +13,21 @@ describe("loadOrderIfPresent", () => { test("ShouldResetState == true => funnel cookie is deleted", () => { // Arrange + cookieHelper.deleteFunnelCookie = jest.spyOn(cookieHelper, "deleteFunnelCookie"); const testShouldResetState = true; const testCookieValue = { - ShouldResetState: testShouldResetState + ShouldResetState: testShouldResetState, + ReferralCorrelationId: "xxx" } - document.cookie = `${cookieNames.ORDER_INFO}=${JSON.stringify(testCookieValue)}; path=/; ${cookieHelper.getCookieDomainValue()}`; + document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${JSON.stringify(testCookieValue)}; path=/; ${cookieHelper.getCookieDomainValue()}`; // Act loadOrderIfPresent(); // Assert + expect(cookieHelper.deleteFunnelCookie).toHaveBeenCalled(); expect(document.cookie).toBe(""); });