Updated savesession logic on duplicate check page.
This commit is contained in:
parent
dd321370a3
commit
75720b2660
2 changed files with 42 additions and 21 deletions
|
|
@ -396,7 +396,8 @@ describe('duplicateCheck.vue', () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(saveSession).toHaveBeenCalledTimes(0);
|
||||
// When selection doesn't match any duplicate, saveSession should be called to create a new referral
|
||||
expect(saveSession).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.mainStore.loadSessionFromDuplicate).toHaveBeenCalledTimes(0);
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||
|
|
@ -429,7 +430,7 @@ describe('duplicateCheck.vue', () => {
|
|||
// Assert
|
||||
expect(wrapper.vm.mainStore.loadSessionFromDuplicate).toHaveBeenCalledTimes(1);
|
||||
expect(saveSession).not.toHaveBeenCalled();
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalledTimes(0);
|
||||
expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
test('coverageType deductible and policy vehicles returned => CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES', async () => {
|
||||
|
|
|
|||
|
|
@ -138,30 +138,50 @@ export default {
|
|||
async forwardButtonAction() {
|
||||
showIssLoadingModal(true);
|
||||
|
||||
try
|
||||
let callSaveSession = false;
|
||||
let selectedReferral = null;
|
||||
|
||||
// If user clicked forward without selecting an option or user click on "start a new claim" button.
|
||||
if (this.selectedAnswer == null || this.selectedAnswer === 'NewClaim') {
|
||||
// User did not pick a duplicate, so call SaveSession to create referral.
|
||||
callSaveSession = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If user clicked forward without selecting an option or user click on "start a new claim" button.
|
||||
if (this.selectedAnswer == null || this.selectedAnswer === 'NewClaim') {
|
||||
// Call SaveSession to create referral.
|
||||
selectedReferral =
|
||||
this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||
|
||||
if (!selectedReferral) {
|
||||
// If duplicate not found in list (unable to load), then call SaveSession to create referral.
|
||||
callSaveSession = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Call LoadSession if duplicate was found.
|
||||
if (selectedReferral) {
|
||||
try {
|
||||
await this.mainStore.loadSessionFromDuplicate(selectedReferral);
|
||||
}
|
||||
catch (error) {
|
||||
// LoadSession will bailout.
|
||||
}
|
||||
}
|
||||
|
||||
// Call SaveSession to create referral.
|
||||
if (callSaveSession) {
|
||||
try {
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: true, bailoutOnError: true });
|
||||
}
|
||||
else
|
||||
{
|
||||
const selectedReferral =
|
||||
this.mainStore.applicationUser.duplicateOrders.find((o) => o.correlationId === this.selectedAnswer);
|
||||
|
||||
if (selectedReferral) {
|
||||
await this.mainStore.loadSessionFromDuplicate(selectedReferral);
|
||||
}
|
||||
catch (error) {
|
||||
// SaveSession will bailout.
|
||||
}
|
||||
}
|
||||
|
||||
// Call getCoveragePolicyInfo to get the policy info.
|
||||
// Call getCoveragePolicyInfo to get the policy info.
|
||||
try {
|
||||
await this.mainStore.getCoveragePolicyInfo();
|
||||
}
|
||||
catch (error) {
|
||||
// No error handling here needed.
|
||||
// SaveSession will bailout.
|
||||
// LoadSession will bailout.
|
||||
// GetCoveragePolicyInfo handles exception / error internally.
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue