Merge pull request #307 from Safelite/feature/CSR-99
rename concept to funnel
This commit is contained in:
commit
db25b06ba3
14 changed files with 72 additions and 96 deletions
|
|
@ -1,8 +1,8 @@
|
|||
const applicationConfig = {
|
||||
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
|
||||
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
|
||||
ANALYTICS_SESSION_TIMEOUT: 30,
|
||||
SAVED_SESSION_TIMEOUT: 45
|
||||
ANALYTICS_SESSION_TIMEOUT_MINUTES: 30,
|
||||
SAVED_SESSION_TIMEOUT_DAYS: 45
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const cookieNames = {
|
||||
CONCEPT_SESSION_INFO: "ConceptSessionInfo",
|
||||
FUNNEL_SESSION_INFO: "FunnelSessionInfo",
|
||||
};
|
||||
|
||||
export { cookieNames };
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const storeMutations = {
|
|||
|
||||
// OTHER MUTATIONS
|
||||
UPDATE_PAGE_DATA: "updatePageData",
|
||||
SET_LOAD_CONCEPT_SESSION_INFO: "setLoadOrderInformation"
|
||||
SET_LOAD_FUNNEL_SESSION_INFO: "setLoadOrderInformation"
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,22 +5,12 @@ import store from "@/store";
|
|||
/*
|
||||
Will update the cookie if present, or create a new one if not.
|
||||
*/
|
||||
export function updateOrCreateConceptCookie() {
|
||||
console.log("Updating cookie...", {
|
||||
LastTouched: new Date().toUTCString(),
|
||||
SavedQuoteTimeoutDate: store.getters.applicationUser.savedSessionTimeout,
|
||||
DidHeritageFunnelUpdateLast: false,
|
||||
ShouldResetState: false,
|
||||
ReferralNumber: store.getters.order.referralNumber,
|
||||
ReferralDate: store.getters.order.referralDate,
|
||||
ReferralCorrelationId: store.getters.order.referralCorrelationId,
|
||||
});
|
||||
|
||||
export function updateOrCreateFunnelCookie() {
|
||||
// Create the cookie
|
||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}={}; path=/`;
|
||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=/`;
|
||||
|
||||
// Set up cookie with all the props.
|
||||
setConceptCookieProperties({
|
||||
setFunnelCookieProperties({
|
||||
LastTouched: new Date().toUTCString(),
|
||||
SavedQuoteTimeoutDate: store.getters.applicationUser.savedSessionTimeout,
|
||||
DidHeritageFunnelUpdateLast: false,
|
||||
|
|
@ -33,13 +23,13 @@ export function updateOrCreateConceptCookie() {
|
|||
}
|
||||
|
||||
/*
|
||||
Gets the current instance of the concept funnel cookie.
|
||||
Gets the current instance of the funnel cookie.
|
||||
Returns null if cookie isn't valid JSON.
|
||||
*/
|
||||
export function getConceptCookie() {
|
||||
export function getFunnelCookie() {
|
||||
const cookieJson = document.cookie
|
||||
?.split("; ")
|
||||
?.find(row => row.startsWith(`${cookieNames.CONCEPT_SESSION_INFO}=`))
|
||||
?.find(row => row.startsWith(`${cookieNames.FUNNEL_SESSION_INFO}=`))
|
||||
?.split("=")[1];
|
||||
|
||||
try {
|
||||
|
|
@ -50,19 +40,19 @@ export function getConceptCookie() {
|
|||
}
|
||||
|
||||
/*
|
||||
Removes concept cookie from browser.
|
||||
Removes cookie from browser.
|
||||
*/
|
||||
export function deleteConceptCookie() {
|
||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
export function deleteFunnelCookie() {
|
||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
}
|
||||
|
||||
/*
|
||||
Used to set properties on the concept funnel cookie.
|
||||
Used to set properties on the funnel cookie.
|
||||
Takes an object with properties to set. Will overwrite existing properties.
|
||||
*/
|
||||
function setConceptCookieProperties(properties) {
|
||||
function setFunnelCookieProperties(properties) {
|
||||
if (typeof properties == "object") {
|
||||
let cookie = getConceptCookie();
|
||||
let cookie = getFunnelCookie();
|
||||
|
||||
if (cookie !== null) {
|
||||
Object.keys(properties).forEach(key => {
|
||||
|
|
@ -71,7 +61,7 @@ function setConceptCookieProperties(properties) {
|
|||
|
||||
const cookieValueJson = JSON.stringify(cookie);
|
||||
|
||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=${cookieValueJson}; path=/`;
|
||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=/`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {getConceptCookie} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import {getFunnelCookie} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper";
|
||||
|
||||
describe("cookies", () => {
|
||||
|
|
@ -7,7 +7,7 @@ describe("cookies", () => {
|
|||
removeAllTestCookies();
|
||||
})
|
||||
|
||||
describe("getConceptCookie method", () => {
|
||||
describe("getFunnelCookie method", () => {
|
||||
test("gets correct value when cookie is present", () => {
|
||||
// Arrange
|
||||
const testReferralNumber = 1566818;
|
||||
|
|
@ -24,10 +24,10 @@ describe("cookies", () => {
|
|||
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast
|
||||
}
|
||||
|
||||
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
var result = getConceptCookie();
|
||||
var result = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(testCookieValue);
|
||||
|
|
@ -42,10 +42,10 @@ describe("cookies", () => {
|
|||
test("returns empty object when value is empty object", () => {
|
||||
// Arrange
|
||||
const testCookieValue = {};
|
||||
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
var result = getConceptCookie();
|
||||
var result = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(testCookieValue);
|
||||
|
|
@ -56,21 +56,21 @@ describe("cookies", () => {
|
|||
test("returns null when value is empty string", () => {
|
||||
// Arrange
|
||||
const testCookieValue = "";
|
||||
setupCookies({ conceptCookieValue: testCookieValue });
|
||||
setupCookies({ funnelCookieValue: testCookieValue });
|
||||
|
||||
// Act
|
||||
var result = getConceptCookie();
|
||||
var result = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(null);
|
||||
});
|
||||
|
||||
test("returns null when concept cookie doesn't exist", () => {
|
||||
test("returns null when funnel cookie doesn't exist", () => {
|
||||
// Arrange
|
||||
setupCookies({ includeHeritageCookie: false });
|
||||
|
||||
// Act
|
||||
var result = getConceptCookie();
|
||||
var result = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(null);
|
||||
|
|
@ -80,10 +80,10 @@ describe("cookies", () => {
|
|||
// Arrange
|
||||
const testCookieValue = { test: "testValue" };
|
||||
|
||||
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
const actualCookieValue = getConceptCookie();
|
||||
const actualCookieValue = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(actualCookieValue).toEqual(testCookieValue);
|
||||
|
|
@ -94,7 +94,7 @@ describe("cookies", () => {
|
|||
setupCookies({ includeHeritageCookie: false });
|
||||
|
||||
// Act
|
||||
const actualCookieValue = getConceptCookie();
|
||||
const actualCookieValue = getFunnelCookie();
|
||||
|
||||
// Assert
|
||||
expect(actualCookieValue).toBeNull();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import store from "@/store";
|
|||
import router from "@/router";
|
||||
|
||||
/*
|
||||
If the user has visited the concept funnel before this method will determine the bets place to
|
||||
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.
|
||||
*/
|
||||
|
|
@ -14,11 +14,9 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
|||
|
||||
// If the user is coming in via the Safelite.Com CTA
|
||||
if (toRoute.query[queryStrings.START_TYPE] === 'fmg') {
|
||||
console.log("Start type is FMG... trying to figure out where to send them...");
|
||||
|
||||
// If they have an existing order, return 'heritage' for the page name.
|
||||
if (existingHeritageOrder) {
|
||||
console.log("Existing heritage order found, returning 'heritage' for page redirect...");
|
||||
return 'heritage';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { storeActions } from "@/constants/store-actions.js";
|
||||
import { getConceptCookie, updateOrCreateConceptCookie, deleteConceptCookie } from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import { getFunnelCookie, updateOrCreateFunnelCookie, deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
|
||||
/*
|
||||
|
|
@ -9,29 +9,23 @@ import baseMixin from "@/mixins/base-mixin";
|
|||
|
||||
*/
|
||||
export async function loadOrderIfPresent() {
|
||||
console.log("attempting to load referral....");
|
||||
const conceptCookie = getConceptCookie();
|
||||
|
||||
console.log(conceptCookie)
|
||||
const funnelCookie = getFunnelCookie();
|
||||
|
||||
// Do nothing if there is no cookie or no correlation id.
|
||||
if (conceptCookie == null || conceptCookie.ReferralCorrelationId == null) {
|
||||
console.log("No referral found");
|
||||
if (funnelCookie == null || funnelCookie.ReferralCorrelationId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Reset state if cookie says to.
|
||||
if (conceptCookie.ShouldResetState) {
|
||||
console.log("Resetting state...");
|
||||
if (funnelCookie.ShouldResetState) {
|
||||
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
|
||||
deleteConceptCookie();
|
||||
deleteFunnelCookie();
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log("calling load order from loadOrderIfPresent()...");
|
||||
|
||||
// Load referral if there is a cookie, and it doesn't indicate it needs a state reset.
|
||||
return (await loadOrder(conceptCookie.ReferralNumber, conceptCookie.ReferralDate, conceptCookie.ReferralCorrelationId)).data;
|
||||
return (await loadOrder(funnelCookie.ReferralNumber, funnelCookie.ReferralDate, funnelCookie.ReferralCorrelationId)).data;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -40,7 +34,6 @@ export async function loadOrderIfPresent() {
|
|||
update the cookie.
|
||||
*/
|
||||
export async function saveOrder() {
|
||||
console.log("saving order...");
|
||||
const savedOrderInfo = await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER);
|
||||
|
||||
// Save the referral information back from the store.
|
||||
|
|
@ -51,7 +44,7 @@ export async function saveOrder() {
|
|||
}, false);
|
||||
|
||||
// Update the cookie with the referral information when saved.
|
||||
updateOrCreateConceptCookie();
|
||||
updateOrCreateFunnelCookie();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -62,7 +55,6 @@ export async function saveOrder() {
|
|||
and returns the response.
|
||||
*/
|
||||
async function loadOrder(referralNumber, referralDate, referralCorrelationId) {
|
||||
console.log("loading order...", referralNumber, referralDate, referralCorrelationId);
|
||||
const response = await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOAD_ORDER,
|
||||
{
|
||||
referralNumber: referralNumber.toString(),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe("loadOrderIfPresent", () => {
|
|||
removeAllTestCookies();
|
||||
});
|
||||
|
||||
test("ShouldResetState == true => concept cookie is deleted", () => {
|
||||
test("ShouldResetState == true => funnel cookie is deleted", () => {
|
||||
// Arrange
|
||||
const testShouldResetState = true;
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ describe("loadOrderIfPresent", () => {
|
|||
|
||||
test("ShouldResetState == true => reset store", () => {
|
||||
// Arrange
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie").mockReturnValueOnce({ ShouldResetState: true, ReferralCorrelationId: "xxx-xxx-xxx" });
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValueOnce({ ShouldResetState: true, ReferralCorrelationId: "xxx-xxx-xxx" });
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
|
|
@ -44,13 +44,13 @@ describe("loadOrderIfPresent", () => {
|
|||
loadOrderIfPresent();
|
||||
|
||||
// Assert
|
||||
expect(cookieHelper.getConceptCookie).toHaveBeenCalled();
|
||||
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
|
||||
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toHaveBeenCalledWith(storeActions.RESET_STATE);
|
||||
});
|
||||
|
||||
test("Concept cookie is null => store is unchanged", () => {
|
||||
test("Funnel cookie is null => store is unchanged", () => {
|
||||
// Arrange
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie").mockReturnValueOnce(null);
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValueOnce(null);
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
|
|
@ -64,13 +64,13 @@ describe("loadOrderIfPresent", () => {
|
|||
loadOrderIfPresent();
|
||||
|
||||
// Assert
|
||||
expect(cookieHelper.getConceptCookie).toHaveBeenCalled();
|
||||
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
|
||||
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).not.toHaveBeenCalledWith(storeActions.RESET_STATE);
|
||||
});
|
||||
|
||||
test("Concept cookie valid, should call loadOrder", async () => {
|
||||
test("Funnel cookie valid, should call loadOrder", async () => {
|
||||
// Arrange
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie")
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
|
||||
.mockReturnValueOnce({ ShouldResetState: false, ReferralNumber: 123456, ReferralCorrelationId: "yyy-yyy-yyyy", ReferralDate: new Date()});
|
||||
|
||||
const mockData = {
|
||||
|
|
@ -86,7 +86,7 @@ describe("loadOrderIfPresent", () => {
|
|||
const result = await loadOrderIfPresent();
|
||||
|
||||
// Assert
|
||||
expect(cookieHelper.getConceptCookie).toHaveBeenCalled();
|
||||
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
|
||||
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).not.toHaveBeenCalledWith(storeActions.LOAD_ORDER);
|
||||
expect(result.ReferralNumber).toBe(123456);
|
||||
expect(result.vehicle.year).toBe(2010);
|
||||
|
|
@ -159,12 +159,12 @@ describe("saveOrder", () => {
|
|||
DidHeritageFunnelUpdateLast: true
|
||||
}
|
||||
|
||||
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
await saveOrder();
|
||||
|
||||
// Assert
|
||||
expect(cookieHelper.getConceptCookie().DidHeritageFunnelUpdateLast).toEqual(false);
|
||||
expect(cookieHelper.getFunnelCookie().DidHeritageFunnelUpdateLast).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { applicationConfig } from "@/constants/application-config";
|
||||
import { getConceptCookie} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import { getFunnelCookie} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
|
||||
/*
|
||||
Method to determine if our analytics session has timed out or not.
|
||||
Amount used for timeout is configurable in application-config.js
|
||||
*/
|
||||
export function isAnalyticsSessionStillActive() {
|
||||
if (getConceptCookie() !== null) {
|
||||
const lastTouchedValue = getConceptCookie().LastTouched;
|
||||
const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT;
|
||||
if (getFunnelCookie() !== null) {
|
||||
const lastTouchedValue = getFunnelCookie().LastTouched;
|
||||
const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT_MINUTES;
|
||||
const isMoreThanHalfHourAgo = ((new Date() - new Date(lastTouchedValue)) / 60000) > timeoutAmount;
|
||||
|
||||
if (isMoreThanHalfHourAgo) {
|
||||
|
|
@ -27,11 +27,9 @@ export function isAnalyticsSessionStillActive() {
|
|||
Note: That time for saved session timeout is configurable in application-config.js
|
||||
*/
|
||||
export function isSavedSessionStillActive() {
|
||||
if (getConceptCookie() !== null) {
|
||||
const savedSessionTimeStamp = new Date(getConceptCookie().SavedQuoteTimeoutDate);
|
||||
if (getFunnelCookie() !== null) {
|
||||
const savedSessionTimeStamp = new Date(getFunnelCookie().SavedQuoteTimeoutDate);
|
||||
const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp);
|
||||
console.log(savedSessionTimeStamp, isSavedSessionTimedOut);
|
||||
console.log("Saved Session Timed Out? --->", isSavedSessionTimedOut);
|
||||
|
||||
if (isSavedSessionTimedOut) {
|
||||
return false;
|
||||
|
|
@ -47,6 +45,6 @@ Function to get the date for the saved session timeout.
|
|||
|
||||
export function getDateForSavedSessionTimeout() {
|
||||
const currentDate = new Date(new Date().toUTCString())
|
||||
currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT)
|
||||
currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS)
|
||||
return currentDate.toUTCString();
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ describe("isAnalyticsSessionStillActive", () => {
|
|||
const mockDate = new Date(new Date().toUTCString())
|
||||
mockDate.setDate(mockDate.getDate() + 1)
|
||||
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie")
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
|
||||
.mockReturnValue({ LastTouched: mockDate });
|
||||
|
||||
// Act
|
||||
|
|
@ -23,7 +23,7 @@ describe("isAnalyticsSessionStillActive", () => {
|
|||
const mockDate = new Date(new Date().toUTCString())
|
||||
mockDate.setDate(mockDate.getDate() - 1)
|
||||
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie")
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
|
||||
.mockReturnValue({ LastTouched: mockDate });
|
||||
|
||||
// Act
|
||||
|
|
@ -40,7 +40,7 @@ describe("isSavedSessionStillActive", () => {
|
|||
const mockDate = new Date(new Date().toUTCString())
|
||||
mockDate.setDate(mockDate.getDate() + 1);
|
||||
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie")
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
|
||||
.mockReturnValue({ SavedQuoteTimeoutDate: mockDate });
|
||||
|
||||
// Act
|
||||
|
|
@ -55,7 +55,7 @@ describe("isSavedSessionStillActive", () => {
|
|||
const mockDate = new Date(new Date().toUTCString())
|
||||
mockDate.setDate(mockDate.getDate() - 1)
|
||||
|
||||
cookieHelper.getConceptCookie = jest.spyOn(cookieHelper, "getConceptCookie")
|
||||
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
|
||||
.mockReturnValue({ SavedQuoteTimeoutDate: mockDate });
|
||||
|
||||
// Act
|
||||
|
|
@ -71,7 +71,7 @@ describe("getDateForSavedSessionTimeout", () => {
|
|||
test("getDateForSavedSessionTimeout, should equal application config setting", () =>{
|
||||
// Arrange
|
||||
const currentDate = new Date(new Date().toUTCString())
|
||||
currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT)
|
||||
currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS)
|
||||
|
||||
// Act
|
||||
const result = getDateForSavedSessionTimeout();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export function setupMocksForJsFiles(mockData = {}) {
|
|||
|
||||
// Heritage integration common methods
|
||||
export const cookies = {
|
||||
[cookieNames.CONCEPT_SESSION_INFO]: `{"ReferralNumber":"1566818","ReferralDate":"2022-03-15T10:56:24.597","ReferralCorrelationId":"404d2b04-f86e-45c3-b373-127b6217b060","ShouldResetState":false,"DidHeritageFunnelUpdateLast":true}`,
|
||||
[cookieNames.FUNNEL_SESSION_INFO]: `{"ReferralNumber":"1566818","ReferralDate":"2022-03-15T10:56:24.597","ReferralCorrelationId":"404d2b04-f86e-45c3-b373-127b6217b060","ShouldResetState":false,"DidHeritageFunnelUpdateLast":true}`,
|
||||
"UNIQUE_SESSION_ID": "33756020-b58e-4ec7-b8b8-3f1576719c40",
|
||||
"anotherCookie": "{}",
|
||||
"someOtherCookie": "{}"
|
||||
|
|
@ -75,11 +75,11 @@ export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockRefe
|
|||
}
|
||||
}
|
||||
|
||||
export function setupCookies({ conceptCookieValue = "", includeHeritageCookie = true }) {
|
||||
export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = true }) {
|
||||
Object.keys(cookies).forEach(key => {
|
||||
const cookieValue = key == cookieNames.CONCEPT_SESSION_INFO ? conceptCookieValue : cookies[key];
|
||||
const cookieValue = key == cookieNames.FUNNEL_SESSION_INFO ? funnelCookieValue : cookies[key];
|
||||
|
||||
if (includeHeritageCookie || key != cookieNames.CONCEPT_SESSION_INFO)
|
||||
if (includeHeritageCookie || key != cookieNames.FUNNEL_SESSION_INFO)
|
||||
document.cookie = `${key}=${cookieValue}; path=/;`;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { globalEvents, globalEventTypes } from "@/constants/events";
|
|||
|
||||
// Heritage integration
|
||||
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
|
||||
import { updateOrCreateConceptCookie,getConceptCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||
import { updateOrCreateFunnelCookie,getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||
import { loadOrderIfPresent, saveOrder } from "@/helpers/heritage-integration/order-helper";
|
||||
import { getPageToRouteExistingOrderTo, navigateToHeritageFunnel} from "@/helpers/heritage-integration/navigation-helper";
|
||||
|
||||
|
|
@ -45,10 +45,10 @@ const routes = [
|
|||
await GoToFunnelStartOn404(next);
|
||||
}
|
||||
|
||||
// Process concept funnel cookie.
|
||||
updateOrCreateConceptCookie();
|
||||
// Process funnel cookie.
|
||||
updateOrCreateFunnelCookie();
|
||||
|
||||
// On entering the concept funnel "fresh", read cookie information, decide what to do next.
|
||||
// On entering the funnel "fresh", read cookie information, decide what to do next.
|
||||
if (from.redirectedFrom === undefined) {
|
||||
const loadOrderResponse = await loadOrderIfPresent();
|
||||
const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse);
|
||||
|
|
@ -62,8 +62,6 @@ const routes = [
|
|||
|
||||
// Assign our fmgPage so it will load normally like the other pages.
|
||||
to.query.fmgPage = pageToRedirectTo;
|
||||
|
||||
console.log("Page to redirect to: ", pageToRedirectTo);
|
||||
}
|
||||
|
||||
// If we already have our route, go to it.
|
||||
|
|
@ -164,7 +162,7 @@ async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery
|
|||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
// if cookie and referralNumber/Date exists
|
||||
if (getConceptCookie()?.ReferralNumber && getConceptCookie()?.ReferralDate) {
|
||||
if (getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) {
|
||||
await saveOrder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ export const actions = {
|
|||
referralCorrelationId: referralCorrelationId
|
||||
},
|
||||
}).then((response) => {
|
||||
context.commit(storeMutations.SET_LOAD_CONCEPT_SESSION_INFO, response.data);
|
||||
context.commit(storeMutations.SET_LOAD_FUNNEL_SESSION_INFO, response.data);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ describe("Actions", () => {
|
|||
|
||||
// Assert
|
||||
expect(response.data).toEqual({ referralNumber: 123 });
|
||||
expect(commit).toBeCalledWith(storeMutations.SET_LOAD_CONCEPT_SESSION_INFO, {"referralNumber": 123});
|
||||
expect(commit).toBeCalledWith(storeMutations.SET_LOAD_FUNNEL_SESSION_INFO, {"referralNumber": 123});
|
||||
});
|
||||
|
||||
it("setReferralInformation, should call commit three times", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue