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) => { return new Promise((resolve, reject) => {
const store = useMainStore(); const store = useMainStore();
const currentPageName = this.getPageNameByQueryString().toLowerCase(); const currentPageName = this.getPageNameByQueryString().toLowerCase();
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
const payloadAndAnalyticsData = { ...payload, AppName: 'ISS' }; const payloadAndAnalyticsData = { ...payload, AppName: 'ISS' };
const sessionKey = getSessionKeyValue(); const sessionKey = getSessionKeyValue();
const headers = { const headers = {
@ -75,6 +75,10 @@ export default {
[headerKeys.SESSION_SEQUENCE_NUMBER]: sessionKey [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; const url = cfDistroUrl + endpoint;
axios({ axios({
method, method,

View file

@ -83,6 +83,11 @@ function setupMocks({
fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
const mountOptions = getMountOptions(mockDataMountOptions); const mountOptions = getMountOptions(mockDataMountOptions);
useMainStore().getCarrierAccountInfo = jest.fn().mockImplementation(() => Promise.resolve({
data: {
phoneNumber: '1234567890'
}
}));
const wrapper = shallowMount(welcomePage, mountOptions); const wrapper = shallowMount(welcomePage, mountOptions);
@ -91,39 +96,6 @@ function setupMocks({
return { wrapper, apiPromise }; 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', () => { describe('welcome-page.vue', () => {
test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => { test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => {
// Arrange // Arrange
@ -180,7 +152,7 @@ describe('navigation', () => {
describe('When zip code check succeeds', () => { describe('When zip code check succeeds', () => {
test('if duplicates found, navigate to duplicate check page', async () => { test('if duplicates found, navigate to duplicate check page', async () => {
// Arrange // Arrange
const { wrapper } = getMountedComponent({}); const { wrapper } = setupMocks({});
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({})); useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }]; useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({ wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({

View file

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