diff --git a/src/layouts/entry-page/entry-page.vue b/src/layouts/entry-page/entry-page.vue index c53c9125..b627bc37 100644 --- a/src/layouts/entry-page/entry-page.vue +++ b/src/layouts/entry-page/entry-page.vue @@ -89,6 +89,7 @@ export default { this.unauthorized = !authorized; if (authorized) { + this.mainStore.applicationUser.coverageAttempts = 0; // Forced full location redirect here. We do not want the entry page as part of the router/flow/path history. window.location = `/?issPage=${issPageValues.WELCOME_PAGE}`; } diff --git a/src/layouts/welcome-page/welcome-page.spec.js b/src/layouts/welcome-page/welcome-page.spec.js index 70447e84..38733d63 100644 --- a/src/layouts/welcome-page/welcome-page.spec.js +++ b/src/layouts/welcome-page/welcome-page.spec.js @@ -219,6 +219,32 @@ describe('navigation', () => { expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled(); expect(wrapper.vm.mainStore.getCoveragePolicyInfo).toHaveBeenCalled(); }); + test('if maxCoverageLookupAttemptsReached is true, then getCoveragePolicyInfo not called', async () => { + // Arrange + const { wrapper } = getMountedComponent({}); + useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({})); + useMainStore().applicationUser.coverageLookupAttempts = 11; + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.mainStore.updatePolicyData).toHaveBeenCalled(); + expect(wrapper.vm.mainStore.getCoveragePolicyInfo).not.toHaveBeenCalled(); + }); + test('if maxCoverageLookupAttemptsReached is false, then getCoveragePolicyInfo called', async () => { + // Arrange + const { wrapper } = getMountedComponent({}); + useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({})); + useMainStore().applicationUser.coverageLookupAttempts = 10; + + // 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({}); diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue index c64371b5..c2b8c4ca 100644 --- a/src/layouts/welcome-page/welcome-page.vue +++ b/src/layouts/welcome-page/welcome-page.vue @@ -308,6 +308,9 @@ export default { }, isCoverageEnabled() { return this.mainStore.issConfig.isCoverageEnabled; + }, + maxCoverageLookupAttemptsReached() { + return this.mainStore.applicationUser.coverageLookupAttempts >= 11; } }, methods: { @@ -316,8 +319,10 @@ export default { await this.mainStore.getDuplicateReferrals() .then(() => {}, () => {}) .finally(async () => { - if (this.isCoverageEnabled) { + if (this.isCoverageEnabled && !this.maxCoverageLookupAttemptsReached) { await this.mainStore.getCoveragePolicyInfo()?.then(() => {}, () => {}); + } else { + this.mainStore.order.policy.policyLookupSuccessful = false; } this.navigateForward(); }); diff --git a/src/store/index.js b/src/store/index.js index 0c4b7ad1..415f7d1c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -185,7 +185,8 @@ const getDefaultState = () => ({ lastPageVisited: null, triggeredSiteEntry: false, // TODO not in save session duplicateOrders: [], - hasSentSaveQuoteEmail: null + hasSentSaveQuoteEmail: null, + coverageLookupAttempts: 0 }, issConfig: { clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name @@ -439,6 +440,8 @@ export const useMainStore = defineStore({ getCoveragePolicyInfo() { const { order } = this; const { policy } = order; + this.applicationUser.coverageAttempts += 1; + console.log(`Coverage lookup attempt #${this.applicationUser.coverageAttempts}. Max attempts allowed: 10.`); return new Promise((resolve, reject) => { globalMethods.callHttpClient({ method: endpoints.CoveragePolicyInfo.method,