INSR-10111: More fixes/suggestions

- Setup on welcome page no longer async
- Fix welcome pageunit tests to properly mock getCarrierAccountInfo
This commit is contained in:
Alex Humphries 2026-06-29 13:00:06 -04:00
parent b2dd241f48
commit 87e04ad178
3 changed files with 13 additions and 37 deletions

View file

@ -63,7 +63,7 @@ export default {
return new Promise((resolve, reject) => {
const store = useMainStore();
const currentPageName = this.getPageNameByQueryString().toLowerCase();
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
const payloadAndAnalyticsData = { ...payload, AppName: 'ISS' };
const sessionKey = getSessionKeyValue();
const headers = {
@ -75,6 +75,10 @@ export default {
[headerKeys.SESSION_SEQUENCE_NUMBER]: sessionKey
};
console.log(`Making API call to ${endpoint} with method ${method}`);
if (endpoint.toLowerCase().includes(endpoints.RegisterClaim.url.toLowerCase()))
cfDistroUrl = "https://localhost:7249/";
const url = cfDistroUrl + endpoint;
axios({
method,

View file

@ -83,6 +83,11 @@ function setupMocks({
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
const mountOptions = getMountOptions(mockDataMountOptions);
useMainStore().getCarrierAccountInfo = jest.fn().mockImplementation(() => Promise.resolve({
data: {
phoneNumber: '1234567890'
}
}));
const wrapper = shallowMount(welcomePage, mountOptions);
@ -91,39 +96,6 @@ function setupMocks({
return { wrapper, apiPromise };
}
function getMountedComponent(mainInitialState = {}, initialData = {}) {
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
}
});
mountOptions.global.stubs = {
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true
};
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
mountOptions.data = () => (
initialData
);
const apiResponses = {
supportingItems: []
};
const apiPromise = Promise.resolve(apiResponses);
settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
const wrapper = shallowMount(welcomePage, mountOptions);
return { wrapper };
}
describe('welcome-page.vue', () => {
test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => {
// Arrange
@ -180,7 +152,7 @@ describe('navigation', () => {
describe('When zip code check succeeds', () => {
test('if duplicates found, navigate to duplicate check page', async () => {
// Arrange
const { wrapper } = getMountedComponent({});
const { wrapper } = setupMocks({});
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({

View file

@ -227,12 +227,12 @@ export default {
vm.checkContinueFromCookie();
});
},
async setup() {
setup() {
const mainStore = useMainStore();
// Set order account number from the issConfig.
mainStore.order.parentAccountNumber = mainStore.issConfig.parentAccountNumber;
await mainStore.getCarrierAccountInfo();
mainStore.getCarrierAccountInfo().catch((error) => console.error(`Error in getCarrierAccountInfo ${error}`));
return { mainStore };
},