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