diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js
index 1c8f51b7..068de8e1 100644
--- a/src/constants/endpoints.js
+++ b/src/constants/endpoints.js
@@ -162,6 +162,10 @@ const endpoints = Object.freeze({
url: '/order/api/v1/order/save-session/iss',
method: 'POST'
},
+ LoadSession: {
+ url: '/order/api/v1/order/load-session',
+ method: 'POST'
+ },
DuplicateSearch: {
// eslint-disable-next-line max-len
url: (accountNumber, policyNumber, phoneNumber) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${phoneNumber}`,
diff --git a/src/digital-components/date-picker/date-picker.vue b/src/digital-components/date-picker/date-picker.vue
index f30f9b7d..feaa430d 100644
--- a/src/digital-components/date-picker/date-picker.vue
+++ b/src/digital-components/date-picker/date-picker.vue
@@ -734,7 +734,11 @@ export default {
}
.loader {
height: 2rem;
- width: calc(100% - 1.5rem);
+ width: 100%;
+ display: flex;
+ justify-content: center;
+ transform: unset;
+ right: unset;
&::after {
width: 1.5rem;
diff --git a/src/helpers/text-helper.js b/src/helpers/text-helper.js
index 01d18309..d08e0c04 100644
--- a/src/helpers/text-helper.js
+++ b/src/helpers/text-helper.js
@@ -5,7 +5,21 @@
* @param {string} stringWithStyleTag
* @returns {string}
*/
-export default function stripRteStyle(stringWithStyleTag) {
+export function stripRteStyle(stringWithStyleTag) {
const regexExp = /[\s*]style="(.*?)"/g;
return stringWithStyleTag.replace(regexExp, '');
}
+
+/**
+ * @function toTitleCase
+ * @summary Returns title cased string version of 'text'
+ * @param {string} text
+ * @returns {string}
+ */
+export function toTitleCase(text) {
+ const temp = text.toLowerCase().split(' ');
+ for (let i = 0; i < temp.length; i++) {
+ temp[i] = temp[i].charAt(0).toUpperCase() + temp[i].slice(1);
+ }
+ return temp.join(' ');
+}
diff --git a/src/iss-components/site-sub-header/site-sub-header.vue b/src/iss-components/site-sub-header/site-sub-header.vue
index 2c998fb3..a26ea95f 100644
--- a/src/iss-components/site-sub-header/site-sub-header.vue
+++ b/src/iss-components/site-sub-header/site-sub-header.vue
@@ -36,7 +36,7 @@ import {
getRouterLinkHtmlStringFromCopy
} from '@/helpers/cms-content-helper';
-import stripRteStyle from '@/helpers/text-helper';
+import { stripRteStyle } from '@/helpers/text-helper';
export default {
name: 'site-sub-header',
diff --git a/src/layouts/contact-details/contact-details.spec.js b/src/layouts/contact-details/contact-details.spec.js
index c6938e58..0b133e22 100644
--- a/src/layouts/contact-details/contact-details.spec.js
+++ b/src/layouts/contact-details/contact-details.spec.js
@@ -1,11 +1,11 @@
// Components
+import { shallowMount } from '@vue/test-utils';
+import { createTestingPinia } from '@pinia/testing';
import contactDetails from '@/layouts/contact-details/contact-details.vue';
// Supporting Files
-import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
-import { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import { useMainStore } from '@/store/index.js';
@@ -267,9 +267,6 @@ describe('contactDetails.vue', () => {
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
- },
- global: {
- plugins: [createTestingPinia()]
}
});
const wrapper = shallowMount(contactDetails, mountOptions);
@@ -302,4 +299,89 @@ describe('contactDetails.vue', () => {
});
});
});
+
+ test('Mocked store with no contact info yields expected data', () => {
+ // Arrange
+ const mountOptions = getMountOptions();
+
+ const firstName = getRandomString(4, 15);
+ const lastName = getRandomString(4, 15);
+ const emailAddress = getRandomString(10, 20);
+ const phoneNumber = getRandomInt(1000000000, 9999999999);
+ const mainInitialState = {
+ order: {
+ customer: {
+ firstName,
+ lastName,
+ emailAddress,
+ phoneNumber
+ },
+ contactInfo: {
+ firstName: null,
+ lastName: null,
+ emailAddress: null,
+ phoneNumber: null,
+ requestTextUpdates: null,
+ notesForTechnician: null
+ }
+ }
+ };
+ mountOptions.global = {
+ plugins: [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })]
+ };
+
+ const wrapper = shallowMount(contactDetails, mountOptions);
+
+ // Assert
+ expect(wrapper.vm.firstName).toBe(firstName);
+ expect(wrapper.vm.lastName).toBe(lastName);
+ expect(wrapper.vm.emailAddress).toBe(emailAddress);
+ expect(wrapper.vm.phoneNumber).toBe(phoneNumber);
+ });
+
+ test('Mock store with contact info yields expected data', () => {
+ // Arrange
+ const customer = {
+ firstName: getRandomString(4, 15),
+ lastName: getRandomString(4, 15),
+ emailAddress: getRandomString(10, 20),
+ phoneNumber: getRandomInt(1000000000, 9999999999)
+ };
+ const contactInfo = {
+ firstName: getRandomString(4, 15),
+ lastName: getRandomString(4, 15),
+ emailAddress: getRandomString(10, 20),
+ phoneNumber: getRandomInt(1000000000, 9999999999),
+ requestTextUpdates: getRandomBoolean(),
+ notesForTechnician: getRandomString(50, 100)
+ };
+ const mainInitialState = {
+ order: {
+ customer,
+ contactInfo
+ }
+ };
+ const mountOptions = getMountOptions();
+ mountOptions.global = {
+ plugins: [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })]
+ };
+
+ const wrapper = shallowMount(contactDetails, mountOptions);
+
+ // Assert
+ expect(wrapper.vm.firstName).toBe(contactInfo.firstName);
+ expect(wrapper.vm.lastName).toBe(contactInfo.lastName);
+ expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress);
+ expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber);
+ expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates);
+ expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician);
+ });
});
diff --git a/src/layouts/duplicate-check/duplicate-check.spec.js b/src/layouts/duplicate-check/duplicate-check.spec.js
index e0b06650..f9138fe9 100644
--- a/src/layouts/duplicate-check/duplicate-check.spec.js
+++ b/src/layouts/duplicate-check/duplicate-check.spec.js
@@ -1,12 +1,13 @@
// Components
+import { shallowMount } from '@vue/test-utils';
+import { createTestingPinia } from '@pinia/testing';
import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue';
// Supporting Files
-import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
-import { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import { getRandomString } from '@/helpers/data-generation.js';
+import { useMainStore } from '@/store';
const duplicateOrderText = 'Finish Existing Claim';
@@ -52,279 +53,277 @@ describe('duplicateCheck.vue', () => {
// Assert
expect(footer.exists()).toBeTruthy();
});
-
- // TODO update or remove
- // test('Mocked store with no contact info yields expected data', () => {
- // // Arrange
- // const mountOptions = getMountOptions();
-
- // const firstName = getRandomString(4, 15);
- // const lastName = getRandomString(4, 15);
- // const emailAddress = getRandomString(10, 20);
- // const phoneNumber = getRandomInt(1000000000, 9999999999);
- // const mainInitialState = {
- // order: {
- // customer: {
- // firstName,
- // lastName,
- // emailAddress,
- // phoneNumber
- // }
- // }
- // };
- // mountOptions.global = {
- // plugins: [createTestingPinia({
- // initialState: {
- // main: mainInitialState
- // }
- // })]
- // };
-
- // const wrapper = shallowMount(contactDetails, mountOptions);
-
- // // Assert
- // expect(wrapper.vm.firstName).toBe(firstName);
- // expect(wrapper.vm.lastName).toBe(lastName);
- // expect(wrapper.vm.emailAddress).toBe(emailAddress);
- // expect(wrapper.vm.phoneNumber).toBe(phoneNumber);
- // });
- // test('Mock store with contact info yields expected data', () => {
- // // Arrange
- // const customer = {
- // firstName: getRandomString(4, 15),
- // lastName: getRandomString(4, 15),
- // emailAddress: getRandomString(10, 20),
- // phoneNumber: getRandomInt(1000000000, 9999999999)
- // };
- // const contactInfo = {
- // firstName: getRandomString(4, 15),
- // lastName: getRandomString(4, 15),
- // emailAddress: getRandomString(10, 20),
- // phoneNumber: getRandomInt(1000000000, 9999999999),
- // requestTextUpdates: getRandomBoolean(),
- // notesForTechnician: getRandomString(50, 100)
- // };
- // const mainInitialState = {
- // order: {
- // customer,
- // contactInfo
- // }
- // };
- // const mountOptions = getMountOptions();
- // mountOptions.global = {
- // plugins: [createTestingPinia({
- // initialState: {
- // main: mainInitialState
- // }
- // })]
- // };
-
- // const wrapper = shallowMount(contactDetails, mountOptions);
-
- // // Assert
- // expect(wrapper.vm.firstName).toBe(contactInfo.firstName);
- // expect(wrapper.vm.lastName).toBe(contactInfo.lastName);
- // expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress);
- // expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber);
- // expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates);
- // expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician);
- // });
});
- describe('duplicateOrders computed', () => {
- test('duplicateOrders in store undefined => returns empty list', () => {
- // Arrange
- const mountOptions = getMountOptions({
- router: { navigate: jest.fn() }
+ describe('computed properties', () => {
+ describe('duplicateOrders computed', () => {
+ test('duplicateOrders in store undefined => returns empty list', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+
+ const mainInitialState = {
+ 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 = {
- applicationUser: {
- duplicateOrders: undefined
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
+ const mainInitialState = {
+ applicationUser: {
+ duplicateOrders: []
+ }
+ };
+ mountOptions.global.plugins = [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })];
- const wrapper = shallowMount(duplicateCheck, mountOptions);
+ 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() }
+ // 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 mainInitialState = {
- applicationUser: {
- duplicateOrders: []
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
+ const referralNumber = getRandomString(6, 6);
+ const mainInitialState = {
+ applicationUser: {
+ duplicateOrders: [
+ {
+ vehicleYear: null,
+ vehicleMake: getRandomString(5, 5),
+ vehicleModel: getRandomString(5, 5),
+ responseDate: '1990-09-23T01:12:34',
+ referralNumber
+ }
+ ]
+ }
+ };
+ mountOptions.global.plugins = [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })];
+ const expectedSubtext = '9/23/1990';
- const wrapper = shallowMount(duplicateCheck, mountOptions);
+ 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() }
+ // Assert
+ expect(wrapper.vm.duplicateOrders.length).toBe(1);
+ expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
+ Text: duplicateOrderText,
+ Name: referralNumber,
+ SubText: expectedSubtext
+ });
});
+ test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
- const date = getRandomString(9, 9);
- const referralNumber = getRandomString(6, 6);
- const mainInitialState = {
- applicationUser: {
- duplicateOrders: [
- {
- vehicleYear: null,
- vehicleMake: getRandomString(5, 5),
- vehicleModel: getRandomString(5, 5),
- dateOfLoss: date,
- referralNumber
- }
- ]
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
+ const referralNumber = getRandomString(6, 6);
+ const mainInitialState = {
+ applicationUser: {
+ duplicateOrders: [
+ {
+ vehicleYear: getRandomString(6, 6),
+ vehicleMake: null,
+ vehicleModel: getRandomString(5, 5),
+ responseDate: '2004-11-01T01:12:34',
+ referralNumber
+ }
+ ]
+ }
+ };
+ mountOptions.global.plugins = [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })];
+ const expectedSubtext = '11/1/2004';
- const wrapper = shallowMount(duplicateCheck, mountOptions);
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
- // Assert
- expect(wrapper.vm.duplicateOrders.length).toBe(1);
- expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
- Text: duplicateOrderText,
- Name: referralNumber,
- SubText: date
+ // Assert
+ expect(wrapper.vm.duplicateOrders.length).toBe(1);
+ expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
+ Text: duplicateOrderText,
+ Name: referralNumber,
+ SubText: expectedSubtext
+ });
+ });
+ 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 = {
+ applicationUser: {
+ duplicateOrders: [
+ {
+ vehicleYear: getRandomString(6, 6),
+ vehicleMake: getRandomString(6, 6),
+ vehicleModel: null,
+ responseDate: '1999-01-15T01:12:34',
+ referralNumber
+ }
+ ]
+ }
+ };
+ mountOptions.global.plugins = [createTestingPinia({
+ initialState: {
+ main: mainInitialState
+ }
+ })];
+ const expectedSubtext = '1/15/1999';
+
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
+
+ // Assert
+ expect(wrapper.vm.duplicateOrders.length).toBe(1);
+ expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
+ Text: duplicateOrderText,
+ Name: referralNumber,
+ SubText: expectedSubtext
+ });
+ });
+ 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 = {
+ applicationUser: {
+ duplicateOrders: [
+ {
+ vehicleYear: 'YEAR',
+ vehicleMake: 'make',
+ vehicleModel: 'MoDel',
+ responseDate: '2018-03-01T01:12:34',
+ referralNumber
+ }
+ ]
+ }
+ };
+ 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}`
+ });
});
});
- test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
- // Arrange
- const mountOptions = getMountOptions({
- router: { navigate: jest.fn() }
+ describe('getNewOrderSelectionName', () => {
+ test('answersFromCms null => returns empty string', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ const answersFromCmsValue = null;
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' ? answersFromCmsValue : ''))
+ }
+ }];
+
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
+
+ // Assert
+ expect(wrapper.vm.getNewOrderSelectionName).toBe('');
});
+ test('answersFromCms empty list => returns empty string', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ const answersFromCmsValue = [];
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers' ? answersFromCmsValue : ''))
+ }
+ }];
- const date = getRandomString(9, 9);
- const referralNumber = getRandomString(6, 6);
- const mainInitialState = {
- applicationUser: {
- duplicateOrders: [
- {
- vehicleYear: getRandomString(6, 6),
- vehicleMake: null,
- vehicleModel: getRandomString(5, 5),
- dateOfLoss: date,
- referralNumber: referralNumber
- }
- ]
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
- const wrapper = shallowMount(duplicateCheck, mountOptions);
-
- // Assert
- expect(wrapper.vm.duplicateOrders.length).toBe(1);
- expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
- Text: duplicateOrderText,
- Name: referralNumber,
- SubText: date
+ // Assert
+ expect(wrapper.vm.getNewOrderSelectionName).toBe('');
});
- });
- test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
- // Arrange
- const mountOptions = getMountOptions({
- router: { navigate: jest.fn() }
+ test('answersFromCms non-empty list whose first item has no Name property => returns empty string', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ const answersFromCmsValue = [{ test: getRandomString(6, 6) }];
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
+ ? answersFromCmsValue
+ : ''))
+ }
+ }];
+
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
+
+ // Assert
+ expect(wrapper.vm.getNewOrderSelectionName).toBe('');
});
+ test('answersFromCms first item has Name property => returns expected', () => {
+ // Arrange
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ const expectedName = getRandomString(6, 6);
+ const answersFromCmsValue = [{ Name: expectedName }];
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
+ ? answersFromCmsValue
+ : ''))
+ }
+ }];
- const date = getRandomString(9, 9);
- const referralNumber = getRandomString(6, 6);
- const mainInitialState = {
- applicationUser: {
- duplicateOrders: [
- {
- vehicleYear: getRandomString(6, 6),
- vehicleMake: getRandomString(6, 6),
- vehicleModel: null,
- dateOfLoss: date,
- referralNumber: referralNumber
- }
- ]
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
- const wrapper = shallowMount(duplicateCheck, mountOptions);
-
- // Assert
- expect(wrapper.vm.duplicateOrders.length).toBe(1);
- expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
- Text: duplicateOrderText,
- Name: referralNumber,
- SubText: date
- });
- });
- 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 year = getRandomString(6, 6,);
- const make = getRandomString(6, 6);
- const model = getRandomString(6, 6);
- const date = getRandomString(9, 9);
- const referralNumber = getRandomString(6, 6);
- const mainInitialState = {
- applicationUser: {
- duplicateOrders: [
- {
- vehicleYear: year,
- vehicleMake: make,
- vehicleModel: model,
- dateOfLoss: date,
- referralNumber: referralNumber
- }
- ]
- }
- };
- mountOptions.global.plugins = [createTestingPinia({
- initialState: {
- main: mainInitialState
- }
- })];
-
- const wrapper = shallowMount(duplicateCheck, mountOptions);
-
- // Assert
- expect(wrapper.vm.duplicateOrders.length).toBe(1);
- expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
- Text: duplicateOrderText,
- Name: referralNumber,
- SubText: `${year} ${make} ${model}, ${date}`
+ // Assert
+ expect(wrapper.vm.getNewOrderSelectionName).toBe(expectedName);
});
});
});
@@ -348,7 +347,88 @@ describe('duplicateCheck.vue', () => {
});
describe('forwardButtonAction', () => {
- test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', () => {
+ test('Selected duplicate => load session called', async () => {
+ // Arrange
+ const newOrderSelectionName = getRandomString(6, 6);
+ const selectedAnswer = getRandomString(6, 6);
+
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
+ ? [{ Name: newOrderSelectionName }]
+ : ''))
+ }
+ }];
+
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
+ wrapper.setData({ selectedAnswer });
+ useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1);
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
+ });
+ 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 = shallowMount(duplicateCheck, mountOptions);
+ wrapper.setData({ selectedAnswer: newOrderSelectionName });
+ useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(0);
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
+ });
+ test('Load session throws error => still navigate forward', async () => {
+ // Arrange
+ const newOrderSelectionName = getRandomString(6, 6);
+ const selectedAnswer = getRandomString(6, 6);
+
+ const mountOptions = getMountOptions({
+ router: { navigate: jest.fn() }
+ });
+ mountOptions.mixins = [{
+ methods: {
+ getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
+ ? [{ Name: newOrderSelectionName }]
+ : ''))
+ }
+ }];
+
+ const wrapper = shallowMount(duplicateCheck, mountOptions);
+ wrapper.setData({ selectedAnswer });
+ const error = 'load session error';
+ useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.mainStore.loadSession).toHaveBeenCalledTimes(1);
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
+ });
+ test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
// Arrange
const mountOptions = getMountOptions({
router: { navigate: jest.fn() }
@@ -358,7 +438,7 @@ describe('duplicateCheck.vue', () => {
order: {
policy: {
policyLookupSuccessful: true,
- vehicles: [{test: 'a'}]
+ vehicles: [{ test: 'a' }]
}
}
};
@@ -371,19 +451,19 @@ describe('duplicateCheck.vue', () => {
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
- wrapper.vm.forwardButtonAction();
+ await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES, undefined);
});
- test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', () => {
+ 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 = {
order: {
policy: {
@@ -401,19 +481,19 @@ describe('duplicateCheck.vue', () => {
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
- wrapper.vm.forwardButtonAction();
+ await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES, undefined);
});
- test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', () => {
+ test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
// Arrange
const mountOptions = getMountOptions({
router: { navigate: jest.fn() }
});
-
+
const mainInitialState = {
order: {
policy: {
@@ -430,7 +510,7 @@ describe('duplicateCheck.vue', () => {
const wrapper = shallowMount(duplicateCheck, mountOptions);
// Act
- wrapper.vm.forwardButtonAction();
+ await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
@@ -439,4 +519,4 @@ describe('duplicateCheck.vue', () => {
});
});
});
-});
\ No newline at end of file
+});
diff --git a/src/layouts/duplicate-check/duplicate-check.vue b/src/layouts/duplicate-check/duplicate-check.vue
index 67e61a11..222309ec 100644
--- a/src/layouts/duplicate-check/duplicate-check.vue
+++ b/src/layouts/duplicate-check/duplicate-check.vue
@@ -42,6 +42,7 @@
+
+
diff --git a/src/layouts/welcome-page/welcome-page.spec.js b/src/layouts/welcome-page/welcome-page.spec.js
index 573b8fce..70447e84 100644
--- a/src/layouts/welcome-page/welcome-page.spec.js
+++ b/src/layouts/welcome-page/welcome-page.spec.js
@@ -1,7 +1,8 @@
+import { shallowMount } from '@vue/test-utils';
+import { createTestingPinia } from '@pinia/testing';
import welcomePage from '@/layouts/welcome-page/welcome-page.vue';
// Supporting files
-import { shallowMount } from '@vue/test-utils';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import baseMixin from '@/mixins/base-mixin.js';
@@ -10,8 +11,6 @@ import applicationConfig from '@/constants/application-config';
import { useMainStore } from '@/store';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
import routerParams from '@/router/router-constants/router-params';
-import { getRandomString } from '@/helpers/data-generation.js';
-import { createTestingPinia } from '@pinia/testing';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
@@ -179,13 +178,8 @@ describe('navigation', () => {
test('if duplicates found, navigate to duplicate check page', async () => {
// Arrange
const { wrapper } = getMountedComponent({});
-
- const duplicatesExist = {
- policyLookupResponse: {},
- duplicateCheckResponse: [{ test: 'a'}]
- };
-
- settleAllPromises.mockImplementation(() => Promise.resolve(duplicatesExist));
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
+ useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
// Act
await wrapper.vm.forwardButtonAction();
@@ -199,38 +193,43 @@ describe('navigation', () => {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
);
});
- test('if policy and vehicles are found, navigate to policy-vehicle page', async () => {
+ test('if isCoverageEnabled is false, then getCoveragePolicyInfo not called', async () => {
// Arrange
- const mockvehicles = [
- {
- vin: 'TEST_VIN'
- },
- {
- vin: 'TEST_VIN2'
- }
- ];
+ const { wrapper } = getMountedComponent({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
+ useMainStore().issConfig.isCoverageEnabled = false;
- const { wrapper } = setupMocks({
- policies: [{
- vehicles: [
- {
- vin: 'TEST_VIN'
- },
- {
- vin: 'TEST_VIN2'
- }
- ]
- }]
- });
-
- await wrapper.setData({
- vehiclesFound: mockvehicles
- });
+ // Act
+ await wrapper.vm.forwardButtonAction();
+ // Assert
+ expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
+ expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled();
+ });
+ test('if isCoverageEnabled is true, then getCoveragePolicyInfo called', async () => {
+ // Arrange
+ const { wrapper } = getMountedComponent({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
useMainStore().issConfig.isCoverageEnabled = true;
- useMainStore().order.policy.policyNumber = 'p_0001';
- useMainStore().order.policy.dateOfLoss = '2022-01-28';
- useMainStore().order.accountNumber = '00000';
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled();
+ expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled();
+ });
+ test('if policy and vehicles are found but no duplicates, navigate to policy-vehicle page', async () => {
+ // Arrange
+ const { wrapper } = setupMocks({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
+
+ useMainStore().applicationUser.duplicateOrders = [];
+ useMainStore().order.policy.policyLookupSuccessful = true;
+ useMainStore().order.policy.vehicles = [
+ { vin: 'TEST_VIN' },
+ { vin: 'TEST_VIN2' }
+ ];
// Act
await wrapper.vm.forwardButtonAction();
@@ -243,20 +242,14 @@ describe('navigation', () => {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
);
});
- test('if policy is found, but no vehicles, navigate to vehicle-selection page', async () => {
+ test('if policy is found, but no vehicles and no duplicates, navigate to vehicle-selection page', async () => {
// Arrange
- const { wrapper } = setupMocks({
- policies: [{}]
- });
+ const { wrapper } = setupMocks({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
- await wrapper.setData({
- vehiclesFound: null
- });
-
- useMainStore().issConfig.isCoverageEnabled = true;
- useMainStore().order.policy.policyNumber = 'p_0001';
- useMainStore().order.policy.dateOfLoss = '2022-01-28';
- useMainStore().order.accountNumber = '00000';
+ useMainStore().applicationUser.duplicateOrders = [];
+ useMainStore().order.policy.policyLookupSuccessful = true;
+ useMainStore().order.policy.vehicles = [];
// Act
@@ -270,19 +263,37 @@ describe('navigation', () => {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
);
});
- test('if policy is not found, navigate to policy-holder-details page', async () => {
+ test('if policy is found, but null vehicles and no duplicates, navigate to vehicle-selection page', async () => {
// Arrange
- const { wrapper } = setupMocks({
- policies: null
- });
+ const { wrapper } = setupMocks({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
- useMainStore().issConfig.isCoverageEnabled = true;
- useMainStore().order.policy.policyNumber = 'p_0001';
- useMainStore().order.policy.dateOfLoss = '2022-01-28';
- useMainStore().order.accountNumber = '00000';
+ useMainStore().applicationUser.duplicateOrders = [];
+ useMainStore().order.policy.policyLookupSuccessful = true;
+ useMainStore().order.policy.vehicles = null;
// Act
- await wrapper.vm.navigateForward();
+
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
+ navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
+ undefined,
+ {},
+ { [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
+ );
+ });
+ test('if policy is not found and no duplicates, navigate to policy-holder-details page', async () => {
+ // Arrange
+ const { wrapper } = setupMocks({});
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
+
+ useMainStore().order.policy.policyLookupSuccessful = false;
+ useMainStore().applicationUser.duplicateOrders = [];
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
@@ -292,4 +303,16 @@ describe('navigation', () => {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
);
});
+ test('getDuplicateReferrals throws rejected promise => navigate called', async () => {
+ // Arrange
+ const { wrapper } = setupMocks({});
+ const error = 'duplicate referrals error';
+ useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.reject(error));
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
+ });
});
diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue
index ee29c984..1f0ac16e 100644
--- a/src/layouts/welcome-page/welcome-page.vue
+++ b/src/layouts/welcome-page/welcome-page.vue
@@ -167,6 +167,7 @@