Merge branch 'develop' into feature/jzimmerman/INSR-10176

This commit is contained in:
Jeremy-Z 2026-06-30 10:00:09 -04:00
commit 517c4a673b
5 changed files with 37 additions and 36 deletions

View file

@ -5,7 +5,8 @@ const dynamicStrings = Object.freeze({
MODAL_LINK: 'modalLink', MODAL_LINK: 'modalLink',
TEXT_LINK: 'textLink', TEXT_LINK: 'textLink',
EXTERNAL_LINK: 'externalLink', EXTERNAL_LINK: 'externalLink',
PHONE_LINK: 'phoneLink' PHONE_LINK: 'phoneLink',
PHONE_NUMBER: 'phoneNumber'
}); });
export default dynamicStrings; export default dynamicStrings;

View file

@ -1,5 +1,6 @@
import dynamicStrings from '@/constants/dynamic-strings'; import dynamicStrings from '@/constants/dynamic-strings';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { toDisplayPhoneNumber } from '@/helpers/text-helper';
/** /**
* @function getStringWithCustomValues * @function getStringWithCustomValues
@ -45,6 +46,9 @@ function processWidgetItemForReplacement(widgetModel, key) {
if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) { if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) {
widgetModel[key] = mapStringToState(widgetModel[key]); widgetModel[key] = mapStringToState(widgetModel[key]);
} }
if (widgetModel[key].includes(dynamicStrings.PHONE_NUMBER)) {
widgetModel[key] = mapStringToPhoneNumber(widgetModel[key]);
}
return widgetModel[key]; return widgetModel[key];
} }
@ -317,6 +321,19 @@ function mapStringToState(str) {
return str.trimStart(); return str.trimStart();
} }
/**
* @function mapStringToPhoneNumber
* @param str
*/
export function mapStringToPhoneNumber(str) {
// Expected token format: {phoneNumber:##########} (or 11 digits).
const regexExp = new RegExp(`\\{${dynamicStrings.PHONE_NUMBER}:([^}]*)\\}`, 'g');
return str.replace(regexExp, (_match, rawValue) => {
const digits = (rawValue.match(/\d+/g) ?? []).join('');
return toDisplayPhoneNumber(digits);
});
}
/** /**
* @function getStoreValueFromString * @function getStoreValueFromString
* @param str * @param str

View file

@ -1,4 +1,4 @@
import { getStringWithCustomValues } from '@/helpers/cms-content-helper.js'; import { getStringWithCustomValues, mapStringToPhoneNumber } from '@/helpers/cms-content-helper.js';
describe('getStringWithCustomValues', () => { describe('getStringWithCustomValues', () => {
test.each([ test.each([
@ -16,3 +16,13 @@ describe('getStringWithCustomValues', () => {
expect(getStringWithCustomValues(str, customValueMap)).toBe(expected); expect(getStringWithCustomValues(str, customValueMap)).toBe(expected);
}); });
}); });
describe('mapStringToPhoneNumber', () => {
test.each([
['{phoneNumber:1234567890}', '123-456-7890'],
['{phoneNumber:12345678901}', '1-234-567-8901'],
['{phoneNumber:123}', ''],
])('mapStringToPhoneNumber(%s) should return %s', (str, expected) => {
expect(mapStringToPhoneNumber(str)).toBe(expected);
});
});

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

@ -232,6 +232,7 @@ export default {
// 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;
mainStore.getCarrierAccountInfo().catch((error) => console.error('Error in getCarrierAccountInfo', error));
return { mainStore }; return { mainStore };
}, },