From 9b69b8e6e9e016570bc46eb9f5929bf3ff9c34fd Mon Sep 17 00:00:00 2001 From: Jeremy Zimmerman Date: Mon, 7 Nov 2022 16:22:53 -0500 Subject: [PATCH] Updates --- src/constants/application-config.js | 3 + .../heritage-integration/session-helper.js | 1 + src/helpers/unit-test-helper.js | 58 ++++++++++--------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/constants/application-config.js b/src/constants/application-config.js index 9c3a3d05..6199b04b 100644 --- a/src/constants/application-config.js +++ b/src/constants/application-config.js @@ -1,6 +1,9 @@ const applicationConfig = { CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT, // "Localhost", "Dev", "QA", and "Prod" CONSUMER_CF_DISTRO: process.env.VUE_APP_CONSUMER_CF_DISTRO, + ANALYTICS_SESSION_TIMEOUT_MINUTES: 30, + SAVED_SESSION_TIMEOUT_DAYS: 45, + COOKIE_PATH: "/", APPLICATION_NAME: "SelfService", SITE_ENTRY_TRIGGER_VALUE: "SelfService", APPLICATION_ABBREVIATION: "iss", diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index 291ebfaf..02aa5181 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -9,6 +9,7 @@ export function isAnalyticsSessionStillActive() { if (getFunnelCookie() !== null) { const lastTouchedValue = getFunnelCookie().LastTouched; const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT_MINUTES; + const isMoreThanHalfHourAgo = (new Date() - new Date(lastTouchedValue)) / 60000 > timeoutAmount; diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 1091965f..0f275dd0 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -71,6 +71,15 @@ export const cookies = { skey: "12345", }; +export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = true }) { + Object.keys(cookies).forEach((key) => { + const cookieValue = + key == cookieNames.FUNNEL_SESSION_INFO ? funnelCookieValue : cookies[key]; + if (includeHeritageCookie || key != cookieNames.FUNNEL_SESSION_INFO) + setCookieProperties({ [key]: cookieValue }, { isSecure: false }); + }); +} + // Removes test cookies for testing cookie-helper and order-helper export function removeAllTestCookies() { Object.keys(cookies).forEach((key) => { @@ -79,6 +88,28 @@ export function removeAllTestCookies() { }); } +export function setupMocksForJsFiles(mockData = {}) { + setupBaseMixinDispatchStoreAction(mockData); + + return { baseMixin }; +} + +// Private methods +function setupBaseMixinDispatchStoreAction(mockData) { + if (mockData.actionList !== undefined) { + baseMixin.methods.dispatchStoreAction = jest.fn(); + baseMixin.methods.dispatchStoreAction.mockImplementation((actionName) => { + let actionFilterResult = mockData.actionList.filter((x) => x.actionName == actionName); + + if (actionFilterResult.length > 0 && actionFilterResult.length === 1) { + return Promise.resolve({ + data: actionFilterResult[0].data, + }); + } + }); + } +} + /* // Common methods @@ -136,11 +167,7 @@ export function getMountOptions(mockData) { return { global }; } -export function setupMocksForJsFiles(mockData = {}) { - setupBaseMixinDispatchStoreAction(mockData); - return { baseMixin }; -} @@ -162,28 +189,7 @@ export function getMockOrderInfo( }; } -export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = true }) { - Object.keys(cookies).forEach((key) => { - const cookieValue = - key == cookieNames.FUNNEL_SESSION_INFO ? funnelCookieValue : cookies[key]; - if (includeHeritageCookie || key != cookieNames.FUNNEL_SESSION_INFO) - setCookieProperties({ [key]: cookieValue }, { isSecure: false }); - }); -} -// Private methods -function setupBaseMixinDispatchStoreAction(mockData) { - if (mockData.actionList !== undefined) { - baseMixin.methods.dispatchStoreAction = jest.fn(); - baseMixin.methods.dispatchStoreAction.mockImplementation((actionName) => { - let actionFilterResult = mockData.actionList.filter((x) => x.actionName == actionName); - if (actionFilterResult.length > 0 && actionFilterResult.length === 1) { - return Promise.resolve({ - data: actionFilterResult[0].data, - }); - } - }); - } -} + */ \ No newline at end of file