Merge branch 'develop' into SSR-1160-add-desktop-functionality
This commit is contained in:
commit
c5c5b05f46
10 changed files with 301 additions and 275 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import applicationConfig from '@/constants/application-config.js';
|
import applicationConfig from '@/constants/application-config.js';
|
||||||
|
import { convertToSeconds } from '@/helpers/date-helper.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module cookieNames
|
* @module cookieNames
|
||||||
|
|
@ -8,6 +9,8 @@ import applicationConfig from '@/constants/application-config.js';
|
||||||
*/
|
*/
|
||||||
const cookieNames = Object.freeze({
|
const cookieNames = Object.freeze({
|
||||||
ISS_SESSION_INFO: `ISSSessionInfo-${applicationConfig.CURRENT_ENVIRONMENT}`,
|
ISS_SESSION_INFO: `ISSSessionInfo-${applicationConfig.CURRENT_ENVIRONMENT}`,
|
||||||
|
ISS_SESSION_KEY: `ISSSessionKey-${applicationConfig.CURRENT_ENVIRONMENT}`,
|
||||||
|
ISS_USER_ID: `ISSUserId-${applicationConfig.CURRENT_ENVIRONMENT}`,
|
||||||
|
|
||||||
// Existing Safelite.com cookies
|
// Existing Safelite.com cookies
|
||||||
DXDEV: 'dxdev',
|
DXDEV: 'dxdev',
|
||||||
|
|
@ -15,4 +18,11 @@ const cookieNames = Object.freeze({
|
||||||
SESSION_KEY: 'skey'
|
SESSION_KEY: 'skey'
|
||||||
});
|
});
|
||||||
|
|
||||||
export default cookieNames;
|
const cookieExpirations = Object.freeze({
|
||||||
|
SESSION_ID: convertToSeconds({ minutes: 30 }),
|
||||||
|
DXDEV: convertToSeconds({ years: 1 }),
|
||||||
|
ISS_USER_ID: convertToSeconds({ weeks: 1 }),
|
||||||
|
ISS_SESSION_KEY: convertToSeconds({ minutes: 30 })
|
||||||
|
});
|
||||||
|
|
||||||
|
export { cookieNames, cookieExpirations };
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import cookieNames from '@/constants/cookie-names';
|
import { cookieNames, cookieExpirations } from '@/constants/cookie-names';
|
||||||
import applicationConfig from '@/constants/application-config';
|
import applicationConfig from '@/constants/application-config';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
|
|
@ -206,3 +206,85 @@ export function setCookieProperties(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isCookieSet(name) {
|
||||||
|
const val = getCookieValueByName(name);
|
||||||
|
|
||||||
|
return !!val;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function regenerateDeviceId() {
|
||||||
|
if (!isCookieSet(cookieNames.DXDEV)) {
|
||||||
|
setCookieProperties(
|
||||||
|
{
|
||||||
|
[cookieNames.DXDEV]: `did=${crypto.randomUUID()}`
|
||||||
|
},
|
||||||
|
{ maxAge: cookieExpirations.DXDEV }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function regenerateUserId() {
|
||||||
|
if (!isCookieSet(cookieNames.ISS_USER_ID)) {
|
||||||
|
setCookieProperties(
|
||||||
|
{
|
||||||
|
[cookieNames.ISS_USER_ID]: crypto.randomUUID()
|
||||||
|
},
|
||||||
|
{ maxAge: cookieExpirations.ISS_USER_ID }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserIdValue() {
|
||||||
|
const cookieValue = getCookieValueByName(cookieNames.ISS_USER_ID);
|
||||||
|
|
||||||
|
if (cookieValue) {
|
||||||
|
return cookieValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '00000000-0000-0000-0000-000000000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function areAllSessionCookiesSet() {
|
||||||
|
return (
|
||||||
|
isCookieSet(cookieNames.SESSION_ID)
|
||||||
|
&& isCookieSet(cookieNames.DXDEV)
|
||||||
|
&& isCookieSet(cookieNames.ISS_SESSION_KEY)
|
||||||
|
&& isCookieSet(cookieNames.ISS_USER_ID)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function refreshCookieExpiration(name, expirationTime) {
|
||||||
|
if (isCookieSet(name)) {
|
||||||
|
createOrUpdateCookie(name, getCookieValueByName(name), { maxAge: expirationTime });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function refreshSessionExpiration() {
|
||||||
|
refreshCookieExpiration(cookieNames.SESSION_ID, cookieExpirations.SESSION_ID);
|
||||||
|
refreshCookieExpiration(cookieNames.DXDEV, cookieExpirations.DXDEV);
|
||||||
|
refreshCookieExpiration(cookieNames.ISS_USER_ID, cookieExpirations.ISS_USER_ID);
|
||||||
|
refreshCookieExpiration(cookieNames.ISS_SESSION_KEY, cookieExpirations.ISS_SESSION_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setSessionIdIfUnset(value) {
|
||||||
|
if (!isCookieSet(cookieNames.SESSION_ID)) {
|
||||||
|
setCookieProperties(
|
||||||
|
{
|
||||||
|
[cookieNames.SESSION_ID]: value
|
||||||
|
},
|
||||||
|
{ maxAge: cookieExpirations.SESSION_ID }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setSessionKeyIfUnset(value) {
|
||||||
|
if (!isCookieSet(cookieNames.ISS_SESSION_KEY)) {
|
||||||
|
setCookieProperties(
|
||||||
|
{
|
||||||
|
[cookieNames.ISS_SESSION_KEY]: value
|
||||||
|
},
|
||||||
|
{ maxAge: cookieExpirations.ISS_SESSION_KEY }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,3 +173,15 @@ export function shortTimeString(date) {
|
||||||
// Return undefined if the input is not a valid date object
|
// Return undefined if the input is not a valid date object
|
||||||
? date.toLocaleTimeString('en-us', { hour: 'numeric', minute: 'numeric', hour12: true }) : undefined;
|
? date.toLocaleTimeString('en-us', { hour: 'numeric', minute: 'numeric', hour12: true }) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertToSeconds({ years, months, weeks, days, hours, minutes, seconds }) {
|
||||||
|
let total = seconds ?? 0;
|
||||||
|
total += (minutes ?? 0) * 60;
|
||||||
|
total += (hours ?? 0) * 60 * 60;
|
||||||
|
total += (days ?? 0) * 24 * 60 * 60;
|
||||||
|
total += (weeks ?? 0) * 7 * 24 * 60 * 60;
|
||||||
|
total += (months ?? 0) * 30 * 24 * 60 * 60;
|
||||||
|
total += (years ?? 0) * 365 * 24 * 60 * 60;
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { createTestingPinia } from '@pinia/testing';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import vehicleCategories from '@/constants/vehicle-categories.js';
|
import vehicleCategories from '@/constants/vehicle-categories.js';
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import cookieNames from '@/constants/cookie-names';
|
import { cookieNames } from '@/constants/cookie-names';
|
||||||
import { Form } from 'vee-validate';
|
import { Form } from 'vee-validate';
|
||||||
import baseMixin from '@/mixins/base-mixin';
|
import baseMixin from '@/mixins/base-mixin';
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,49 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import { getRandomString } from '@/helpers/data-generation.js';
|
import { getRandomString } from '@/helpers/data-generation.js';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
|
|
||||||
|
// Mock fetchCmsContentForPage
|
||||||
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
doesCopyContainRouterLink: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock our module for promises.
|
||||||
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRunAfterInitializingStore = () => {}) {
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const testingPinia = createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
});
|
||||||
|
useMainStore(testingPinia);
|
||||||
|
methodToRunAfterInitializingStore();
|
||||||
|
|
||||||
|
mountOptions.global.plugins = [testingPinia];
|
||||||
|
mountOptions.data = () => (initialData);
|
||||||
|
|
||||||
|
const apiResponses = { cmsContent: {} };
|
||||||
|
|
||||||
|
settleAllPromises.mockImplementation(() => apiResponses);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {});
|
||||||
|
wrapper.vm.setCmsContent = jest.fn();
|
||||||
|
wrapper.vm.$router.navigateWithSpinner = jest.fn();
|
||||||
|
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||||
|
|
||||||
|
return { wrapper };
|
||||||
|
}
|
||||||
|
|
||||||
const duplicateOrderText = 'Finish Existing Claim';
|
const duplicateOrderText = 'Finish Existing Claim';
|
||||||
|
|
||||||
|
|
@ -60,56 +103,30 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('duplicateOrders computed', () => {
|
describe('duplicateOrders computed', () => {
|
||||||
test('duplicateOrders in store undefined => returns empty list', () => {
|
test('duplicateOrders in store undefined => returns empty list', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: undefined
|
duplicateOrders: undefined
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||||
});
|
});
|
||||||
test('duplicateOrders in store empty => returns empty list', () => {
|
test('duplicateOrders in store empty => returns empty list', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: []
|
duplicateOrders: []
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -117,19 +134,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: getRandomString(5, 5),
|
vehicleMake: getRandomString(5, 5),
|
||||||
vehicleModel: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
responseDate: '1990-09-23T01:12:34',
|
responseDate: '1990-09-23T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(5, 5)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '9/23/1990';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '9/23/1990';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -137,17 +149,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -155,19 +163,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: null,
|
vehicleMake: null,
|
||||||
vehicleModel: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
responseDate: '2004-11-01T01:12:34',
|
responseDate: '2004-11-01T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '11/1/2004';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '11/1/2004';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -175,17 +178,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -193,19 +192,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: getRandomString(6, 6),
|
vehicleMake: getRandomString(6, 6),
|
||||||
vehicleModel: null,
|
vehicleModel: null,
|
||||||
responseDate: '1999-01-15T01:12:34',
|
responseDate: '1999-01-15T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '1/15/1999';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '1/15/1999';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -213,17 +207,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -231,28 +221,23 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: 'make',
|
vehicleMake: 'make',
|
||||||
vehicleModel: 'MoDel',
|
vehicleModel: 'MoDel',
|
||||||
responseDate: '2018-03-01T01:12:34',
|
responseDate: '2018-03-01T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedVehicle = 'Year Make Model';
|
const expectedVehicle = 'Year Make Model';
|
||||||
const expectedDate = '3/1/2018';
|
const expectedDate = '3/1/2018';
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: `${expectedVehicle}, ${expectedDate}`,
|
SubText: `${expectedVehicle}, ${expectedDate}`,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -336,11 +321,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
test('Back button clicked triggers navigation', () => {
|
test('Back button clicked triggers navigation', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(duplicateCheck, getMountOptions({
|
|
||||||
router: {
|
const { wrapper } = getMountedComponent({});
|
||||||
navigateWithSpinner: jest.fn()
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -355,21 +337,22 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('forwardButtonAction', () => {
|
describe('forwardButtonAction', () => {
|
||||||
test('Selected duplicate => load session called', async () => {
|
test('Selected duplicate => load session called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const selectedAnswer = getRandomString(6, 6);
|
||||||
const selectedAnswer = {};
|
const { wrapper } = getMountedComponent({
|
||||||
|
applicationUser: {
|
||||||
const mountOptions = getMountOptions({
|
duplicateOrders: [
|
||||||
router: { navigate: jest.fn() }
|
{
|
||||||
});
|
vehicleYear: 'YEAR',
|
||||||
mountOptions.mixins = [{
|
vehicleMake: 'make',
|
||||||
methods: {
|
vehicleModel: 'MoDel',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
responseDate: '2018-03-01T01:12:34',
|
||||||
? [{ Name: newOrderSelectionName }]
|
referralNumber: getRandomString(6, 6),
|
||||||
: ''))
|
correlationId: selectedAnswer
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer });
|
wrapper.setData({ selectedAnswer });
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
|
||||||
|
|
@ -383,19 +366,21 @@ describe('duplicateCheck.vue', () => {
|
||||||
test('Selected new order => load session not called', async () => {
|
test('Selected new order => load session not called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const newOrderSelectionName = getRandomString(6, 6);
|
||||||
|
const { wrapper } = getMountedComponent({
|
||||||
const mountOptions = getMountOptions({
|
applicationUser: {
|
||||||
router: { navigate: jest.fn() }
|
duplicateOrders: [
|
||||||
});
|
{
|
||||||
mountOptions.mixins = [{
|
vehicleYear: 'YEAR',
|
||||||
methods: {
|
vehicleMake: 'make',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
vehicleModel: 'MoDel',
|
||||||
? [{ Name: newOrderSelectionName }]
|
responseDate: '2018-03-01T01:12:34',
|
||||||
: ''))
|
referralNumber: getRandomString(6, 6),
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer: newOrderSelectionName });
|
wrapper.setData({ selectedAnswer: newOrderSelectionName });
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
|
||||||
|
|
@ -408,21 +393,22 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('Load session throws error => still navigate forward', async () => {
|
test('Load session throws error => still navigate forward', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const selectedAnswer = getRandomString(6, 6);
|
||||||
const selectedAnswer = {};
|
const { wrapper } = getMountedComponent({
|
||||||
|
applicationUser: {
|
||||||
const mountOptions = getMountOptions({
|
duplicateOrders: [
|
||||||
router: { navigate: jest.fn() }
|
{
|
||||||
});
|
vehicleYear: 'YEAR',
|
||||||
mountOptions.mixins = [{
|
vehicleMake: 'make',
|
||||||
methods: {
|
vehicleModel: 'MoDel',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
responseDate: '2018-03-01T01:12:34',
|
||||||
? [{ Name: newOrderSelectionName }]
|
referralNumber: getRandomString(6, 6),
|
||||||
: ''))
|
correlationId: selectedAnswer
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer });
|
wrapper.setData({ selectedAnswer });
|
||||||
const error = 'load session error';
|
const error = 'load session error';
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||||
|
|
@ -436,25 +422,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
vehicles: [{ test: 'a' }]
|
vehicles: [{ test: 'a' }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -466,25 +441,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
vehicles: []
|
vehicles: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -496,24 +460,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: false
|
policyLookupSuccessful: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -523,14 +476,11 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -541,14 +491,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -558,14 +501,11 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -576,14 +516,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -593,13 +526,10 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -610,14 +540,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,10 @@ export default {
|
||||||
vm.setCmsContent(cmsContent);
|
vm.setCmsContent(cmsContent);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setup() {
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
return { mainStore };
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedAnswer: null,
|
selectedAnswer: null,
|
||||||
|
|
@ -110,31 +114,25 @@ export default {
|
||||||
},
|
},
|
||||||
duplicateOrders() {
|
duplicateOrders() {
|
||||||
const duplicateOrderText = 'Finish Existing Claim';
|
const duplicateOrderText = 'Finish Existing Claim';
|
||||||
const orders = useMainStore().applicationUser.duplicateOrders;
|
const orders = this.mainStore.applicationUser.duplicateOrders;
|
||||||
return (
|
return orders?.map((o) => {
|
||||||
orders?.map((o) => {
|
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||||
const vehicle =
|
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||||
!!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
: null;
|
||||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const dateOfLoss =
|
const dateOfLoss = o.responseDate == null ? '' : new Date(o.responseDate).toLocaleDateString();
|
||||||
o.responseDate == null
|
const subtext = vehicle && o.responseDate
|
||||||
? ''
|
? `${vehicle}, ${dateOfLoss}`
|
||||||
: new Date(o.responseDate).toLocaleDateString();
|
: (vehicle ?? '').concat(dateOfLoss);
|
||||||
const subtext =
|
|
||||||
vehicle && o.responseDate
|
|
||||||
? `${vehicle}, ${dateOfLoss}`
|
|
||||||
: (vehicle ?? '').concat(dateOfLoss);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: o.referralNumber,
|
Name: o.referralNumber,
|
||||||
SubText: toTitleCase(subtext),
|
SubText: toTitleCase(subtext),
|
||||||
value: o,
|
value: o.correlationId
|
||||||
};
|
};
|
||||||
}) ?? []
|
}) ?? [];
|
||||||
);
|
},
|
||||||
},
|
},
|
||||||
answers() {
|
answers() {
|
||||||
return [...this.duplicateOrders, ...this.answersFromCms];
|
return [...this.duplicateOrders, ...this.answersFromCms];
|
||||||
|
|
@ -145,17 +143,16 @@ export default {
|
||||||
* @summary Steps to perform when forward button clicked.
|
* @summary Steps to perform when forward button clicked.
|
||||||
*/
|
*/
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (
|
if (this.selectedAnswer !== null) {
|
||||||
this.selectedAnswer !== null &&
|
const selectedReferral = this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||||
typeof this.selectedAnswer === 'object'
|
if (selectedReferral) {
|
||||||
) {
|
await this.mainStore.loadSession(selectedReferral)
|
||||||
await useMainStore()
|
.catch(() => {})
|
||||||
.loadSession(this.selectedAnswer)
|
.finally(() => {
|
||||||
.catch(() => {})
|
this.navigateForward();
|
||||||
.finally(() => {
|
});
|
||||||
this.navigateForward();
|
return;
|
||||||
});
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.navigateForward();
|
this.navigateForward();
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
class="appointment-text text-center lh-base mt-2"
|
class="appointment-text text-center lh-base mt-2"
|
||||||
v-html="appointmentWordingText2"></div>
|
v-html="appointmentWordingText2"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<hr class="mb-0" />
|
||||||
<div>
|
<div>
|
||||||
<cartDropdown
|
<cartDropdown
|
||||||
:showAsPaid="isPayInAdvance"
|
:showAsPaid="isPayInAdvance"
|
||||||
|
|
@ -57,6 +58,7 @@
|
||||||
servicePackageTitleWidgetName="ServicePackageTitle"
|
servicePackageTitleWidgetName="ServicePackageTitle"
|
||||||
:submittedOrder="submittedOrder" />
|
:submittedOrder="submittedOrder" />
|
||||||
</div>
|
</div>
|
||||||
|
<hr class="mt-0 mb-5" />
|
||||||
<div
|
<div
|
||||||
class="email-confirmation-text"
|
class="email-confirmation-text"
|
||||||
v-html="confirmationEmailText" />
|
v-html="confirmationEmailText" />
|
||||||
|
|
@ -494,7 +496,7 @@ $page-side-padding: 1.5rem;
|
||||||
.email-confirmation-text {
|
.email-confirmation-text {
|
||||||
:deep(a) {
|
:deep(a) {
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
text-decoration: none;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
:deep(strong) {
|
:deep(strong) {
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
|
/* eslint-disable import/no-cycle */
|
||||||
import {
|
import {
|
||||||
setCookieProperties,
|
areAllSessionCookiesSet,
|
||||||
getDeviceIdValue,
|
getDeviceIdValue,
|
||||||
getSessionIdValue,
|
getSessionIdValue,
|
||||||
getSessionKeyValue
|
getSessionKeyValue,
|
||||||
|
getUserIdValue,
|
||||||
|
regenerateUserId,
|
||||||
|
regenerateDeviceId,
|
||||||
|
setSessionIdIfUnset,
|
||||||
|
setSessionKeyIfUnset
|
||||||
} from '@/helpers/cookie-helper';
|
} from '@/helpers/cookie-helper';
|
||||||
|
import applicationConfig from '@/constants/application-config';
|
||||||
import queryStrings from '@/constants/query-strings';
|
import queryStrings from '@/constants/query-strings';
|
||||||
import { experimentSettings } from '@/constants/experiments';
|
import { experimentSettings } from '@/constants/experiments';
|
||||||
import {
|
import {
|
||||||
|
|
@ -14,7 +21,6 @@ import {
|
||||||
GaEvents,
|
GaEvents,
|
||||||
ValueToLogTypes
|
ValueToLogTypes
|
||||||
} from '@/constants/analytics';
|
} from '@/constants/analytics';
|
||||||
import cookieNames from '@/constants/cookie-names';
|
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
function pushToDataLayerIfDefined(data) {
|
function pushToDataLayerIfDefined(data) {
|
||||||
|
|
@ -151,42 +157,36 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async initSession() {
|
async initSession() {
|
||||||
const sid = getSessionIdValue();
|
regenerateDeviceId();
|
||||||
const skey = getSessionKeyValue();
|
regenerateUserId();
|
||||||
|
|
||||||
|
const deviceId = getDeviceIdValue(); // cookieNames.DXDEV
|
||||||
|
const userId = getUserIdValue(); // cookieNames.ISS_USER_ID
|
||||||
|
const sid = getSessionIdValue(); // cookieNames.SESSION_ID
|
||||||
|
// const skey = getSessionKeyValue();
|
||||||
|
const referrer = applicationConfig.CURRENT_ENVIRONMENT !== 'Localhost' ? document.referrer : null;
|
||||||
const payload = {
|
const payload = {
|
||||||
userId: getDeviceIdValue(),
|
deviceId,
|
||||||
|
referrer,
|
||||||
sessionId: sid,
|
sessionId: sid,
|
||||||
userAgent: navigator.userAgent,
|
userId,
|
||||||
referrer: document.referrer
|
userAgent: navigator.userAgent
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await useMainStore().initializeSession(payload);
|
const response = await useMainStore().initializeSession(payload);
|
||||||
|
|
||||||
if (response?.data) {
|
if (response?.data) {
|
||||||
if (response?.data.sessionKey && skey === 0) {
|
if (response?.data.sessionKey) {
|
||||||
setCookieProperties(
|
setSessionKeyIfUnset(response.data.sessionKey);
|
||||||
{ [cookieNames.SESSION_KEY]: response?.data.sessionKey },
|
|
||||||
{
|
|
||||||
useDefaultFunnelCookieAttributes: false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (response?.data.sessionId && sid === '00000000-0000-0000-0000-000000000000') {
|
if (response?.data.sessionId) {
|
||||||
setCookieProperties(
|
setSessionIdIfUnset(response.data.sessionId);
|
||||||
{ [cookieNames.SESSION_ID]: response?.data.sessionId },
|
|
||||||
{
|
|
||||||
maxAge: 60 * 30 // 30 minutes
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
noSession() {
|
noSession() {
|
||||||
return (
|
return !areAllSessionCookiesSet();
|
||||||
getSessionKeyValue() === 0
|
|
||||||
|| getSessionIdValue() === '00000000-0000-0000-0000-000000000000'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
|
|
@ -1342,7 +1342,7 @@ export const useMainStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadSession(duplicate) {
|
async loadSession(duplicate) {
|
||||||
const { applicationUser, order, issConfig } = this;
|
const { order, issConfig } = this;
|
||||||
try {
|
try {
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
method: endpoints.LoadSession.method,
|
method: endpoints.LoadSession.method,
|
||||||
|
|
@ -1351,7 +1351,7 @@ export const useMainStore = defineStore({
|
||||||
referralNumber: duplicate.referralNumber,
|
referralNumber: duplicate.referralNumber,
|
||||||
referralDate: duplicate.responseDate,
|
referralDate: duplicate.responseDate,
|
||||||
parentAccountNumber: issConfig.parentAccountNumber,
|
parentAccountNumber: issConfig.parentAccountNumber,
|
||||||
referralCorrelationId: duplicate.referralCorrelationId
|
referralCorrelationId: duplicate.correlationId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
|
|
@ -1374,8 +1374,8 @@ export const useMainStore = defineStore({
|
||||||
order.contactInfo.firstName = data?.customer?.firstName;
|
order.contactInfo.firstName = data?.customer?.firstName;
|
||||||
order.contactInfo.lastName = data?.customer?.lastName;
|
order.contactInfo.lastName = data?.customer?.lastName;
|
||||||
order.contactInfo.emailAddress = data?.customer?.emailAddress;
|
order.contactInfo.emailAddress = data?.customer?.emailAddress;
|
||||||
order.contactInfo.homePhone = data?.customer?.phoneNumber;
|
order.contactInfo.homePhone = data?.customer?.homePhone;
|
||||||
order.contactInfo.servicephone = data?.customer?.phoneNumber;
|
order.contactInfo.servicephone = data?.customer?.homePhone;
|
||||||
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
||||||
|
|
||||||
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
|
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
|
||||||
|
|
|
||||||
|
|
@ -1149,7 +1149,7 @@ describe('Store', () => {
|
||||||
expect(store.order.customer.firstName).toBe(customer.firstName);
|
expect(store.order.customer.firstName).toBe(customer.firstName);
|
||||||
expect(store.order.customer.lastName).toBe(customer.lastName);
|
expect(store.order.customer.lastName).toBe(customer.lastName);
|
||||||
expect(store.order.customer.emailAddress).toBe(customer.emailAddress);
|
expect(store.order.customer.emailAddress).toBe(customer.emailAddress);
|
||||||
expect(store.order.contactInfo.homePhone).toBe(customer.phoneNumber);
|
expect(store.order.contactInfo.homePhone).toBe(customer.homePhone);
|
||||||
});
|
});
|
||||||
it('sets expected remaining order data', async () => {
|
it('sets expected remaining order data', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue