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 { convertToSeconds } from '@/helpers/date-helper.js';
|
||||
|
||||
/**
|
||||
* @module cookieNames
|
||||
|
|
@ -8,6 +9,8 @@ import applicationConfig from '@/constants/application-config.js';
|
|||
*/
|
||||
const cookieNames = Object.freeze({
|
||||
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
|
||||
DXDEV: 'dxdev',
|
||||
|
|
@ -15,4 +18,11 @@ const cookieNames = Object.freeze({
|
|||
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 { 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
|
||||
? 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 vehicleCategories from '@/constants/vehicle-categories.js';
|
||||
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 baseMixin from '@/mixins/base-mixin';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,49 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
|||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||
import { getRandomString } from '@/helpers/data-generation.js';
|
||||
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';
|
||||
|
||||
|
|
@ -60,56 +103,30 @@ describe('duplicateCheck.vue', () => {
|
|||
describe('duplicateOrders computed', () => {
|
||||
test('duplicateOrders in store undefined => returns empty list', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: undefined
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||
});
|
||||
test('duplicateOrders in store empty => returns empty list', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: []
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||
});
|
||||
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
|
|
@ -117,19 +134,14 @@ describe('duplicateCheck.vue', () => {
|
|||
vehicleMake: getRandomString(5, 5),
|
||||
vehicleModel: getRandomString(5, 5),
|
||||
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
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||
|
|
@ -137,17 +149,13 @@ describe('duplicateCheck.vue', () => {
|
|||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
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', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
|
|
@ -155,19 +163,14 @@ describe('duplicateCheck.vue', () => {
|
|||
vehicleMake: null,
|
||||
vehicleModel: getRandomString(5, 5),
|
||||
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
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||
|
|
@ -175,17 +178,13 @@ describe('duplicateCheck.vue', () => {
|
|||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
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', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
|
|
@ -193,19 +192,14 @@ describe('duplicateCheck.vue', () => {
|
|||
vehicleMake: getRandomString(6, 6),
|
||||
vehicleModel: null,
|
||||
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
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||
|
|
@ -213,17 +207,13 @@ describe('duplicateCheck.vue', () => {
|
|||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
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', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
|
|
@ -231,28 +221,23 @@ describe('duplicateCheck.vue', () => {
|
|||
vehicleMake: 'make',
|
||||
vehicleModel: 'MoDel',
|
||||
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 expectedDate = '3/1/2018';
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||
Text: duplicateOrderText,
|
||||
Name: referralNumber,
|
||||
SubText: `${expectedVehicle}, ${expectedDate}`,
|
||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -336,11 +321,8 @@ describe('duplicateCheck.vue', () => {
|
|||
describe('Navigation', () => {
|
||||
test('Back button clicked triggers navigation', () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(duplicateCheck, getMountOptions({
|
||||
router: {
|
||||
navigateWithSpinner: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
const { wrapper } = getMountedComponent({});
|
||||
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||
|
||||
// Act
|
||||
|
|
@ -355,21 +337,22 @@ describe('duplicateCheck.vue', () => {
|
|||
describe('forwardButtonAction', () => {
|
||||
test('Selected duplicate => load session called', async () => {
|
||||
// Arrange
|
||||
const newOrderSelectionName = getRandomString(6, 6);
|
||||
const selectedAnswer = {};
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
mountOptions.mixins = [{
|
||||
methods: {
|
||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
||||
? [{ Name: newOrderSelectionName }]
|
||||
: ''))
|
||||
const selectedAnswer = getRandomString(6, 6);
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
vehicleYear: 'YEAR',
|
||||
vehicleMake: 'make',
|
||||
vehicleModel: 'MoDel',
|
||||
responseDate: '2018-03-01T01:12:34',
|
||||
referralNumber: getRandomString(6, 6),
|
||||
correlationId: selectedAnswer
|
||||
}
|
||||
]
|
||||
}
|
||||
}];
|
||||
});
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
wrapper.setData({ selectedAnswer });
|
||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
|
|
@ -383,19 +366,21 @@ describe('duplicateCheck.vue', () => {
|
|||
test('Selected new order => load session not called', async () => {
|
||||
// Arrange
|
||||
const newOrderSelectionName = getRandomString(6, 6);
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
mountOptions.mixins = [{
|
||||
methods: {
|
||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
||||
? [{ Name: newOrderSelectionName }]
|
||||
: ''))
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
vehicleYear: 'YEAR',
|
||||
vehicleMake: 'make',
|
||||
vehicleModel: 'MoDel',
|
||||
responseDate: '2018-03-01T01:12:34',
|
||||
referralNumber: getRandomString(6, 6),
|
||||
correlationId: getRandomString(6, 6)
|
||||
}
|
||||
]
|
||||
}
|
||||
}];
|
||||
});
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
wrapper.setData({ selectedAnswer: newOrderSelectionName });
|
||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
|
||||
|
|
@ -408,21 +393,22 @@ describe('duplicateCheck.vue', () => {
|
|||
});
|
||||
test('Load session throws error => still navigate forward', async () => {
|
||||
// Arrange
|
||||
const newOrderSelectionName = getRandomString(6, 6);
|
||||
const selectedAnswer = {};
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
mountOptions.mixins = [{
|
||||
methods: {
|
||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
||||
? [{ Name: newOrderSelectionName }]
|
||||
: ''))
|
||||
const selectedAnswer = getRandomString(6, 6);
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
vehicleYear: 'YEAR',
|
||||
vehicleMake: 'make',
|
||||
vehicleModel: 'MoDel',
|
||||
responseDate: '2018-03-01T01:12:34',
|
||||
referralNumber: getRandomString(6, 6),
|
||||
correlationId: selectedAnswer
|
||||
}
|
||||
]
|
||||
}
|
||||
}];
|
||||
});
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
wrapper.setData({ selectedAnswer });
|
||||
const error = 'load session 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 () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: [{ test: 'a' }]
|
||||
}
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
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 () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
vehicles: []
|
||||
}
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -496,24 +460,13 @@ describe('duplicateCheck.vue', () => {
|
|||
});
|
||||
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: false
|
||||
}
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -523,14 +476,11 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.$router.navigate)
|
||||
.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 () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const vin = getRandomString(17, 17);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
|
|
@ -541,14 +491,7 @@ describe('duplicateCheck.vue', () => {
|
|||
},
|
||||
loadedFromDupeCheck: true
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -558,14 +501,11 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.$router.navigate)
|
||||
.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 () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const vin = getRandomString(17, 17);
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
|
|
@ -576,14 +516,7 @@ describe('duplicateCheck.vue', () => {
|
|||
},
|
||||
loadedFromDupeCheck: true
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
@ -593,13 +526,10 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.$router.navigate)
|
||||
.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 () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
|
||||
const mainInitialState = {
|
||||
const { wrapper } = getMountedComponent({
|
||||
order: {
|
||||
policy: {
|
||||
policyLookupSuccessful: true,
|
||||
|
|
@ -610,14 +540,7 @@ describe('duplicateCheck.vue', () => {
|
|||
},
|
||||
loadedFromDupeCheck: true
|
||||
}
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
|
||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ export default {
|
|||
vm.setCmsContent(cmsContent);
|
||||
});
|
||||
},
|
||||
setup() {
|
||||
const mainStore = useMainStore();
|
||||
return { mainStore };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedAnswer: null,
|
||||
|
|
@ -110,31 +114,25 @@ export default {
|
|||
},
|
||||
duplicateOrders() {
|
||||
const duplicateOrderText = 'Finish Existing Claim';
|
||||
const orders = useMainStore().applicationUser.duplicateOrders;
|
||||
return (
|
||||
orders?.map((o) => {
|
||||
const vehicle =
|
||||
!!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||
: null;
|
||||
const orders = this.mainStore.applicationUser.duplicateOrders;
|
||||
return orders?.map((o) => {
|
||||
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||
: null;
|
||||
|
||||
const dateOfLoss =
|
||||
o.responseDate == null
|
||||
? ''
|
||||
: new Date(o.responseDate).toLocaleDateString();
|
||||
const subtext =
|
||||
vehicle && o.responseDate
|
||||
? `${vehicle}, ${dateOfLoss}`
|
||||
: (vehicle ?? '').concat(dateOfLoss);
|
||||
const dateOfLoss = o.responseDate == null ? '' : new Date(o.responseDate).toLocaleDateString();
|
||||
const subtext = vehicle && o.responseDate
|
||||
? `${vehicle}, ${dateOfLoss}`
|
||||
: (vehicle ?? '').concat(dateOfLoss);
|
||||
|
||||
return {
|
||||
Text: duplicateOrderText,
|
||||
Name: o.referralNumber,
|
||||
SubText: toTitleCase(subtext),
|
||||
value: o,
|
||||
};
|
||||
}) ?? []
|
||||
);
|
||||
return {
|
||||
Text: duplicateOrderText,
|
||||
Name: o.referralNumber,
|
||||
SubText: toTitleCase(subtext),
|
||||
value: o.correlationId
|
||||
};
|
||||
}) ?? [];
|
||||
},
|
||||
},
|
||||
answers() {
|
||||
return [...this.duplicateOrders, ...this.answersFromCms];
|
||||
|
|
@ -145,17 +143,16 @@ export default {
|
|||
* @summary Steps to perform when forward button clicked.
|
||||
*/
|
||||
async forwardButtonAction() {
|
||||
if (
|
||||
this.selectedAnswer !== null &&
|
||||
typeof this.selectedAnswer === 'object'
|
||||
) {
|
||||
await useMainStore()
|
||||
.loadSession(this.selectedAnswer)
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
this.navigateForward();
|
||||
});
|
||||
return;
|
||||
if (this.selectedAnswer !== null) {
|
||||
const selectedReferral = this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||
if (selectedReferral) {
|
||||
await this.mainStore.loadSession(selectedReferral)
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
this.navigateForward();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.navigateForward();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
class="appointment-text text-center lh-base mt-2"
|
||||
v-html="appointmentWordingText2"></div>
|
||||
</div>
|
||||
<hr class="mb-0" />
|
||||
<div>
|
||||
<cartDropdown
|
||||
:showAsPaid="isPayInAdvance"
|
||||
|
|
@ -57,6 +58,7 @@
|
|||
servicePackageTitleWidgetName="ServicePackageTitle"
|
||||
:submittedOrder="submittedOrder" />
|
||||
</div>
|
||||
<hr class="mt-0 mb-5" />
|
||||
<div
|
||||
class="email-confirmation-text"
|
||||
v-html="confirmationEmailText" />
|
||||
|
|
@ -494,7 +496,7 @@ $page-side-padding: 1.5rem;
|
|||
.email-confirmation-text {
|
||||
:deep(a) {
|
||||
font-weight: $font-weight-bold;
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
:deep(strong) {
|
||||
font-weight: $font-weight-bold;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
/* eslint-disable import/no-cycle */
|
||||
import {
|
||||
setCookieProperties,
|
||||
areAllSessionCookiesSet,
|
||||
getDeviceIdValue,
|
||||
getSessionIdValue,
|
||||
getSessionKeyValue
|
||||
getSessionKeyValue,
|
||||
getUserIdValue,
|
||||
regenerateUserId,
|
||||
regenerateDeviceId,
|
||||
setSessionIdIfUnset,
|
||||
setSessionKeyIfUnset
|
||||
} from '@/helpers/cookie-helper';
|
||||
import applicationConfig from '@/constants/application-config';
|
||||
import queryStrings from '@/constants/query-strings';
|
||||
import { experimentSettings } from '@/constants/experiments';
|
||||
import {
|
||||
|
|
@ -14,7 +21,6 @@ import {
|
|||
GaEvents,
|
||||
ValueToLogTypes
|
||||
} from '@/constants/analytics';
|
||||
import cookieNames from '@/constants/cookie-names';
|
||||
import { useMainStore } from '@/store';
|
||||
|
||||
function pushToDataLayerIfDefined(data) {
|
||||
|
|
@ -151,42 +157,36 @@ export default {
|
|||
},
|
||||
|
||||
async initSession() {
|
||||
const sid = getSessionIdValue();
|
||||
const skey = getSessionKeyValue();
|
||||
regenerateDeviceId();
|
||||
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 = {
|
||||
userId: getDeviceIdValue(),
|
||||
deviceId,
|
||||
referrer,
|
||||
sessionId: sid,
|
||||
userAgent: navigator.userAgent,
|
||||
referrer: document.referrer
|
||||
userId,
|
||||
userAgent: navigator.userAgent
|
||||
};
|
||||
|
||||
const response = await useMainStore().initializeSession(payload);
|
||||
|
||||
if (response?.data) {
|
||||
if (response?.data.sessionKey && skey === 0) {
|
||||
setCookieProperties(
|
||||
{ [cookieNames.SESSION_KEY]: response?.data.sessionKey },
|
||||
{
|
||||
useDefaultFunnelCookieAttributes: false
|
||||
}
|
||||
);
|
||||
if (response?.data.sessionKey) {
|
||||
setSessionKeyIfUnset(response.data.sessionKey);
|
||||
}
|
||||
if (response?.data.sessionId && sid === '00000000-0000-0000-0000-000000000000') {
|
||||
setCookieProperties(
|
||||
{ [cookieNames.SESSION_ID]: response?.data.sessionId },
|
||||
{
|
||||
maxAge: 60 * 30 // 30 minutes
|
||||
}
|
||||
);
|
||||
if (response?.data.sessionId) {
|
||||
setSessionIdIfUnset(response.data.sessionId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
noSession() {
|
||||
return (
|
||||
getSessionKeyValue() === 0
|
||||
|| getSessionIdValue() === '00000000-0000-0000-0000-000000000000'
|
||||
);
|
||||
return !areAllSessionCookiesSet();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
|||
|
|
@ -1342,7 +1342,7 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
async loadSession(duplicate) {
|
||||
const { applicationUser, order, issConfig } = this;
|
||||
const { order, issConfig } = this;
|
||||
try {
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.LoadSession.method,
|
||||
|
|
@ -1351,7 +1351,7 @@ export const useMainStore = defineStore({
|
|||
referralNumber: duplicate.referralNumber,
|
||||
referralDate: duplicate.responseDate,
|
||||
parentAccountNumber: issConfig.parentAccountNumber,
|
||||
referralCorrelationId: duplicate.referralCorrelationId
|
||||
referralCorrelationId: duplicate.correlationId
|
||||
}
|
||||
});
|
||||
const { data } = response;
|
||||
|
|
@ -1374,8 +1374,8 @@ export const useMainStore = defineStore({
|
|||
order.contactInfo.firstName = data?.customer?.firstName;
|
||||
order.contactInfo.lastName = data?.customer?.lastName;
|
||||
order.contactInfo.emailAddress = data?.customer?.emailAddress;
|
||||
order.contactInfo.homePhone = data?.customer?.phoneNumber;
|
||||
order.contactInfo.servicephone = data?.customer?.phoneNumber;
|
||||
order.contactInfo.homePhone = data?.customer?.homePhone;
|
||||
order.contactInfo.servicephone = data?.customer?.homePhone;
|
||||
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
||||
|
||||
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.lastName).toBe(customer.lastName);
|
||||
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 () => {
|
||||
// Arrange
|
||||
|
|
|
|||
Loading…
Reference in a new issue