SSR-600 Load Session Changes
This commit is contained in:
parent
c7ace8557d
commit
23503cd040
4 changed files with 150 additions and 220 deletions
|
|
@ -9,6 +9,49 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import { getRandomString } from '@/helpers/data-generation.js';
|
import { getRandomString } from '@/helpers/data-generation.js';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
|
|
||||||
|
// Mock fetchCmsContentForPage
|
||||||
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
doesCopyContainRouterLink: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock our module for promises.
|
||||||
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRunAfterInitializingStore = () => {}) {
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const testingPinia = createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
});
|
||||||
|
useMainStore(testingPinia);
|
||||||
|
methodToRunAfterInitializingStore();
|
||||||
|
|
||||||
|
mountOptions.global.plugins = [testingPinia];
|
||||||
|
mountOptions.data = () => (initialData);
|
||||||
|
|
||||||
|
const apiResponses = { cmsContent: {} };
|
||||||
|
|
||||||
|
settleAllPromises.mockImplementation(() => apiResponses);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
||||||
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {});
|
||||||
|
wrapper.vm.setCmsContent = jest.fn();
|
||||||
|
wrapper.vm.$router.navigateWithSpinner = jest.fn();
|
||||||
|
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||||
|
|
||||||
|
return { wrapper };
|
||||||
|
}
|
||||||
|
|
||||||
const duplicateOrderText = 'Finish Existing Claim';
|
const duplicateOrderText = 'Finish Existing Claim';
|
||||||
|
|
||||||
|
|
@ -60,56 +103,30 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('duplicateOrders computed', () => {
|
describe('duplicateOrders computed', () => {
|
||||||
test('duplicateOrders in store undefined => returns empty list', () => {
|
test('duplicateOrders in store undefined => returns empty list', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: undefined
|
duplicateOrders: undefined
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||||
});
|
});
|
||||||
test('duplicateOrders in store empty => returns empty list', () => {
|
test('duplicateOrders in store empty => returns empty list', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: []
|
duplicateOrders: []
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
expect(wrapper.vm.duplicateOrders.length).toBe(0);
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
test('duplicateOrder in store with null vehicle year => returns order with only date in subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -117,19 +134,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: getRandomString(5, 5),
|
vehicleMake: getRandomString(5, 5),
|
||||||
vehicleModel: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
responseDate: '1990-09-23T01:12:34',
|
responseDate: '1990-09-23T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(5, 5)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '9/23/1990';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '9/23/1990';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -137,17 +149,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -155,19 +163,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: null,
|
vehicleMake: null,
|
||||||
vehicleModel: getRandomString(5, 5),
|
vehicleModel: getRandomString(5, 5),
|
||||||
responseDate: '2004-11-01T01:12:34',
|
responseDate: '2004-11-01T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '11/1/2004';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '11/1/2004';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -175,17 +178,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -193,19 +192,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: getRandomString(6, 6),
|
vehicleMake: getRandomString(6, 6),
|
||||||
vehicleModel: null,
|
vehicleModel: null,
|
||||||
responseDate: '1999-01-15T01:12:34',
|
responseDate: '1999-01-15T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedSubtext = '1/15/1999';
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
const expectedSubtext = '1/15/1999';
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
|
|
@ -213,17 +207,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext,
|
SubText: expectedSubtext,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
duplicateOrders: [
|
duplicateOrders: [
|
||||||
{
|
{
|
||||||
|
|
@ -231,28 +221,23 @@ describe('duplicateCheck.vue', () => {
|
||||||
vehicleMake: 'make',
|
vehicleMake: 'make',
|
||||||
vehicleModel: 'MoDel',
|
vehicleModel: 'MoDel',
|
||||||
responseDate: '2018-03-01T01:12:34',
|
responseDate: '2018-03-01T01:12:34',
|
||||||
referralNumber
|
referralNumber,
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
const expectedVehicle = 'Year Make Model';
|
const expectedVehicle = 'Year Make Model';
|
||||||
const expectedDate = '3/1/2018';
|
const expectedDate = '3/1/2018';
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
expect(wrapper.vm.duplicateOrders.length).toBe(1);
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: `${expectedVehicle}, ${expectedDate}`,
|
SubText: `${expectedVehicle}, ${expectedDate}`,
|
||||||
value: useMainStore().applicationUser.duplicateOrders[0]
|
value: useMainStore().applicationUser.duplicateOrders[0].correlationId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -336,11 +321,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
test('Back button clicked triggers navigation', () => {
|
test('Back button clicked triggers navigation', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(duplicateCheck, getMountOptions({
|
|
||||||
router: {
|
const { wrapper } = getMountedComponent({});
|
||||||
navigateWithSpinner: jest.fn()
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -355,21 +337,22 @@ describe('duplicateCheck.vue', () => {
|
||||||
describe('forwardButtonAction', () => {
|
describe('forwardButtonAction', () => {
|
||||||
test('Selected duplicate => load session called', async () => {
|
test('Selected duplicate => load session called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const selectedAnswer = getRandomString(6, 6);
|
||||||
const selectedAnswer = {};
|
const { wrapper } = getMountedComponent({
|
||||||
|
applicationUser: {
|
||||||
const mountOptions = getMountOptions({
|
duplicateOrders: [
|
||||||
router: { navigate: jest.fn() }
|
{
|
||||||
});
|
vehicleYear: 'YEAR',
|
||||||
mountOptions.mixins = [{
|
vehicleMake: 'make',
|
||||||
methods: {
|
vehicleModel: 'MoDel',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
responseDate: '2018-03-01T01:12:34',
|
||||||
? [{ Name: newOrderSelectionName }]
|
referralNumber: getRandomString(6, 6),
|
||||||
: ''))
|
correlationId: selectedAnswer
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer });
|
wrapper.setData({ selectedAnswer });
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
|
||||||
|
|
@ -383,19 +366,21 @@ describe('duplicateCheck.vue', () => {
|
||||||
test('Selected new order => load session not called', async () => {
|
test('Selected new order => load session not called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const newOrderSelectionName = getRandomString(6, 6);
|
||||||
|
const { wrapper } = getMountedComponent({
|
||||||
const mountOptions = getMountOptions({
|
applicationUser: {
|
||||||
router: { navigate: jest.fn() }
|
duplicateOrders: [
|
||||||
});
|
{
|
||||||
mountOptions.mixins = [{
|
vehicleYear: 'YEAR',
|
||||||
methods: {
|
vehicleMake: 'make',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
vehicleModel: 'MoDel',
|
||||||
? [{ Name: newOrderSelectionName }]
|
responseDate: '2018-03-01T01:12:34',
|
||||||
: ''))
|
referralNumber: getRandomString(6, 6),
|
||||||
|
correlationId: getRandomString(6, 6)
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer: newOrderSelectionName });
|
wrapper.setData({ selectedAnswer: newOrderSelectionName });
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
|
||||||
|
|
@ -408,21 +393,22 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('Load session throws error => still navigate forward', async () => {
|
test('Load session throws error => still navigate forward', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const selectedAnswer = getRandomString(6, 6);
|
||||||
const selectedAnswer = {};
|
const { wrapper } = getMountedComponent({
|
||||||
|
applicationUser: {
|
||||||
const mountOptions = getMountOptions({
|
duplicateOrders: [
|
||||||
router: { navigate: jest.fn() }
|
{
|
||||||
});
|
vehicleYear: 'YEAR',
|
||||||
mountOptions.mixins = [{
|
vehicleMake: 'make',
|
||||||
methods: {
|
vehicleModel: 'MoDel',
|
||||||
getCmsContent: jest.fn().mockImplementation((_, label) => (label === 'Answers'
|
responseDate: '2018-03-01T01:12:34',
|
||||||
? [{ Name: newOrderSelectionName }]
|
referralNumber: getRandomString(6, 6),
|
||||||
: ''))
|
correlationId: selectedAnswer
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}];
|
});
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
wrapper.setData({ selectedAnswer });
|
wrapper.setData({ selectedAnswer });
|
||||||
const error = 'load session error';
|
const error = 'load session error';
|
||||||
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
useMainStore().loadSession = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||||
|
|
@ -436,25 +422,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
test('policyLookupSuccessful true and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
vehicles: [{ test: 'a' }]
|
vehicles: [{ test: 'a' }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -466,25 +441,14 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
test('policyLookupSuccessful true and no policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
vehicles: []
|
vehicles: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -496,24 +460,13 @@ describe('duplicateCheck.vue', () => {
|
||||||
});
|
});
|
||||||
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
test('policyLookupSuccessful false => CLICKED_FORWARD_POLICY_UNVERIFIED', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: false
|
policyLookupSuccessful: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -523,14 +476,11 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -541,14 +491,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -558,14 +501,11 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with non policy vehicle => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const vin = getRandomString(17, 17);
|
const vin = getRandomString(17, 17);
|
||||||
const mainInitialState = {
|
const { wrapper } = getMountedComponent({
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -576,14 +516,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -593,13 +526,10 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, undefined);
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
test('policyLookupSuccessful true and loaded duplicate with no policy vehicles => CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NO_POLICY_VEHICLES', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const { wrapper } = getMountedComponent({
|
||||||
router: { navigate: jest.fn() }
|
|
||||||
});
|
|
||||||
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
order: {
|
||||||
policy: {
|
policy: {
|
||||||
policyLookupSuccessful: true,
|
policyLookupSuccessful: true,
|
||||||
|
|
@ -610,14 +540,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
},
|
},
|
||||||
loadedFromDupeCheck: true
|
loadedFromDupeCheck: true
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
})];
|
|
||||||
|
|
||||||
const wrapper = shallowMount(duplicateCheck, mountOptions);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,10 @@ export default {
|
||||||
vm.setCmsContent(cmsContent);
|
vm.setCmsContent(cmsContent);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setup() {
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
return { mainStore };
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedAnswer: null,
|
selectedAnswer: null,
|
||||||
|
|
@ -99,7 +103,7 @@ export default {
|
||||||
},
|
},
|
||||||
duplicateOrders() {
|
duplicateOrders() {
|
||||||
const duplicateOrderText = 'Finish Existing Claim';
|
const duplicateOrderText = 'Finish Existing Claim';
|
||||||
const orders = useMainStore().applicationUser.duplicateOrders;
|
const orders = this.mainStore.applicationUser.duplicateOrders;
|
||||||
return orders?.map((o) => {
|
return orders?.map((o) => {
|
||||||
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
|
||||||
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
|
||||||
|
|
@ -114,7 +118,7 @@ export default {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: o.referralNumber,
|
Name: o.referralNumber,
|
||||||
SubText: toTitleCase(subtext),
|
SubText: toTitleCase(subtext),
|
||||||
value: o
|
value: o.correlationId
|
||||||
};
|
};
|
||||||
}) ?? [];
|
}) ?? [];
|
||||||
},
|
},
|
||||||
|
|
@ -127,13 +131,16 @@ export default {
|
||||||
* @summary Steps to perform when forward button clicked.
|
* @summary Steps to perform when forward button clicked.
|
||||||
*/
|
*/
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.selectedAnswer !== null && typeof this.selectedAnswer === 'object') {
|
if (this.selectedAnswer !== null) {
|
||||||
await useMainStore().loadSession(this.selectedAnswer)
|
const selectedReferral = this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||||
.catch(() => {})
|
if (selectedReferral) {
|
||||||
.finally(() => {
|
await this.mainStore.loadSession(selectedReferral)
|
||||||
this.navigateForward();
|
.catch(() => {})
|
||||||
});
|
.finally(() => {
|
||||||
return;
|
this.navigateForward();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.navigateForward();
|
this.navigateForward();
|
||||||
|
|
|
||||||
|
|
@ -1342,7 +1342,7 @@ export const useMainStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadSession(duplicate) {
|
async loadSession(duplicate) {
|
||||||
const { applicationUser, order, issConfig } = this;
|
const { order, issConfig } = this;
|
||||||
try {
|
try {
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
method: endpoints.LoadSession.method,
|
method: endpoints.LoadSession.method,
|
||||||
|
|
@ -1351,7 +1351,7 @@ export const useMainStore = defineStore({
|
||||||
referralNumber: duplicate.referralNumber,
|
referralNumber: duplicate.referralNumber,
|
||||||
referralDate: duplicate.responseDate,
|
referralDate: duplicate.responseDate,
|
||||||
parentAccountNumber: issConfig.parentAccountNumber,
|
parentAccountNumber: issConfig.parentAccountNumber,
|
||||||
referralCorrelationId: duplicate.referralCorrelationId
|
referralCorrelationId: duplicate.correlationId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
|
|
@ -1374,8 +1374,8 @@ export const useMainStore = defineStore({
|
||||||
order.contactInfo.firstName = data?.customer?.firstName;
|
order.contactInfo.firstName = data?.customer?.firstName;
|
||||||
order.contactInfo.lastName = data?.customer?.lastName;
|
order.contactInfo.lastName = data?.customer?.lastName;
|
||||||
order.contactInfo.emailAddress = data?.customer?.emailAddress;
|
order.contactInfo.emailAddress = data?.customer?.emailAddress;
|
||||||
order.contactInfo.homePhone = data?.customer?.phoneNumber;
|
order.contactInfo.homePhone = data?.customer?.homePhone;
|
||||||
order.contactInfo.servicephone = data?.customer?.phoneNumber;
|
order.contactInfo.servicephone = data?.customer?.homePhone;
|
||||||
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
|
||||||
|
|
||||||
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
|
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
|
||||||
|
|
|
||||||
|
|
@ -1149,7 +1149,7 @@ describe('Store', () => {
|
||||||
expect(store.order.customer.firstName).toBe(customer.firstName);
|
expect(store.order.customer.firstName).toBe(customer.firstName);
|
||||||
expect(store.order.customer.lastName).toBe(customer.lastName);
|
expect(store.order.customer.lastName).toBe(customer.lastName);
|
||||||
expect(store.order.customer.emailAddress).toBe(customer.emailAddress);
|
expect(store.order.customer.emailAddress).toBe(customer.emailAddress);
|
||||||
expect(store.order.contactInfo.homePhone).toBe(customer.phoneNumber);
|
expect(store.order.contactInfo.homePhone).toBe(customer.homePhone);
|
||||||
});
|
});
|
||||||
it('sets expected remaining order data', async () => {
|
it('sets expected remaining order data', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue