From 2a043a077ea4b9c95b84609bce5e1762079a2bb5 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Wed, 7 Feb 2024 15:05:46 -0500 Subject: [PATCH] route to carrier URL --- .../tpa-confirmation/tpa-confirmation.spec.js | 32 ++++++++++++++----- .../tpa-confirmation/tpa-confirmation.vue | 5 +-- src/router/index.js | 4 +++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js index 4a6901bc..20792266 100644 --- a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js +++ b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js @@ -9,7 +9,6 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { mount } from '@vue/test-utils'; import { createTestingPinia } from '@pinia/testing'; import bailoutMessage from '@/constants/bailoutMessage'; -import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; jest.mock('@/helpers/layout-helper.js', () => jest.fn()); @@ -40,7 +39,8 @@ const footerStub = { function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) { const mountOptions = getMountOptions({ router: { - navigate: jest.fn() + navigate: jest.fn(), + navigateToExternalUrl: jest.fn() } }); @@ -154,9 +154,15 @@ describe('TPAConfirmation.vue', () => { // Assert expect(deductibleBox.exists()).toBe(true); }); - test('Should render Site Footer', () => { + test('If Advanced flow, should display Site Footer', () => { // Arrange - const { wrapper } = getMountedComponent({}); + const carrierReturnUrl = 'testURL'; + const initialStore = { + issConfig: { + successReturnURL: carrierReturnUrl + } + }; + const { wrapper } = getMountedComponent(initialStore); // Act const siteFooter = wrapper.findComponent({ ref: 'siteFooter' }); @@ -164,6 +170,16 @@ describe('TPAConfirmation.vue', () => { // Assert expect(siteFooter.exists()).toBe(true); }); + test('If Essential flow, should not display Site Footer', () => { + // Arrange + const { wrapper } = getMountedComponent(); + + // Act + const siteFooter = wrapper.findComponent({ ref: 'siteFooter' }); + + // Assert + expect(siteFooter.isVisible()).toBe(false); + }); }); describe('Computed properties', () => { describe('Deductible Box value', () => { @@ -352,11 +368,12 @@ describe('TPAConfirmation.vue', () => { }); }); describe('Navigation', () => { - test.only('Forward button action, navigate forward with CLICKED_FORWARD scenario', () => { + test('If Advanced flow, forward button action navigates to carrier URL', () => { // Arrange + const carrierReturnUrl = 'testURL'; const initialStore = { issConfig: { - successReturnURL: 'testURL' + successReturnURL: carrierReturnUrl } }; const { wrapper } = getMountedComponent(initialStore); @@ -365,8 +382,7 @@ describe('TPAConfirmation.vue', () => { wrapper.vm.forwardButtonAction(); // Assert - expect(wrapper.vm.navigateForward) - .toHaveBeenCalled(); + expect(wrapper.vm.$router.navigateToExternalUrl).toHaveBeenCalledWith(carrierReturnUrl); }); }); }); diff --git a/src/layouts/tpa-confirmation/tpa-confirmation.vue b/src/layouts/tpa-confirmation/tpa-confirmation.vue index 4163cfff..3741f4b8 100644 --- a/src/layouts/tpa-confirmation/tpa-confirmation.vue +++ b/src/layouts/tpa-confirmation/tpa-confirmation.vue @@ -180,10 +180,7 @@ export default { methods: { async forwardButtonAction() { - this.navigateForward(); - }, - navigateForward() { - window.location.href = this.carrierUrl; + this.$router.navigateToExternalUrl(this.carrierUrl); }, getCustomValueFromString(str) { switch (str) { diff --git a/src/router/index.js b/src/router/index.js index 4578d427..bef88b03 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -182,6 +182,10 @@ router.navigateWithoutSaving = ( navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData); }; +router.navigateToExternalUrl = (url, optionalQuery = {}) => { + navigateToUrl(url, optionalQuery); +}; + // Get route information by page name. // This will reach out to the Cms and there is a 1:1 relationship between page names and route names. async function GetRouteInfoFromPageName(pageName) {