Merge pull request #477 from Safelite/feature/digital/SSR-512
Feature/digital/ssr 512
This commit is contained in:
commit
64d85c1ddb
11 changed files with 1623 additions and 734 deletions
|
|
@ -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}`,
|
||||
|
|
|
|||
|
|
@ -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(' ');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
<script>
|
||||
// Components
|
||||
import { Form } from 'vee-validate';
|
||||
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
|
||||
|
|
@ -49,10 +50,10 @@ import buttonQuestion from '@/digital-components/button-question/button-question
|
|||
|
||||
// Supporting files
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper.js';
|
||||
import { Form } from 'vee-validate';
|
||||
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import globalRules from '@/constants/global-rules.js';
|
||||
import { toTitleCase } from '@/helpers/text-helper.js';
|
||||
|
||||
export default {
|
||||
name: 'duplicate-check',
|
||||
|
|
@ -74,6 +75,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
selectedAnswer: '',
|
||||
widget: {
|
||||
siteHeader: 'SiteHeaderWidget',
|
||||
siteSubHeader: 'SiteSubHeaderWidget',
|
||||
|
|
@ -92,6 +94,9 @@ export default {
|
|||
answersFromCms() {
|
||||
return this.getCmsContent(this.widget.existingOrNewQuestion, 'Answers') ?? [];
|
||||
},
|
||||
getNewOrderSelectionName() {
|
||||
return this.answersFromCms?.[0]?.Name ?? '';
|
||||
},
|
||||
duplicateOrders() {
|
||||
const duplicateOrderText = 'Finish Existing Claim';
|
||||
const orders = useMainStore().applicationUser.duplicateOrders;
|
||||
|
|
@ -100,14 +105,15 @@ export default {
|
|||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||
: null;
|
||||
|
||||
const subtext = vehicle && o.dateOfLoss
|
||||
? `${vehicle}, ${o.dateOfLoss}`
|
||||
: (vehicle ?? '').concat(o.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: subtext
|
||||
SubText: toTitleCase(subtext)
|
||||
};
|
||||
}) ?? [];
|
||||
},
|
||||
|
|
@ -125,7 +131,16 @@ export default {
|
|||
/**
|
||||
* @summary Steps to perform when forward button clicked.
|
||||
*/
|
||||
forwardButtonAction() {
|
||||
async forwardButtonAction() {
|
||||
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
|
||||
await useMainStore().loadSession()
|
||||
.then(() => {}, () => {})
|
||||
.finally(() => { this.navigateForward(); });
|
||||
} else {
|
||||
this.navigateForward();
|
||||
}
|
||||
},
|
||||
navigateForward() {
|
||||
if (useMainStore().order.policy.policyLookupSuccessful) {
|
||||
const policyVehicles = useMainStore().order.policy.vehicles ?? [];
|
||||
if (policyVehicles.length > 0) {
|
||||
|
|
@ -168,6 +183,9 @@ export default {
|
|||
margin-top: map-get($spacers, 4);
|
||||
margin-bottom: map-get($spacers, 2);
|
||||
}
|
||||
.form-test-error{
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -176,17 +176,6 @@ describe('schedule-page.vue', () => {
|
|||
// Assert
|
||||
expect(arePagePrerequisitesValid).toBeFalsy();
|
||||
});
|
||||
test('Should fail arePagePrerequisitesValid without isInsurance', () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent();
|
||||
wrapper.vm.mainStore.payment.isInsurance = null;
|
||||
|
||||
// Act
|
||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||
|
||||
// Assert
|
||||
expect(arePagePrerequisitesValid).toBe(false);
|
||||
});
|
||||
test('Should fail arePagePrerequisitesValid if supportingItems is null', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent();
|
||||
|
|
|
|||
|
|
@ -328,14 +328,13 @@ export default {
|
|||
&& ((serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
||||
|| serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP)
|
||||
|| serviceLocation.provider.providerNumber);
|
||||
const paymentInfo = useMainStore().payment.isInsurance !== null;
|
||||
const supportingItems = useMainStore().lineItems.supportingItems !== null;
|
||||
const damageInfo =
|
||||
useMainStore().order.damage.isRepair
|
||||
|| (useMainStore().order.lineItems?.glassParts != null
|
||||
&& useMainStore().order.lineItems.glassParts.length > 0);
|
||||
|
||||
return serviceLocationPreReqs && paymentInfo && supportingItems && damageInfo;
|
||||
return serviceLocationPreReqs && supportingItems && damageInfo;
|
||||
},
|
||||
setData(initialShopTimeSlotsResponse, premiumFeeWithPriceResponse) {
|
||||
this.selectableDatesData = initialShopTimeSlotsResponse;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@
|
|||
|
||||
<script>
|
||||
// Components
|
||||
import { Form, defineRule } from 'vee-validate';
|
||||
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
||||
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||
|
|
@ -178,7 +179,6 @@ import textBlock from '@/digital-components/text-block/text-block.vue';
|
|||
// Supporting files
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper';
|
||||
import { Form, defineRule } from 'vee-validate';
|
||||
import { required, regex } from '@/helpers/validation-rules';
|
||||
import errorMessages from '@/constants/error-messages';
|
||||
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
||||
|
|
@ -253,7 +253,6 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
welcomePageModel: this.getWelcomePageModelFromStore(),
|
||||
vehiclesFound: [],
|
||||
duplicates: [],
|
||||
rules: {
|
||||
policyNumber: 'policy-number-required',
|
||||
|
|
@ -309,75 +308,27 @@ export default {
|
|||
methods: {
|
||||
async forwardButtonAction() {
|
||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||
const duplicateCheckResponse = await useMainStore().getDuplicateReferrals();
|
||||
const duplicatePromiseResultMap = [
|
||||
{
|
||||
resultKey: 'duplicateCheckResponse',
|
||||
promise: duplicateCheckResponse
|
||||
}
|
||||
];
|
||||
const duplicateResultMap = await settleAllPromises(duplicatePromiseResultMap);
|
||||
|
||||
this.mainStore.applicationUser.duplicateOrders = duplicateResultMap.duplicateCheckResponse ?? [];
|
||||
this.duplicates = duplicateResultMap.duplicateCheckResponse;
|
||||
|
||||
// call coverage policy lookup if isCoverageEnabled flag enabled
|
||||
if (this.isCoverageEnabled) {
|
||||
const policyLookupResponse = useMainStore().getCoveragePolicyInfo({
|
||||
accountNumber: this.mainStore.order.accountNumber.toString(),
|
||||
policyNumber: this.mainStore.order.policy.policyNumber,
|
||||
dateOfLoss: this.mainStore.order.policy.dateOfLoss,
|
||||
zipCode: this.mainStore.order.policy.policyZipCode
|
||||
});
|
||||
|
||||
const policyPromiseResultMap = [
|
||||
{
|
||||
resultKey: 'policyLookupResponse',
|
||||
promise: policyLookupResponse
|
||||
await this.mainStore.getDuplicateReferrals()
|
||||
.then(() => {}, () => {})
|
||||
.finally(async () => {
|
||||
if (this.isCoverageEnabled) {
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
}
|
||||
];
|
||||
|
||||
const policyResultMap = await settleAllPromises(policyPromiseResultMap);
|
||||
const policyInfo = policyResultMap.policyLookupResponse;
|
||||
|
||||
// if policy lookup fails, navigate directly to policy-holder-details page
|
||||
if (!policyInfo) {
|
||||
this.navigateForward();
|
||||
}
|
||||
|
||||
const policy = policyInfo.policies?.[0];
|
||||
if (policy) {
|
||||
// populate policy holder details from policy lookup
|
||||
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
||||
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
||||
this.mainStore.order.customer.address.state = policy.insureds?.[0]?.state;
|
||||
this.mainStore.order.customer.address.zipCode = policy.insureds?.[0]?.zipCode;
|
||||
this.mainStore.order.customer.firstName = policy.insureds?.[0]?.firstName;
|
||||
this.mainStore.order.customer.lastName = policy.insureds?.[0]?.lastName;
|
||||
|
||||
// populate additional fields
|
||||
this.mainStore.order.serviceLocation.zipCode = policy.insureds?.[0]?.zipCode;
|
||||
|
||||
// populate vehicles
|
||||
this.mainStore.order.policy.vehicles = policy.vehicles;
|
||||
this.vehiclesFound = policy.vehicles;
|
||||
}
|
||||
return this.navigateForward(policy);
|
||||
}
|
||||
return this.navigateForward();
|
||||
});
|
||||
},
|
||||
|
||||
navigateForward(policy) {
|
||||
if (this.duplicates?.length > 0 ?? false) {
|
||||
navigateForward() {
|
||||
if (this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
||||
this.$route,
|
||||
{},
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
} else if (policy) {
|
||||
if (this.vehiclesFound) {
|
||||
// if policy lookup is successful and vehicles are found, navigate to policy-vehicles page
|
||||
} else if (this.mainStore.policy.policyLookupSuccessful) {
|
||||
if (this.mainStore.order.policy.vehicles?.length > 0 ?? false) {
|
||||
// navigate to policy-vehicles page
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
|
||||
this.$route,
|
||||
|
|
@ -385,7 +336,6 @@ export default {
|
|||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
} else {
|
||||
// if policy lookup is successful, but no vehicles are associated with the policy
|
||||
// navigate to vehicle-selection page (manual entry)
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const getDefaultState = () => ({
|
|||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
imageColor: null,
|
||||
registration: {
|
||||
registration: { // TODO only licensePlate saved in save session
|
||||
licensePlate: null,
|
||||
address: null,
|
||||
city: null,
|
||||
|
|
@ -119,7 +119,6 @@ const getDefaultState = () => ({
|
|||
vaps: null
|
||||
},
|
||||
payment: {
|
||||
isInsurance: true, // TODO delete; irrelevant to ISS
|
||||
insuranceCoverage: {
|
||||
isVerified: false,
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
|
|
@ -154,15 +153,16 @@ const getDefaultState = () => ({
|
|||
},
|
||||
applicationUser: {
|
||||
experiments: [],
|
||||
eventBus: [],
|
||||
eventBus: [], // TODO not in save session
|
||||
pageData: {},
|
||||
savedSessionTimeout: getDateForSavedSessionTimeout(),
|
||||
saveSessionPromise: null,
|
||||
savedSessionId: null,
|
||||
savedSessionId: '00000000-0000-0000-0000-000000000000',
|
||||
crmCustomerId: null,
|
||||
lastPageVisited: null,
|
||||
triggeredSiteEntry: false,
|
||||
duplicateOrders: []
|
||||
triggeredSiteEntry: false, // TODO not in save session
|
||||
duplicateOrders: [],
|
||||
hasSentSaveQuoteEmail: null
|
||||
},
|
||||
issConfig: {
|
||||
clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name
|
||||
|
|
@ -205,7 +205,9 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
eventBus: (state) => state.applicationUser.eventBus,
|
||||
applicationUserObj: (state) => state.applicationUser,
|
||||
pageData: (state) => (page) => state.applicationUser.pageData[page],
|
||||
pageData: (state) => (page) => (page in state.applicationUser.pageData
|
||||
? state.applicationUser.pageData[page]
|
||||
: undefined),
|
||||
customerData: (state) => {
|
||||
if (state.order.vehicle.registration.address) {
|
||||
const { registration } = state.order.vehicle;
|
||||
|
|
@ -386,36 +388,46 @@ export const useMainStore = defineStore({
|
|||
};
|
||||
}
|
||||
},
|
||||
getCoveragePolicyInfo({ accountNumber, policyNumber, dateOfLoss, zipCode }) {
|
||||
const { policy } = this.order;
|
||||
try {
|
||||
const response = globalMethods.callHttpClient({
|
||||
getCoveragePolicyInfo() {
|
||||
const { order } = this;
|
||||
const { policy } = order;
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
method: endpoints.CoveragePolicyInfo.method,
|
||||
endpoint: endpoints.CoveragePolicyInfo.url,
|
||||
payload: {
|
||||
accountNumber,
|
||||
policyNumber,
|
||||
dateOfLoss,
|
||||
zipCode,
|
||||
correlationId: this.order.referralCorrelationId
|
||||
accountNumber: order.accountNumber?.toString(),
|
||||
policyNumber: policy.policyNumber,
|
||||
dateOfLoss: policy.dateOfLoss,
|
||||
zipCode: policy.policyZipCode,
|
||||
correlationId: order.referralCorrelationId
|
||||
}
|
||||
}).then((r) => {
|
||||
const responsePolicy = r.data.policies?.[0];
|
||||
const responsePolicy = r?.data?.policies?.[0];
|
||||
policy.policyLookupSuccessful = !!responsePolicy;
|
||||
return r;
|
||||
if (policy.policyLookupSuccessful) {
|
||||
const insured = responsePolicy.insureds?.[0];
|
||||
|
||||
// populate policy holder details from policy lookup
|
||||
order.customer.address.streetAddress = insured?.address;
|
||||
order.customer.address.city = insured?.city;
|
||||
order.customer.address.state = insured?.state;
|
||||
order.customer.address.zipCode = insured?.zipCode;
|
||||
order.customer.firstName = insured?.firstName;
|
||||
order.customer.lastName = insured?.lastName;
|
||||
|
||||
// populate additional fields
|
||||
order.serviceLocation.zipCode = insured?.zipCode;
|
||||
|
||||
// populate vehicles
|
||||
order.policy.vehicles = responsePolicy.vehicles ?? [];
|
||||
}
|
||||
return resolve(r);
|
||||
}).catch((error) => {
|
||||
policy.policyLookupSuccessful = false;
|
||||
return error;
|
||||
return reject(error);
|
||||
});
|
||||
return response;
|
||||
} catch (responseError) {
|
||||
policy.policyLookupSuccessful = false;
|
||||
return {
|
||||
error: {
|
||||
status: responseError.status
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
registerClaim() {
|
||||
const nonNumberCharRegex = /[^0-9]/g;
|
||||
|
|
@ -624,7 +636,7 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
getMobilePremiumFee() {
|
||||
const damageType = this.damage.isRepair ? 'Repair' : 'Replace';
|
||||
const paymentType = this.order.payment.isInsurance ? 'Insurance' : 'Cash';
|
||||
const paymentType = 'Insurance';
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetMobilePremiumFee.method,
|
||||
|
|
@ -912,123 +924,251 @@ export const useMainStore = defineStore({
|
|||
const { vehicle, damage, policy, customer, contactInfo, payment,
|
||||
lineItems, serviceLocation, schedule } = this.order;
|
||||
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace);
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url,
|
||||
payload: {
|
||||
applicationUser: {
|
||||
crmCustomerId: this.applicationUser.crmCustomerId,
|
||||
experiments: this.applicationUser.experiments,
|
||||
lastPage: this.applicationUser.lastPageVisited,
|
||||
pageData: this.applicationUser.pageData,
|
||||
savedSessionId: this.applicationUser.savedSessionId
|
||||
},
|
||||
vehicle: {
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
vin: vehicle.vin,
|
||||
carId: vehicle.carId,
|
||||
licensePlateNumber: vehicle.registration?.licensePlate
|
||||
},
|
||||
damage: {
|
||||
numberOfChips: damage.numberOfChips,
|
||||
glassToReplace: newGlassToReplace,
|
||||
isRepair: damage.isRepair,
|
||||
partQuestionAnswers: damage.partQuestionAnswers,
|
||||
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
||||
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
||||
dateOfLoss: policy.dateOfLoss,
|
||||
damageCause: policy.damageCause,
|
||||
damageState: policy.damageState,
|
||||
damageCity: policy.damageCity,
|
||||
isDamageGlassOnly: policy.isDamageGlassOnly
|
||||
},
|
||||
policy: {
|
||||
policyHolder: {
|
||||
policyFirstName: customer.firstName,
|
||||
policyLastName: customer.lastName,
|
||||
policyPhoneNumber: customer.phoneNumber,
|
||||
policyEmail: customer.emailAddress,
|
||||
policyState: customer.address.state
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url,
|
||||
payload: {
|
||||
applicationUser: {
|
||||
crmCustomerId: this.applicationUser.crmCustomerId,
|
||||
experiments: this.applicationUser.experiments,
|
||||
lastPage: this.applicationUser.lastPageVisited,
|
||||
pageData: this.applicationUser.pageData,
|
||||
savedSessionId: this.applicationUser.savedSessionId
|
||||
},
|
||||
policyNumber: policy.policyNumber,
|
||||
policyZipCode: policy.policyZipCode,
|
||||
noCoverage: policy.noCoverage,
|
||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||
originalDeductible: this.order.originalDeductible,
|
||||
currentDeductible: this.order.currentDeductible
|
||||
},
|
||||
customer: {
|
||||
address: {
|
||||
streetAddress: customer.address?.streetAddress,
|
||||
streetAddress2: customer.address?.streetAddress2,
|
||||
city: customer.address?.city,
|
||||
state: customer.address?.state,
|
||||
zipCode: customer.address?.zipCode
|
||||
vehicle: {
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
vin: vehicle.vin,
|
||||
carId: vehicle.carId,
|
||||
licensePlateNumber: vehicle.registration?.licensePlate
|
||||
},
|
||||
emailAddress: contactInfo.emailAddress,
|
||||
firstName: contactInfo.firstName || customer.firstName,
|
||||
lastName: contactInfo.lastName || customer.lastName,
|
||||
phoneNumber: contactInfo.phoneNumber,
|
||||
optInSms: contactInfo.requestTextUpdates ?? false
|
||||
},
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
isVerified: payment.insuranceCoverage?.isVerified ?? false,
|
||||
coverageStatus: payment.insuranceCoverage?.coverageStatus,
|
||||
claimNumber: payment.insuranceCoverage?.claimNumber
|
||||
damage: {
|
||||
numberOfChips: damage.numberOfChips,
|
||||
glassToReplace: newGlassToReplace,
|
||||
isRepair: damage.isRepair,
|
||||
partQuestionAnswers: damage.partQuestionAnswers,
|
||||
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
||||
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
||||
dateOfLoss: policy.dateOfLoss,
|
||||
damageCause: policy.damageCause,
|
||||
damageState: policy.damageState,
|
||||
damageCity: policy.damageCity,
|
||||
isDamageGlassOnly: policy.isDamageGlassOnly
|
||||
},
|
||||
isInsurance: payment.isInsurance ?? true,
|
||||
parentAccountNumber: this.issConfig.parentAccountNumber
|
||||
},
|
||||
serviceLocation: {
|
||||
address: {
|
||||
streetAddress: serviceLocation.address,
|
||||
city: serviceLocation.city,
|
||||
state: serviceLocation.state,
|
||||
zipCode: serviceLocation.zipCode,
|
||||
zipCodeCtu: serviceLocation.zipCodeCtu
|
||||
policy: {
|
||||
policyHolder: {
|
||||
policyFirstName: customer.firstName,
|
||||
policyLastName: customer.lastName,
|
||||
policyPhoneNumber: customer.phoneNumber,
|
||||
policyEmail: customer.emailAddress,
|
||||
policyState: customer.address.state
|
||||
},
|
||||
policyNumber: policy.policyNumber,
|
||||
policyZipCode: policy.policyZipCode,
|
||||
noCoverage: policy.noCoverage,
|
||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||
originalDeductible: this.order.originalDeductible,
|
||||
currentDeductible: this.order.currentDeductible
|
||||
},
|
||||
appointmentType: (serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
||||
|| serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP)
|
||||
? AppointmentTypeStrings.MOBILE : serviceLocation.appointmentType,
|
||||
isVehicleProtected: serviceLocation.isVehicleProtected,
|
||||
provider: {
|
||||
providerNumber: serviceLocation.provider?.providerNumber,
|
||||
customer: {
|
||||
address: {
|
||||
streetAddress: serviceLocation.provider?.address?.streetAddress,
|
||||
city: serviceLocation.provider?.address?.city,
|
||||
state: serviceLocation.provider?.address?.state,
|
||||
zipCode: serviceLocation.provider?.address?.zipCode,
|
||||
zipCodeCtu: serviceLocation.provider?.address?.zipCodeCtu
|
||||
}
|
||||
streetAddress: customer.address?.streetAddress,
|
||||
streetAddress2: customer.address?.streetAddress2,
|
||||
city: customer.address?.city,
|
||||
state: customer.address?.state,
|
||||
zipCode: customer.address?.zipCode
|
||||
},
|
||||
emailAddress: contactInfo.emailAddress,
|
||||
firstName: contactInfo.firstName || customer.firstName,
|
||||
lastName: contactInfo.lastName || customer.lastName,
|
||||
phoneNumber: contactInfo.phoneNumber,
|
||||
optInSms: contactInfo.requestTextUpdates ?? false
|
||||
},
|
||||
techNotes: contactInfo.notesForTechnician
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
isVerified: payment.insuranceCoverage?.isVerified ?? false,
|
||||
coverageStatus: payment.insuranceCoverage?.coverageStatus,
|
||||
claimNumber: payment.insuranceCoverage?.claimNumber
|
||||
},
|
||||
parentAccountNumber: this.issConfig.parentAccountNumber
|
||||
},
|
||||
serviceLocation: {
|
||||
address: {
|
||||
streetAddress: serviceLocation.address,
|
||||
city: serviceLocation.city,
|
||||
state: serviceLocation.state,
|
||||
zipCode: serviceLocation.zipCode,
|
||||
zipCodeCtu: serviceLocation.zipCodeCtu
|
||||
},
|
||||
appointmentType: (serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
||||
|| serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP)
|
||||
? AppointmentTypeStrings.MOBILE : serviceLocation.appointmentType,
|
||||
isVehicleProtected: serviceLocation.isVehicleProtected,
|
||||
provider: {
|
||||
providerNumber: serviceLocation.provider?.providerNumber,
|
||||
address: {
|
||||
streetAddress: serviceLocation.provider?.address?.streetAddress,
|
||||
city: serviceLocation.provider?.address?.city,
|
||||
state: serviceLocation.provider?.address?.state,
|
||||
zipCode: serviceLocation.provider?.address?.zipCode,
|
||||
zipCodeCtu: serviceLocation.provider?.address?.zipCodeCtu
|
||||
}
|
||||
},
|
||||
techNotes: contactInfo.notesForTechnician
|
||||
},
|
||||
schedule: {
|
||||
date: schedule.date,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
routeCode: schedule.routeCode,
|
||||
jobMaxMinutes: schedule.jobMaxMinutes,
|
||||
jobMinMinutes: schedule.jobMinMinutes
|
||||
},
|
||||
referralDate: this.order.referralDate,
|
||||
referralNumber: this.order.referralNumber?.toString(),
|
||||
referralCorrelationId: this.order.referralCorrelationId,
|
||||
referralSequenceNumber: this.order.referralSequenceNumber,
|
||||
eon: this.order.eon
|
||||
},
|
||||
schedule: {
|
||||
date: schedule.date,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
routeCode: schedule.routeCode,
|
||||
jobMaxMinutes: schedule.jobMaxMinutes,
|
||||
jobMinMinutes: schedule.jobMinMinutes
|
||||
},
|
||||
referralDate: this.order.referralDate,
|
||||
referralNumber: this.order.referralNumber?.toString(),
|
||||
referralCorrelationId: this.order.referralCorrelationId,
|
||||
referralSequenceNumber: this.order.referralSequenceNumber,
|
||||
eon: this.order.eon
|
||||
},
|
||||
additionalSuccessEventDataHandler: (response) =>
|
||||
`Email provided: ${customer.emailAddress ? 'true' : 'false'}`
|
||||
additionalSuccessEventDataHandler: (response) =>
|
||||
`Email provided: ${customer.emailAddress ? 'true' : 'false'}`
|
||||
}).then((response) => resolve(response), (error) => reject(error));
|
||||
});
|
||||
},
|
||||
|
||||
loadSession() {
|
||||
const { applicationUser, order, issConfig } = this;
|
||||
// TODO how to get savedSessionId for a duplicate referral?
|
||||
return new Promise((resolve, reject) => {
|
||||
globalMethods.callHttpClient({
|
||||
method: endpoints.LoadSession.method,
|
||||
endpoint: endpoints.LoadSession.url,
|
||||
payload: {
|
||||
savedSessionId: applicationUser.savedSessionId?.toString(),
|
||||
referralNumber: order.referralNumber?.toString(),
|
||||
referralDate: order.referralDate?.toString(),
|
||||
parentAccountNumber: issConfig.parentAccountNumber,
|
||||
referralCorrelationId: order.referralCorrelationId
|
||||
}
|
||||
}).then((response) => {
|
||||
const { data } = response;
|
||||
if (!data) {
|
||||
// TODO how should we handle this case?
|
||||
return resolve(data);
|
||||
}
|
||||
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
|
||||
applicationUser.experiments = data.applicationUser?.experiments ?? [];
|
||||
applicationUser.lastPageVisited = data.applicationUser?.lastPage;
|
||||
applicationUser.pageData = data.applicationUser?.pageData ?? {};
|
||||
applicationUser.savedSessionId = data.applicationUser?.savedSessionId; // TODO this might just be what is passed
|
||||
applicationUser.hasSentSaveQuoteEmail = data.applicationUser?.hasSentSaveQuoteEmail;
|
||||
|
||||
order.vehicle.registration.licensePlate = data.order?.vehicle?.registration?.licensePlateNumber;
|
||||
order.vehicle.imageUrl = data.order?.vehicle?.imageUrl;
|
||||
order.vehicle.imageColor = data.order?.vehicle?.imageVifColor;
|
||||
order.vehicle.imageVifNumber = data.order?.vehicle?.imageVifNumber;
|
||||
order.vehicle.year = data.order?.vehicle?.year;
|
||||
order.vehicle.make = data.order?.vehicle?.make;
|
||||
order.vehicle.model = data.order?.vehicle?.model;
|
||||
order.vehicle.style = data.order?.vehicle?.style;
|
||||
order.vehicle.carId = data.order?.vehicle?.carId;
|
||||
order.vehicle.category = data.order?.vehicle?.category;
|
||||
order.vehicle.vin = data.order?.vehicle?.vin;
|
||||
|
||||
order.customer.emailAddress = data.order?.customer?.emailAddress;
|
||||
order.customer.firstName = data.order?.policy?.policyHolder?.policyFirstName;
|
||||
order.customer.lastName = data.order?.policy?.policyHolder?.policyLastName;
|
||||
order.customer.phoneNumber = data.order?.policy?.policyHolder?.policyPhoneNumber;
|
||||
|
||||
order.customer.address.streetAddress = data.order?.customer?.address?.streetAddress;
|
||||
order.customer.address.streetAddress2 = data.order?.customer?.address?.streetAddress2;
|
||||
order.customer.address.city = data.order?.customer?.address?.city;
|
||||
order.customer.address.state = data.order?.customer?.address?.state;
|
||||
order.customer.address.zipCode = data.order?.customer?.address?.zipCode;
|
||||
|
||||
order.damage.isRepair = data.order?.damage?.isRepair;
|
||||
order.damage.numberOfChips = data.order?.damage?.numberOfChips;
|
||||
order.damage.glassToReplace = data.order?.damage?.glassToReplace;
|
||||
order.damage.capabilityQuestionAnswers = data.order?.damage?.capabilityQuestionAnswers;
|
||||
order.damage.moldingQuestionAnswers = data.order?.damage?.moldingQuestionAnswers;
|
||||
order.damage.partQuestionAnswers = data.order?.damage?.partQuestionAnswers;
|
||||
|
||||
order.policy.policyNumber = data.order?.policy?.policyNumber;
|
||||
order.policy.policyZipCode = data.order?.policy?.policyZipCode;
|
||||
order.policy.noCoverage = data.order?.policy?.noCoverage;
|
||||
order.policy.policyLookupSuccessful = data.order?.policy?.policyLookupSuccessful; // TODO probably don't need to load this
|
||||
order.policy.dateOfLoss = data.order?.damage?.dateOfLoss;
|
||||
order.policy.damageCause = data.order?.damage?.damageCause;
|
||||
order.policy.damageState = data.order?.damage?.damageState;
|
||||
order.policy.damageCity = data.order?.damage?.damageCity;
|
||||
order.policy.isDamageGlassOnly = data.order?.damage?.isDamageGlassOnly;
|
||||
|
||||
order.originalDeductible = data.order?.policy?.originalDeductible;
|
||||
order.currentDeductible = data.order?.policy?.currentDeductible;
|
||||
|
||||
order.lineItems.glassParts = data.order?.lineItems?.glassParts;
|
||||
// TODO otherParts
|
||||
order.lineItems.supportingItems = data.order?.lineItems?.supportingItems;
|
||||
order.lineItems.vaps = data.order?.lineItems?.vaps;
|
||||
|
||||
order.payment.insuranceCoverage.isVerified = data.order?.payment?.insuranceCoverage?.isVerified;
|
||||
order.payment.insuranceCoverage.coverageStatus = data.order?.payment?.insuranceCoverage?.coverageStatus;
|
||||
const parentAccountNumber = Number.isNaN(data.order?.payment?.parentAccountNumber)
|
||||
? 0
|
||||
: data.order?.payment?.parentAccountNumber;
|
||||
order.payment.parentAccountNumber = parentAccountNumber;
|
||||
issConfig.parentAccountNumber = parentAccountNumber;
|
||||
order.payment.insuranceCoverage.claimNumber = data.order?.payment?.insuranceCoverage?.claimNumber;
|
||||
|
||||
order.serviceLocation.address = data.order?.serviceLocation?.streetAddress;
|
||||
order.serviceLocation.address2 = data.order?.serviceLocation?.streetAddress2;
|
||||
order.serviceLocation.city = data.order?.serviceLocation?.city;
|
||||
order.serviceLocation.state = data.order?.serviceLocation?.state;
|
||||
order.serviceLocation.zipCode = data.order?.serviceLocation?.zipCode;
|
||||
order.serviceLocation.zipCodeCtu = data.order?.serviceLocation?.zipCodeCtu;
|
||||
order.serviceLocation.appointmentType = data.order?.serviceLocation?.appointmentType;
|
||||
order.serviceLocation.isVehicleProtected = data.order?.serviceLocation?.isVehicleProtected;
|
||||
order.serviceLocation.provider.providerNumber = data.order?.serviceLocation?.provider?.providerNumber;
|
||||
order.serviceLocation.provider.address.streetAddress = data.order?.serviceLocation?.provider?.address?.streetAddress;
|
||||
order.serviceLocation.provider.address.city = data.order?.serviceLocation?.provider?.address?.city;
|
||||
order.serviceLocation.provider.address.state = data.order?.serviceLocation?.provider?.address?.state;
|
||||
order.serviceLocation.provider.address.zipCode = data.order?.serviceLocation?.provider?.address?.zipCode;
|
||||
order.serviceLocation.provider.address.zipCodeCtu = data.order?.serviceLocation?.provider?.address?.zipCodeCtu;
|
||||
|
||||
order.contactInfo.firstName = data.order?.customer?.firstName;
|
||||
order.contactInfo.lastName = data.order?.customer?.lastName;
|
||||
order.contactInfo.emailAddress = data.order?.customer?.emailAddress;
|
||||
order.contactInfo.phoneNumber = data.order?.customer?.phoneNumber;
|
||||
order.contactInfo.requestTextUpdates = data.order?.customer?.isSmsOptIn; // TODO confirm
|
||||
order.contactInfo.notesForTechnician = data.order?.serviceLocation?.techNotes;
|
||||
// TODO service phone number ??
|
||||
// TODO isSmsOptIn service ??
|
||||
|
||||
order.schedule.date = data.order?.schedule?.date;
|
||||
order.schedule.startTime = data.order?.schedule?.startTime;
|
||||
order.schedule.endTime = data.order?.schedule?.endTime;
|
||||
order.schedule.routeCode = data.order?.schedule?.routeCode;
|
||||
order.schedule.jobMaxMinutes = data.order?.schedule?.jobMaxMinutes;
|
||||
order.schedule.jobMinMinutes = data.order?.schedule?.jobMinMinutes;
|
||||
|
||||
order.referralNumber = data.order?.referralNumber;
|
||||
order.referralDate = data.order?.referralDate;
|
||||
order.referralCorrelationId = data.order?.referralCorrelationId;
|
||||
order.referralSequenceNumber = data.order?.referralSequenceNumber;
|
||||
order.eon = data.order?.eon;
|
||||
// TODO order.workOrderNumber not set, but this likely is not an issue since WON => will not return
|
||||
return resolve(data);
|
||||
}, (error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue