Final touches

This commit is contained in:
Michaela Brydon 2023-10-12 17:17:00 -04:00
parent 9efd351d9d
commit 3f6c8dbf93
5 changed files with 442 additions and 272 deletions

View file

@ -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,10 +267,11 @@ describe('contactDetails.vue', () => {
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
},
global: {
plugins: [createTestingPinia()]
}
// ,
// global: {
// plugins: [createTestingPinia()]
// }
});
const wrapper = shallowMount(contactDetails, mountOptions);
const firstName = getRandomString(4, 15);
@ -302,4 +303,81 @@ 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
}
}
};
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);
});
});

View file

@ -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: '09/23/1990T01:12:34',
referralNumber
}
]
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const expectedSubtext = '09/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: '11/01/2004T01:12:34',
referralNumber
}
]
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const expectedSubtext = '11/01/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: '02/30/1999T01:12:34',
referralNumber
}
]
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const expectedSubtext = '02/30/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: '03/01/2018T01:12:34',
referralNumber
}
]
}
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const expectedVehicle = 'Year Make Model';
const expectedDate = '03/01/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
}
]
}
};
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
}
]
}
};
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
}
]
}
};
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() }
@ -371,14 +451,14 @@ 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() }
@ -401,14 +481,14 @@ 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() }
@ -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', () => {
});
});
});
});
});

View file

@ -103,9 +103,10 @@ export default {
const vehicle = !!o.vehicleYear && !!o.vehicleMake && !!o.vehicleModel
? `${o.vehicleYear} ${o.vehicleMake} ${o.vehicleModel}`
: null;
const subtext = vehicle && o.responseDate
? `${vehicle}, ${this.getDateMinusTime(o.responseDate)}`
: (vehicle ?? '').concat(this.getDateMinusTime(o.responseDate) ?? '');
: (vehicle ?? '').concat(this.getDateMinusTime(o.responseDate ?? ''));
return {
Text: duplicateOrderText,
@ -131,9 +132,8 @@ export default {
async forwardButtonAction() {
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
await useMainStore().loadSession()
.finally(() => {
this.navigateForward();
});
.then(() => {}, () => {})
.finally(() => { this.navigateForward(); });
} else {
this.navigateForward();
}

View file

@ -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());
@ -294,7 +293,7 @@ describe('navigation', () => {
useMainStore().applicationUser.duplicateOrders = [];
// Act
await wrapper.vm.navigateForward();
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
@ -304,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();
});
});

View file

@ -309,6 +309,7 @@ export default {
async forwardButtonAction() {
this.mainStore.updatePolicyData(this.welcomePageModel);
await this.mainStore.getDuplicateReferrals()
.then(() => {}, () => {})
.finally(async () => {
if (this.isCoverageEnabled) {
await this.mainStore.getCoveragePolicyInfo();