Fixed some logic and unit tests.
This commit is contained in:
parent
ecfbfb9588
commit
e31998db9c
3 changed files with 32 additions and 38 deletions
|
|
@ -402,37 +402,6 @@ describe('duplicateCheck.vue', () => {
|
|||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
test('Load session throws error => should bailout, should not navigate forward', async () => {
|
||||
// Arrange
|
||||
const selectedAnswer = getRandomString(6, 6);
|
||||
const { wrapper } = getMountedComponent({
|
||||
applicationUser: {
|
||||
duplicateOrders: [
|
||||
{
|
||||
vehicleYear: 'YEAR',
|
||||
vehicleMake: 'make',
|
||||
vehicleModel: 'MoDel',
|
||||
responseDate: '2018-03-01T01:12:34',
|
||||
referralNumber: getRandomString(6, 6),
|
||||
correlationId: selectedAnswer
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
await wrapper.setData({ selectedAnswer });
|
||||
const error = 'load session error';
|
||||
wrapper.vm.mainStore.loadSessionFromDuplicate = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.loadSessionFromDuplicate).toHaveBeenCalledTimes(1);
|
||||
expect(saveSession).not.toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.$router.navigate).not.toHaveBeenCalledWith();
|
||||
});
|
||||
test('coverageType deductible and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({
|
||||
|
|
|
|||
|
|
@ -152,7 +152,17 @@ export default {
|
|||
|
||||
if (selectedReferral) {
|
||||
// LoadSession will bailout on error.
|
||||
await this.mainStore.loadSessionFromDuplicate(selectedReferral);
|
||||
try
|
||||
{
|
||||
await this.mainStore.loadSessionFromDuplicate(selectedReferral);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
// No error handling here needed. Error is already logged.
|
||||
// If LoadSession fails, user gets redirected to bailout page. No need to call save session.
|
||||
// Return here to stop current navigation.
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If duplicate not found in list (unable to load), then call SaveSession to create referral.
|
||||
|
|
@ -167,14 +177,17 @@ export default {
|
|||
// SaveSession will bailout on error.
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: true, bailoutOnError: true });
|
||||
}
|
||||
|
||||
// Call getCoveragePolicyInfo to get the policy info.
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
}
|
||||
catch (error) {
|
||||
// No error handling here needed.
|
||||
// GetCoveragePolicyInfo handles exception / error internally. We do not care if it fails, user continues in unverified path.
|
||||
// No error handling here needed. Error is already logged.
|
||||
// Return here to stop current navigation.
|
||||
return;
|
||||
}
|
||||
|
||||
// Call getCoveragePolicyInfo to get the policy info.
|
||||
// GetCoveragePolicyInfo handles exception / error internally. We do not care if it fails, user continues in unverified path.
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
|
||||
|
||||
this.pushEventToGA("policy_search", "policy_found", this.mainStore.isPolicyLookupSuccessful ? "Yes" : "No", true);
|
||||
|
||||
|
|
|
|||
|
|
@ -354,13 +354,25 @@ export default {
|
|||
|
||||
// Skip duplicate check if loaded from cookie or already visited duplicate check page.
|
||||
if (!this.mainStore.order.loadedFromCookie && !this.mainStore.order.visitedDuplicateCheckPage) {
|
||||
// getDuplicateReferrals handles exception / error internally. We do not care if it fails, user continues with creating new referral.
|
||||
await this.mainStore.getDuplicateReferrals();
|
||||
|
||||
// If we do not have any duplicates.
|
||||
// Call SaveSession to create referral.
|
||||
// Then call getCoveragePolicyInfo to get the policy info.
|
||||
if (this.mainStore.applicationUser.duplicateOrders?.length === 0) {
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: true, bailoutOnError: true });
|
||||
try {
|
||||
// SaveSession will bailout on error.
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: true, bailoutOnError: true });
|
||||
}
|
||||
catch (error) {
|
||||
// No error handling here needed. Error is already logged.
|
||||
// Return here to stop current navigation.
|
||||
return;
|
||||
}
|
||||
|
||||
// Call getCoveragePolicyInfo to get the policy info.
|
||||
// GetCoveragePolicyInfo handles exception / error internally. We do not care if it fails, user continues in unverified path.
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
|
||||
this.pushEventToGA("policy_search", "policy_found", this.mainStore.isPolicyLookupSuccessful ? "Yes" : "No", true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue