From 59dfb0c4fb5067006f08e7b0813d4ed0c21b74ad Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 28 Nov 2023 15:30:35 -0500 Subject: [PATCH 01/16] CSR-1841 | Ensure saving promos cleans up inactivePromos --- src/store/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index efaf5b428..1d350a143 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2130,6 +2130,17 @@ export const actions = { }, // Manage promo saving to ensure a promoCode never ends up in both active and inactive saveActiveAndOrInactivePromos(context, { activePromos = null, inactivePromos = null }) { + if (inactivePromos) { + // Clean up inactivePromos + // Remove bundle identifier + inactivePromos = inactivePromos.map((promoCode) => + getPromoCodeWithoutBundleIdentifier(promoCode) + ); + // Remove duplicates + inactivePromos = inactivePromos.filter( + (promoCode, index) => inactivePromos.indexOf(promoCode) === index + ); + } activePromos = activePromos?.slice(0); inactivePromos = inactivePromos?.slice(0); let activePromosToSave; From 25f56e51c4dfe9e2491940bace7a52577e0d8414 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 09:31:08 -0500 Subject: [PATCH 02/16] Remove unneeded damage check --- src/store/index.js | 10 +--------- src/store/store.spec.js | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 574df8012..a094a8a15 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2495,15 +2495,7 @@ export const actions = { isVinOptionalVehicle(context) { //Optional for carIds with only a single windshield - if ( - singleWindshieldCarIds.find((item) => item === context.state.order.vehicle.carId) && - context.state.order.damage.glassToReplace.length == 1 && - context.state.order.damage.glassToReplace.find( - (glassToReplace) => - glassToReplace.glassLocation.toLowerCase() === - damageLocationsSelected.WINDSHIELD.toLowerCase() - ) - ) { + if (singleWindshieldCarIds.find((item) => item === context.state.order.vehicle.carId)) { return true; } //Optional for specific YMMSs diff --git a/src/store/store.spec.js b/src/store/store.spec.js index e7c004090..8353ec0d8 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -3329,7 +3329,7 @@ describe("isVinOptionalVehicle", () => { "CR00062396", "make3", [{ glassLocation: "windshield" }, { glassLocation: "driver" }], - false, + true, ], ["CR00066428", "make4", [{ glassLocation: "rear" }], false], ]; From 57d2b4ee0ee3833ee13fd2ab6c7d029798bb6a81 Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Tue, 5 Dec 2023 09:38:11 -0500 Subject: [PATCH 03/16] CSR-1860 fix styling for select input. --- public/css/hop-styling.css | 2 ++ public/scss/hop-styling.scss | 2 ++ 2 files changed, 4 insertions(+) diff --git a/public/css/hop-styling.css b/public/css/hop-styling.css index cd94e3024..68e556d53 100644 --- a/public/css/hop-styling.css +++ b/public/css/hop-styling.css @@ -73,6 +73,8 @@ body select { background-position: 95% 50%; background-size: 15px 9px; appearance: none; + font-size: 16px; + color: #000; } body .creditCardSpecific div { padding: 8px 0; diff --git a/public/scss/hop-styling.scss b/public/scss/hop-styling.scss index 5f21c46dd..ed8e8e14c 100644 --- a/public/scss/hop-styling.scss +++ b/public/scss/hop-styling.scss @@ -85,6 +85,8 @@ body { background-position: 95% 50%; background-size: 15px 9px; appearance: none; + font-size: 16px; + color: #000; } .creditCardSpecific { From f45d73e297dfaf979a75dc40ca8beb584263f7fd Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 10:49:05 -0500 Subject: [PATCH 04/16] Tests for deviceID --- .../cookie-helper.spec.js | 91 +++++++++++++++---- src/helpers/unit-test-helper.js | 8 ++ 2 files changed, 83 insertions(+), 16 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 5df2ae925..8abd265e5 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -3,10 +3,19 @@ import { getDeviceIdValue, getSessionKeyValue, getSessionIdValue, + setCookieProperties, + regenerateDeviceId, } from "@/helpers/heritage-integration/cookie-helper.js"; -import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper"; +import { cookieNames } from "@/constants/cookie-names"; +import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; + +const randomUUID = "68d89736-c277-46f1-8fee-c3dacdb23c08"; describe("cookies", () => { + beforeEach(() => { + setupCrypto(randomUUID); + }); + afterEach(() => { removeAllTestCookies(); }); @@ -106,30 +115,80 @@ describe("cookies", () => { }); }); - describe("getDeviceIdValue", () => { - test("getDeviceIdValue, should return GUID", () => { - // Arrange - setupCookies({}); + describe("Device Id", () => { + describe("getDeviceIdValue", () => { + test("getDeviceIdValue, should return GUID", () => { + // Arrange + setupCookies({}); - // Act - const result = getDeviceIdValue(); + // Act + const result = getDeviceIdValue(); - //Assert - expect(result).toBe("21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe"); + //Assert + expect(result).toBe("21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe"); + }); + + test("Should return 0s if unset", () => { + //Arrange + //Act + const result = getDeviceIdValue(); + + //Assert + expect(result).toBe("00000000-0000-0000-0000-000000000000"); + }); + + test("Should return id even if cookie contains other data", () => { + //Arrange + setCookieProperties({ + [cookieNames.DXDEV]: "did=f4a1a9e8-b3f3-4936-8c30-2f06a98644af&tz=-300&tzd=1", + }, {}); + + //Act + const result = getDeviceIdValue(); + + //Assert + expect(result).toBe("f4a1a9e8-b3f3-4936-8c30-2f06a98644af"); + }); }); - test("getSessionKeyValue, should return session key int", () => { - // Arrange - setupCookies({}); + describe("regenerateDeviceId", () => { + test("Generates a new id if unset", () => { + // Arrange + // Act + regenerateDeviceId(); + const result = getDeviceIdValue(); - // Act - const result = getSessionKeyValue(); + // Assert + expect(result).not.toBe("00000000-0000-0000-0000-000000000000"); + expect(global.crypto.randomUUID).toBeCalled(); + }); - //Assert - expect(result).toBe("12345"); + test("Does not create a new id if already set", () => { + // Arrange + setupCookies({}); + + // Act + regenerateDeviceId(); + const result = getDeviceIdValue(); + + // Assert + expect(result).toBe("21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe"); + expect(global.crypto.randomUUID).not.toBeCalled(); + }); }); }); + test("getSessionKeyValue, should return session key int", () => { + // Arrange + setupCookies({}); + + // Act + const result = getSessionKeyValue(); + + //Assert + expect(result).toBe("12345"); + }); + describe("getSessionIdValue", () => { test("getSessionIdValue, should return GUID", () => { // Arrange diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 123dc9d40..457dd47fb 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -139,6 +139,14 @@ export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = t }); } +export function setupCrypto(mockValue) { + global.crypto = { + randomUUID: jest.fn() + }; + + global.crypto.randomUUID.mockImplementation(() => mockValue); +} + // Private methods function setupBaseMixinDispatchStoreAction(mockData) { if (mockData.actionList !== undefined) { From aa59d955cb1a5faace71bf34286cfedfd6428e4b Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 11:35:51 -0500 Subject: [PATCH 05/16] UserId + Formatting --- .../cookie-helper.spec.js | 62 ++++++++++++++++++- src/helpers/unit-test-helper.js | 2 +- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 8abd265e5..349b2206a 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -5,6 +5,8 @@ import { getSessionIdValue, setCookieProperties, regenerateDeviceId, + getUserIdValue, + regenerateUserId, } from "@/helpers/heritage-integration/cookie-helper.js"; import { cookieNames } from "@/constants/cookie-names"; import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; @@ -139,9 +141,13 @@ describe("cookies", () => { test("Should return id even if cookie contains other data", () => { //Arrange - setCookieProperties({ - [cookieNames.DXDEV]: "did=f4a1a9e8-b3f3-4936-8c30-2f06a98644af&tz=-300&tzd=1", - }, {}); + setCookieProperties( + { + [cookieNames.DXDEV]: + "did=f4a1a9e8-b3f3-4936-8c30-2f06a98644af&tz=-300&tzd=1", + }, + {} + ); //Act const result = getDeviceIdValue(); @@ -178,6 +184,56 @@ describe("cookies", () => { }); }); + describe("User Id", () => { + describe("getUserIdValue", () => { + test("Should return GUID", () => { + // Arrange + setupCookies({}); + + // Act + const result = getUserIdValue(); + + //Assert + expect(result).toBe("11aec5e8-92ba-4dc9-a8b6-179a916d8d7a"); + }); + + test("Should return 0s if unset", () => { + //Arrange + //Act + const result = getUserIdValue(); + + //Assert + expect(result).toBe("00000000-0000-0000-0000-000000000000"); + }); + }); + + describe("regenerateUserId", () => { + test("Generates a new id if unset", () => { + // Arrange + // Act + regenerateUserId(); + const result = getUserIdValue(); + + // Assert + expect(result).not.toBe("00000000-0000-0000-0000-000000000000"); + expect(global.crypto.randomUUID).toBeCalled(); + }); + + test("Does not create a new id if already set", () => { + // Arrange + setupCookies({}); + + // Act + regenerateUserId(); + const result = getUserIdValue(); + + // Assert + expect(result).toBe("11aec5e8-92ba-4dc9-a8b6-179a916d8d7a"); + expect(global.crypto.randomUUID).not.toBeCalled(); + }); + }); + }); + test("getSessionKeyValue, should return session key int", () => { // Arrange setupCookies({}); diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 457dd47fb..2cd580df0 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -141,7 +141,7 @@ export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = t export function setupCrypto(mockValue) { global.crypto = { - randomUUID: jest.fn() + randomUUID: jest.fn(), }; global.crypto.randomUUID.mockImplementation(() => mockValue); From 736aee68e990e82d5f862890661fc7c84ab396d3 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 11:46:31 -0500 Subject: [PATCH 06/16] Session Key --- .../cookie-helper.spec.js | 54 ++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 349b2206a..c5cbc5bee 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -7,6 +7,7 @@ import { regenerateDeviceId, getUserIdValue, regenerateUserId, + setSessionKeyIfUnset, } from "@/helpers/heritage-integration/cookie-helper.js"; import { cookieNames } from "@/constants/cookie-names"; import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; @@ -234,15 +235,54 @@ describe("cookies", () => { }); }); - test("getSessionKeyValue, should return session key int", () => { - // Arrange - setupCookies({}); + describe("Session Key", () => { + describe("getSessionKeyValue", () => { + test("Should return session key int", () => { + // Arrange + setupCookies({}); - // Act - const result = getSessionKeyValue(); + // Act + const result = getSessionKeyValue(); - //Assert - expect(result).toBe("12345"); + //Assert + expect(result).toBe("12345"); + }); + + test("Should return 0 if unset", () => { + // Arrange + + // Act + const result = getSessionKeyValue(); + + //Assert + expect(result).toBe(0); + }); + }); + + describe("setSessionKeyIfUnset", () => { + test("Should set the cookie if not previously set", () => { + // Arrange + + // Act + setSessionKeyIfUnset("54321"); + const result = getSessionKeyValue(); + + // Assert + expect(result).toBe("54321"); + }); + + test("Should not set the cookie if previously set", () => { + // Arrange + setupCookies({}); + + // Act + setSessionKeyIfUnset("54321"); + const result = getSessionKeyValue(); + + // Assert + expect(result).toBe("12345"); + }); + }); }); describe("getSessionIdValue", () => { From 1f0a0870c932fd2511129c4356c9695068c78220 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 12:40:37 -0500 Subject: [PATCH 07/16] Session Id --- .../cookie-helper.spec.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index c5cbc5bee..99a502559 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -8,6 +8,7 @@ import { getUserIdValue, regenerateUserId, setSessionKeyIfUnset, + setSessionIdIfUnset, } from "@/helpers/heritage-integration/cookie-helper.js"; import { cookieNames } from "@/constants/cookie-names"; import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; @@ -285,6 +286,56 @@ describe("cookies", () => { }); }); + describe("Session Id", () => { + describe("getSessionIdValue", () => { + test("Should return session id", () => { + // Arrange + setupCookies({}); + + // Act + const result = getSessionIdValue(); + + //Assert + expect(result).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27"); + }); + + test("Should return 0s if unset", () => { + // Arrange + + // Act + const result = getSessionIdValue(); + + //Assert + expect(result).toBe("00000000-0000-0000-0000-000000000000"); + }); + }); + + describe("setSessionIdIfUnset", () => { + test("Should set the cookie if not previously set", () => { + // Arrange + + // Act + setSessionIdIfUnset("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02"); + const result = getSessionIdValue(); + + // Assert + expect(result).toBe("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02"); + }); + + test("Should not set the cookie if previously set", () => { + // Arrange + setupCookies({}); + + // Act + setSessionIdIfUnset("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02"); + const result = getSessionIdValue(); + + // Assert + expect(result).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27"); + }); + }); + }); + describe("getSessionIdValue", () => { test("getSessionIdValue, should return GUID", () => { // Arrange From 48756a9683262c4c4af4ecaf78c923b4bdeafec1 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 12:44:01 -0500 Subject: [PATCH 08/16] Cleanup --- .../heritage-integration/cookie-helper.spec.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 99a502559..73cc388d6 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -335,17 +335,4 @@ describe("cookies", () => { }); }); }); - - describe("getSessionIdValue", () => { - test("getSessionIdValue, should return GUID", () => { - // Arrange - setupCookies({}); - - // Act - const result = getSessionIdValue(); - - //Assert - expect(result).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27"); - }); - }); }); From 4be83e96493cdd5a5a6d16634995c6d1f2e7d8be Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 13:08:41 -0500 Subject: [PATCH 09/16] Is Cookie Set --- .../cookie-helper.spec.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 73cc388d6..55b4a73ff 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -9,6 +9,7 @@ import { regenerateUserId, setSessionKeyIfUnset, setSessionIdIfUnset, + isCookieSet, } from "@/helpers/heritage-integration/cookie-helper.js"; import { cookieNames } from "@/constants/cookie-names"; import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; @@ -335,4 +336,43 @@ describe("cookies", () => { }); }); }); + + describe("isCookieSet", () => { + test("Returns true if cookie is set and unexpired", () => { + // Arrange + setupCookies({}); + + // Act + const result = isCookieSet(cookieNames.SESSION_ID); + + // Assert + expect(result).toBe(true); + }); + + test("Returns false if never set", () => { + // Arrange + // Act + const result = isCookieSet(cookieNames.SESSION_ID); + + // Assert + expect(result).toBe(false); + }); + + test("Returns false if cookie is expired", () => { + // Arrange + setupCookies({}); + + // Act + setCookieProperties( + { + [cookieNames.SESSION_ID]: "test", + }, + { maxAge: 0 } + ); + const result = isCookieSet(cookieNames.SESSION_ID); + + // Assert + expect(result).toBe(false); + }); + }); }); From 67c9b1609bd1cd9422969c52beebefa4739149de Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 14:00:28 -0500 Subject: [PATCH 10/16] Final cookie tests --- .../cookie-helper.spec.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 55b4a73ff..0929e0ed6 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -10,6 +10,7 @@ import { setSessionKeyIfUnset, setSessionIdIfUnset, isCookieSet, + refreshCookieExpiration, } from "@/helpers/heritage-integration/cookie-helper.js"; import { cookieNames } from "@/constants/cookie-names"; import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper"; @@ -375,4 +376,29 @@ describe("cookies", () => { expect(result).toBe(false); }); }); + + describe("refreshCookieExpiration", () => { + test("Preserves value", () => { + // Arrange + setupCookies({}); + + // Act + const result1 = getSessionIdValue(); + refreshCookieExpiration(cookieNames.SESSION_ID, 1000000); + const result2 = getSessionIdValue(); + + // Assert + expect(result1).toBe(result2); + }); + + test("Does not set cookie if not already set", () => { + // Arrange + + // Act + refreshCookieExpiration(cookieNames.SESSION_ID, 1000000); + const result = isCookieSet(cookieNames.SESSION_ID); + + expect(result).toBe(false); + }); + }); }); From ef5a6a55e3771edf64706ca3f79feed281e92b34 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 14:08:05 -0500 Subject: [PATCH 11/16] Properly mock crypto module --- src/mixins/analytics-mixin.spec.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index 8f7cfceaa..7e04215af 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -1,5 +1,5 @@ import analyticsMixin from "@/mixins/analytics-mixin"; -import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js"; +import { setupMocksForJsFiles, setupCookies, setupCrypto } from "@/helpers/unit-test-helper.js"; import { storeActions } from "@/constants/store-actions"; import { analyticsPageEvents, @@ -11,19 +11,12 @@ import { } from "@/constants/analytics"; import store from "@/store"; -// Mock only the regenerate functions; window.crypto is not available in testing. -jest.mock("@/helpers/heritage-integration/cookie-helper", () => { - const originalModule = jest.requireActual("@/helpers/heritage-integration/cookie-helper"); - - return { - __esModule: true, - ...originalModule, - regenerateDeviceId: jest.fn(), - regenerateUserId: jest.fn(), - }; -}); describe("analyticsMixin.js", () => { + beforeEach(() => { + setupCrypto(); + }); + test("logPageView: calls dispatch with type and payload", async () => { const type = ""; const payload = {}; From 9b9001d67a36b9f00fc0302fe6b3f0394a448eed Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 18:06:12 -0500 Subject: [PATCH 12/16] Tests for initsession --- src/mixins/analytics-mixin.spec.js | 133 ++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 3 deletions(-) diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index 7e04215af..567d9154e 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -1,5 +1,10 @@ import analyticsMixin from "@/mixins/analytics-mixin"; -import { setupMocksForJsFiles, setupCookies, setupCrypto } from "@/helpers/unit-test-helper.js"; +import { + setupMocksForJsFiles, + setupCookies, + setupCrypto, + removeAllTestCookies, +} from "@/helpers/unit-test-helper.js"; import { storeActions } from "@/constants/store-actions"; import { analyticsPageEvents, @@ -10,11 +15,17 @@ import { ValueToLogTypes, } from "@/constants/analytics"; import store from "@/store"; - +import { + getDeviceIdValue, + getSessionIdValue, + getSessionKeyValue, + getUserIdValue, +} from "@/helpers/heritage-integration/cookie-helper"; describe("analyticsMixin.js", () => { beforeEach(() => { - setupCrypto(); + removeAllTestCookies(); + setupCrypto("7e4727f3-9a3d-4c59-9cb3-6f4121b5ea94"); }); test("logPageView: calls dispatch with type and payload", async () => { @@ -341,4 +352,120 @@ describe("analyticsMixin.js", () => { //Assert expect(gaLabels).toEqual(GaLabels); }); + describe("initSession", () => { + test("Generates random values for userId and deviceId if not present", async () => { + // Arrange + const mockData = { + actionList: [ + { + actionName: storeActions.LOG_CUSTOM_EVENT, + }, + { + actionName: storeActions.INITIALIZE_SESSION, + data: { + sessionKey: "12345", + sessionId: "4f1eba4a-4dd5-4144-9a6b-1363c1e5e54f", + }, + }, + ], + }; + const mocks = setupMocksForJsFiles(mockData); + + // Act + await analyticsMixin.methods.initSession(); + const userId = getUserIdValue(); + const deviceId = getDeviceIdValue(); + + // Assert + expect(userId).not.toBe("00000000-0000-0000-0000-000000000000"); + expect(deviceId).not.toBe("00000000-0000-0000-0000-000000000000"); + }); + + test("Pulls sessionId and sessionKey from api if not set", async () => { + // Arrange + const mockData = { + actionList: [ + { + actionName: storeActions.LOG_CUSTOM_EVENT, + }, + { + actionName: storeActions.INITIALIZE_SESSION, + data: { + sessionKey: "54321", + sessionId: "4f1eba4a-4dd5-4144-9a6b-1363c1e5e54f", + }, + }, + ], + }; + const mocks = setupMocksForJsFiles(mockData); + + // Act + await analyticsMixin.methods.initSession(); + const sessionId = getSessionIdValue(); + const sessionKey = getSessionKeyValue(); + + // Assert + expect(sessionId).toBe("4f1eba4a-4dd5-4144-9a6b-1363c1e5e54f"); + expect(sessionKey).toBe("54321"); + }); + + test("Does not overwrite values that are already set", async () => { + // Arrange + const mockData = { + actionList: [ + { + actionName: storeActions.LOG_CUSTOM_EVENT, + }, + { + actionName: storeActions.INITIALIZE_SESSION, + data: { + sessionKey: "54321", + sessionId: "4f1eba4a-4dd5-4144-9a6b-1363c1e5e54f", + }, + }, + ], + }; + const mocks = setupMocksForJsFiles(mockData); + setupCookies({}); + + // Act + await analyticsMixin.methods.initSession(); + + const userId = getUserIdValue(); + const deviceId = getDeviceIdValue(); + const sessionId = getSessionIdValue(); + const sessionKey = getSessionKeyValue(); + + // Assert + expect(userId).toBe("11aec5e8-92ba-4dc9-a8b6-179a916d8d7a"); + expect(deviceId).toBe("21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe"); + expect(sessionId).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27"); + expect(sessionKey).toBe("12345"); + }); + + test("Calls dispatchStoreAction", async () => { + // Arrange + const mockData = { + actionList: [ + { + actionName: storeActions.LOG_CUSTOM_EVENT, + }, + { + actionName: storeActions.INITIALIZE_SESSION, + data: { + sessionKey: "12345", + sessionId: "4f1eba4a-4dd5-4144-9a6b-1363c1e5e54f", + }, + }, + ], + }; + const mocks = setupMocksForJsFiles(mockData); + + // Act + await analyticsMixin.methods.initSession(); + + // Assert + expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled(); + }); + }); }); From be4524e5adf464647da408c3a5955a42ff9de21c Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 6 Dec 2023 10:19:11 -0500 Subject: [PATCH 13/16] Loader tests --- src/ux-components/loader/loader.spec.js | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/ux-components/loader/loader.spec.js b/src/ux-components/loader/loader.spec.js index fb1eea21e..d56c4e0ed 100644 --- a/src/ux-components/loader/loader.spec.js +++ b/src/ux-components/loader/loader.spec.js @@ -28,4 +28,58 @@ describe("loader.vue", () => { loaderPosition: "left", }); }); + + describe("Blocking interaction on page", () => { + test("Does capture clicks if enabled (default)", async () => { + // Arrange + const div = document.createElement("div"); + div.id = "parent"; + document.body.appendChild(div); + + const parentClickFn = jest.fn(); + + div.addEventListener("click", parentClickFn); + + const wrapper = shallowMount(loader, { + props: {}, + attachTo: "#parent", + }); + + // Act + await wrapper.trigger("click"); + + // Assert + expect(parentClickFn).not.toBeCalled(); + + // Cleanup + document.body.removeChild(div); + }); + + test("Does not capture clicks if disabled", async () => { + // Arrange + const div = document.createElement("div"); + div.id = "parent"; + document.body.appendChild(div); + + const parentClickFn = jest.fn(); + + div.addEventListener("click", parentClickFn); + + const wrapper = shallowMount(loader, { + props: { + allowPageInteraction: true, + }, + attachTo: "#parent", + }); + + // Act + await wrapper.trigger("click"); + + // Assert + expect(parentClickFn).toBeCalled(); + + // Cleanup + document.body.removeChild(div); + }); + }); }); From 8b7229608c37aef4894db7fabb864a559a508ab2 Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Wed, 6 Dec 2023 10:37:18 -0500 Subject: [PATCH 14/16] CSR-1729 add label copy for textarea. --- .../textarea-question/textarea-question.vue | 33 +++++++++++-------- .../customer-details/customer-details.vue | 1 + 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/digital-components/textarea-question/textarea-question.vue b/src/digital-components/textarea-question/textarea-question.vue index eda3a6f9c..27eeda216 100644 --- a/src/digital-components/textarea-question/textarea-question.vue +++ b/src/digital-components/textarea-question/textarea-question.vue @@ -1,12 +1,13 @@ -