INSR-10111: Address various Copilot comments
- Add unit tests for mapStringToPhoneNumber function - Remove console.log from mapStringToPhoneNumber function - Update welcome-page.vue to await getCarrierAccountInfo() in setup() - getCarrierAccountInfo() again when submitting order, in case of account# change - Change import for toDisplayPhoneNumber to use absolute path
This commit is contained in:
parent
3f4e6ebf3a
commit
1149939337
4 changed files with 18 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import dynamicStrings from '@/constants/dynamic-strings';
|
||||
import { useMainStore } from '@/store';
|
||||
import { toDisplayPhoneNumber } from './text-helper';
|
||||
import { toDisplayPhoneNumber } from '@/helpers/text-helper';
|
||||
|
||||
/**
|
||||
* @function getStringWithCustomValues
|
||||
|
|
@ -325,18 +325,16 @@ function mapStringToState(str) {
|
|||
* @function mapStringToPhoneNumber
|
||||
* @param str
|
||||
*/
|
||||
function mapStringToPhoneNumber(str) {
|
||||
export function mapStringToPhoneNumber(str) {
|
||||
const startIndex = str.indexOf(`{${dynamicStrings.PHONE_NUMBER}`);
|
||||
console.log('startIndex', startIndex);
|
||||
console.log('str', str);
|
||||
|
||||
let textToReplace = str.substring(startIndex, str.length);
|
||||
textToReplace = textToReplace.substring(0, textToReplace.indexOf('}') + 1);
|
||||
console.log('textToReplace', textToReplace);
|
||||
|
||||
const phoneNumber = textToReplace.substring(
|
||||
dynamicStrings.PHONE_NUMBER.length + 2,
|
||||
textToReplace.length - 1
|
||||
);
|
||||
console.log('phoneNumber', phoneNumber);
|
||||
const displayPhoneNumber = toDisplayPhoneNumber(phoneNumber);
|
||||
|
||||
const returnVal = str.replace(textToReplace, displayPhoneNumber);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { getStringWithCustomValues } from '@/helpers/cms-content-helper.js';
|
||||
import { getStringWithCustomValues, mapStringToPhoneNumber } from '@/helpers/cms-content-helper.js';
|
||||
|
||||
describe('getStringWithCustomValues', () => {
|
||||
test.each([
|
||||
|
|
@ -16,3 +16,13 @@ describe('getStringWithCustomValues', () => {
|
|||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -227,12 +227,12 @@ export default {
|
|||
vm.checkContinueFromCookie();
|
||||
});
|
||||
},
|
||||
setup() {
|
||||
async setup() {
|
||||
const mainStore = useMainStore();
|
||||
|
||||
// Set order account number from the issConfig.
|
||||
mainStore.order.parentAccountNumber = mainStore.issConfig.parentAccountNumber;
|
||||
mainStore.getCarrierAccountInfo();
|
||||
await mainStore.getCarrierAccountInfo();
|
||||
|
||||
return { mainStore };
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3162,6 +3162,7 @@ export const useMainStore = defineStore({
|
|||
if (this.hasSubmittedOrder()) {
|
||||
return;
|
||||
}
|
||||
await this.getCarrierAccountInfo();
|
||||
const submittedOrder = this.order;
|
||||
const { experiments } = this.applicationUser;
|
||||
const { issConfig, hasRecalibrationPart } = this;
|
||||
|
|
|
|||
Loading…
Reference in a new issue