Merge pull request #547 from Safelite/feature/SSR-1107

Feature/ssr 1107
This commit is contained in:
katiekroell 2024-02-07 15:41:13 -05:00 committed by GitHub
commit 043494072e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 25 deletions

View file

@ -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', () => {
@ -351,19 +367,23 @@ describe('TPAConfirmation.vue', () => {
);
});
});
// TODO: Add tests for forward navigation to carrier URL - card SSR-1107
describe('Navigation', () => {
// test('Forward button action, navigate forward with CLICKED_FORWARD scenario', () => {
// // Arrange
// const { wrapper } = getMountedComponent({});
test('If Advanced flow, forward button action navigates to carrier URL', () => {
// Arrange
const carrierReturnUrl = 'testURL';
const initialStore = {
issConfig: {
successReturnURL: carrierReturnUrl
}
};
const { wrapper } = getMountedComponent(initialStore);
// // Act
// wrapper.vm.forwardButtonAction();
// Act
wrapper.vm.forwardButtonAction();
// // Assert
// expect(wrapper.vm.$router.navigate)
// .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD);
// });
// Assert
expect(wrapper.vm.$router.navigateToExternalUrl).toHaveBeenCalledWith(carrierReturnUrl);
});
});
});
});

View file

@ -54,6 +54,7 @@
:value="deductibleBoxValue" />
</div>
<siteFooter
v-if="carrierUrl"
ref="siteFooter"
cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid"
@ -168,24 +169,18 @@ export default {
return this.mainStore.issConfig.clientName;
},
carrierUrl() {
const url = this.mainStore.issConfig.successReturnURL;
console.log(url);
return url;
return this.mainStore.issConfig.successReturnURL;
}
},
mounted() {
this.$refs.siteFooter.updateButtonText(`Go back to ${this.carrierName}`);
if (this.carrierUrl) {
this.$refs.siteFooter.updateButtonText(`Go back to ${this.carrierName}`);
}
},
methods:
{
async forwardButtonAction() {
window.location.href = this.carrierUrl;
},
navigateForward() {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
this.$router.navigateToExternalUrl(this.carrierUrl);
},
getCustomValueFromString(str) {
switch (str) {

View file

@ -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) {