SSR-1125 Update Phone Numbers

This commit is contained in:
Josh Dassinger 2024-04-11 09:53:33 -05:00
parent 4fb167db71
commit 1c6b56b4e9
12 changed files with 163 additions and 56 deletions

View file

@ -160,14 +160,16 @@ describe('contactDetails.vue', () => {
const firstName = getRandomString(4, 15);
const lastName = getRandomString(4, 15);
const emailAddress = getRandomString(10, 20);
const phoneNumber = getRandomInt(1000000000, 9999999999);
const servicePhone = getRandomInt(1000000000, 9999999999).toString();
const mainInitialState = {
order: {
customer: {
firstName,
lastName,
emailAddress,
phoneNumber
emailAddress
},
contactInfo: {
servicePhone
}
}
};
@ -185,7 +187,7 @@ describe('contactDetails.vue', () => {
expect(wrapper.vm.firstName).toBe(firstName);
expect(wrapper.vm.lastName).toBe(lastName);
expect(wrapper.vm.emailAddress).toBe(emailAddress);
expect(wrapper.vm.phoneNumber).toBe(phoneNumber);
expect(wrapper.vm.phoneNumber).toBe(servicePhone);
});
test('Mock store with contact info yields expected data', () => {
// Arrange
@ -199,7 +201,7 @@ describe('contactDetails.vue', () => {
firstName: getRandomString(4, 15),
lastName: getRandomString(4, 15),
emailAddress: getRandomString(10, 20),
phoneNumber: getRandomInt(1000000000, 9999999999),
servicePhone: getRandomInt(1000000000, 9999999999),
requestTextUpdates: getRandomBoolean(),
notesForTechnician: getRandomString(50, 100)
};
@ -224,7 +226,7 @@ describe('contactDetails.vue', () => {
expect(wrapper.vm.firstName).toBe(contactInfo.firstName);
expect(wrapper.vm.lastName).toBe(contactInfo.lastName);
expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress);
expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber);
expect(wrapper.vm.phoneNumber).toBe(contactInfo.servicePhone);
expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates);
expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician);
});
@ -315,7 +317,7 @@ describe('contactDetails.vue', () => {
const firstName = getRandomString(4, 15);
const lastName = getRandomString(4, 15);
const emailAddress = getRandomString(10, 20);
const phoneNumber = getRandomInt(1000000000, 9999999999);
const phoneNumber = getRandomInt(1000000000, 9999999999).toString();
const requestTextUpdates = getRandomBoolean();
const notesForTechnician = getRandomString(1, 100);
wrapper.setData({
@ -335,11 +337,60 @@ describe('contactDetails.vue', () => {
firstName,
lastName,
emailAddress,
phoneNumber,
requestTextUpdates,
notesForTechnician
});
});
test('Forward button click updates phone numbers request text updates', () => {
// Arrange
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
}
});
const wrapper = shallowMount(contactDetails, mountOptions);
const phoneNumber = getRandomInt(1000000000, 9999999999).toString();
const requestTextUpdates = true;
wrapper.setData({
phoneNumber,
requestTextUpdates
});
// Act
wrapper.vm.forwardButtonAction();
// Assert
expect(useMainStore().updatePhoneNumbers).toHaveBeenCalledWith({
service: phoneNumber,
alternative: phoneNumber
});
});
test('Forward button click updates phone numbers dot not request text updates', () => {
// Arrange
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
}
});
const wrapper = shallowMount(contactDetails, mountOptions);
const phoneNumber = getRandomInt(1000000000, 9999999999).toString();
const requestTextUpdates = false;
wrapper.setData({
phoneNumber,
requestTextUpdates
});
// Act
wrapper.vm.forwardButtonAction();
// Assert
expect(useMainStore().updatePhoneNumbers).toHaveBeenCalledWith({
home: phoneNumber,
service: phoneNumber
});
});
});
test('Mocked store with no contact info yields expected data', () => {
@ -349,20 +400,19 @@ describe('contactDetails.vue', () => {
const firstName = getRandomString(4, 15);
const lastName = getRandomString(4, 15);
const emailAddress = getRandomString(10, 20);
const phoneNumber = getRandomInt(1000000000, 9999999999);
const servicePhone = getRandomInt(1000000000, 9999999999);
const mainInitialState = {
order: {
customer: {
firstName,
lastName,
emailAddress,
phoneNumber
emailAddress
},
contactInfo: {
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null,
servicePhone,
requestTextUpdates: null,
notesForTechnician: null
}
@ -382,7 +432,7 @@ describe('contactDetails.vue', () => {
expect(wrapper.vm.firstName).toBe(firstName);
expect(wrapper.vm.lastName).toBe(lastName);
expect(wrapper.vm.emailAddress).toBe(emailAddress);
expect(wrapper.vm.phoneNumber).toBe(phoneNumber);
expect(wrapper.vm.phoneNumber).toBe(servicePhone);
});
test('Mock store with contact info yields expected data', () => {
@ -397,7 +447,7 @@ describe('contactDetails.vue', () => {
firstName: getRandomString(4, 15),
lastName: getRandomString(4, 15),
emailAddress: getRandomString(10, 20),
phoneNumber: getRandomInt(1000000000, 9999999999),
servicePhone: getRandomInt(1000000000, 9999999999),
requestTextUpdates: getRandomBoolean(),
notesForTechnician: getRandomString(50, 100)
};
@ -422,7 +472,7 @@ describe('contactDetails.vue', () => {
expect(wrapper.vm.firstName).toBe(contactInfo.firstName);
expect(wrapper.vm.lastName).toBe(contactInfo.lastName);
expect(wrapper.vm.emailAddress).toBe(contactInfo.emailAddress);
expect(wrapper.vm.phoneNumber).toBe(contactInfo.phoneNumber);
expect(wrapper.vm.phoneNumber).toBe(contactInfo.servicePhone);
expect(wrapper.vm.requestTextUpdates).toBe(contactInfo.requestTextUpdates);
expect(wrapper.vm.notesForTechnician).toBe(contactInfo.notesForTechnician);
});

View file

@ -139,14 +139,14 @@ export default {
const { firstName,
lastName,
emailAddress,
phoneNumber,
servicePhone,
requestTextUpdates,
notesForTechnician } = useMainStore().contactInfo;
return {
firstName,
lastName,
emailAddress,
phoneNumber,
phoneNumber: servicePhone,
requestTextUpdates,
notesForTechnician,
widget: {
@ -196,11 +196,23 @@ export default {
firstName: this.firstName,
lastName: this.lastName,
emailAddress: this.emailAddress,
phoneNumber: this.phoneNumber,
requestTextUpdates: this.requestTextUpdates,
notesForTechnician: this.notesForTechnician
};
useMainStore().updateContactInfo(contactInfo);
if (this.requestTextUpdates) {
useMainStore().updatePhoneNumbers({
service: this.phoneNumber,
alternative: this.phoneNumber
});
} else {
useMainStore().updatePhoneNumbers({
home: this.phoneNumber,
service: this.phoneNumber
});
}
const scenario = useMainStore().order.serviceLocation.IsSafeliteProvider === false
? this.navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP
: this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP;

View file

@ -76,7 +76,7 @@ const initialStore = {
contactInfo: {
firstName: 'Test',
lastName: 'Test',
phoneNumber: '111-111-1111',
servicePhone: '111-111-1111',
emailAddress: 'test@email.com'
}
}

View file

@ -318,7 +318,7 @@ export default {
const contactInfoReqs = !!(
contactInfo.firstName
&& contactInfo.lastName
&& contactInfo.phoneNumber
&& contactInfo.servicePhone
&& contactInfo.emailAddress
);

View file

@ -183,7 +183,7 @@ describe('payment-page.vue', () => {
firstName: 'first',
lastName: 'last',
emailAddress: 'builddigitaltest@safelite.com',
phoneNumber: '555-555-5555'
servicePhone: '555-555-5555'
},
damage: {
isRepair: false,

View file

@ -500,7 +500,7 @@ export default {
zipCode: this.getZipCode(),
firstName: useMainStore().order.contactInfo.firstName,
lastName: useMainStore().order.contactInfo.lastName,
phoneNumber: useMainStore().order.contactInfo.phoneNumber,
phoneNumber: useMainStore().order.contactInfo.servicePhone,
ctu: useMainStore().order.serviceLocation.zipCodeCtu,
referralCorrelationId: useMainStore().order.referralCorrelationId,
workOrderNumber: this.getWorkOrderNumber(),
@ -597,7 +597,7 @@ export default {
const contactInfoReqs = !!(
contactInfo.firstName
&& contactInfo.lastName
&& contactInfo.phoneNumber
&& contactInfo.servicePhone
&& contactInfo.emailAddress
);

View file

@ -35,14 +35,14 @@ describe('contact-details-drawer', () => {
const firstName = 'Frederick';
const lastName = 'Taylor';
const emailAddress = 'fred.tay@gmail.com';
const phoneNumber = '606-009-2943';
const servicePhone = '606-009-2943';
const mainInitialState = {
order: {
contactInfo: {
firstName,
lastName,
emailAddress,
phoneNumber
servicePhone
}
}
};
@ -81,7 +81,7 @@ describe('contact-details-drawer', () => {
firstName: 'Frederick',
lastName: 'Taylor',
emailAddress: 'fred.tay@gmail.com',
phoneNumber: '606-009-2943'
servicePhone: '606-009-2943'
}
}
};
@ -96,7 +96,9 @@ describe('contact-details-drawer', () => {
// Assert
expect(wrapper.emitted()['update-contact-details']).toBeTruthy();
expect(useMainStore().updateContactInfo).toBeCalledTimes(1);
expect(useMainStore().updateContactInfo).toBeCalledWith({ firstName, lastName, emailAddress, phoneNumber });
expect(useMainStore().updateContactInfo).toBeCalledWith({ firstName, lastName, emailAddress });
expect(useMainStore().updatePhoneNumbers).toBeCalledTimes(1);
expect(useMainStore().updatePhoneNumbers).toBeCalledWith({ home: phoneNumber, service: phoneNumber });
}
);
});

View file

@ -67,13 +67,13 @@ export default {
const { firstName,
lastName,
emailAddress,
phoneNumber } = useMainStore().contactInfo;
servicePhone } = useMainStore().contactInfo;
return {
isModalOpened: false,
firstName,
lastName,
emailAddress,
phoneNumber,
phoneNumber: servicePhone,
widget: {
title: 'ContactDetailsDrawerHeaderWidget',
firstNameQuestion: 'FirstNameQuestionWidget',
@ -119,21 +119,24 @@ export default {
const contactInfo = {
firstName: this.firstName,
lastName: this.lastName,
emailAddress: this.emailAddress,
phoneNumber: this.phoneNumber
emailAddress: this.emailAddress
};
useMainStore().updateContactInfo(contactInfo);
useMainStore().updatePhoneNumbers({
home: this.phoneNumber,
service: this.phoneNumber
});
this.$emit('update-contact-details');
},
resetFormValues() {
const { firstName,
lastName,
emailAddress,
phoneNumber } = useMainStore().contactInfo;
homePhone } = useMainStore().contactInfo;
this.firstName = firstName;
this.lastName = lastName;
this.emailAddress = emailAddress;
this.phoneNumber = phoneNumber;
this.phoneNumber = homePhone;
},
openModal() {
this.modal.openModal();

View file

@ -499,14 +499,14 @@ describe('tpa-submit', () => {
const firstName = 'Jones';
const lastName = 'Eddison';
const emailAddress = 'myname@gmail.com';
const phoneNumber = '0001112222';
const servicePhone = '0001112222';
const initialStore = {
order: {
contactInfo: {
firstName,
lastName,
emailAddress,
phoneNumber
servicePhone
}
}
};
@ -514,7 +514,7 @@ describe('tpa-submit', () => {
const expectedLine1 = 'Jones Eddison';
const expectedLine2 = emailAddress;
const expectedLine3 = 'some value returned';
toDisplayPhoneNumber.mockImplementation((number) => (number === phoneNumber ? expectedLine3 : ''));
toDisplayPhoneNumber.mockImplementation((number) => (number === servicePhone ? expectedLine3 : ''));
const contactInfoSectionIndex = 3;
// Act
@ -530,7 +530,7 @@ describe('tpa-submit', () => {
expect(contactInfoSection.lines[0]).toBe(expectedLine1);
expect(contactInfoSection.lines[1]).toBe(expectedLine2);
expect(contactInfoSection.lines[2]).toBe(expectedLine3);
expect(toDisplayPhoneNumber).toHaveBeenCalledWith(phoneNumber);
expect(toDisplayPhoneNumber).toHaveBeenCalledWith(servicePhone);
});
});
describe('computed', () => {

View file

@ -236,11 +236,11 @@ export default {
return [toTitleCase(this.companyName ?? ''), displayAddress, displayPhoneNumber];
},
getContactInfoLines() {
const { firstName, lastName, emailAddress, phoneNumber } = useMainStore().contactInfo;
const { firstName, lastName, emailAddress, servicePhone } = useMainStore().contactInfo;
return [
`${firstName} ${lastName}`,
emailAddress ?? '',
toDisplayPhoneNumber(phoneNumber)
toDisplayPhoneNumber(servicePhone)
];
}
},

View file

@ -23,7 +23,7 @@ import {
} from '@/helpers/policy-vehicle-helper';
import partTypeStrings from '@/constants/part-type-strings';
import bailoutMessage from '@/constants/bailoutMessage';
import bailoutCode from "@/constants/bailoutCode";
import bailoutCode from '@/constants/bailoutCode';
const storeId = 'main';
@ -120,7 +120,7 @@ export const getDefaultState = () => ({
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null
homePhone: null
},
serviceLocation: {
address: null,
@ -182,7 +182,9 @@ export const getDefaultState = () => ({
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null,
homePhone: null,
alternativePhone: null,
servicePhone: null,
requestTextUpdates: false,
notesForTechnician: ''
},
@ -308,7 +310,9 @@ export const useMainStore = defineStore({
firstName: s.order.contactInfo.firstName ?? s.order.customer.firstName,
lastName: s.order.contactInfo.lastName ?? s.order.customer.lastName,
emailAddress: s.order.contactInfo.emailAddress ?? s.order.customer.emailAddress,
phoneNumber: s.order.contactInfo.phoneNumber ?? s.order.customer.phoneNumber,
homePhone: s.order.contactInfo.homePhone,
alternativePhone: s.order.contactInfo.alternativePhone,
servicePhone: s.order.contactInfo.servicePhone,
requestTextUpdates: s.order.contactInfo.requestTextUpdates ?? false,
notesForTechnician: s.order.contactInfo.notesForTechnician
}),
@ -1228,8 +1232,10 @@ export const useMainStore = defineStore({
emailAddress: contactInfo.emailAddress || customer.emailAddress,
firstName: contactInfo.firstName || customer.firstName,
lastName: contactInfo.lastName || customer.lastName,
phoneNumber: contactInfo.phoneNumber,
optInSms: contactInfo.requestTextUpdates ?? false
homePhone: contactInfo.homePhone,
servicePhone: contactInfo.servicePhone,
alternativePhone: contactInfo.alternativePhone,
isSmsOptIn: contactInfo.requestTextUpdates ?? false
},
lineItems: {
glassParts: lineItems.glassParts,
@ -1336,7 +1342,8 @@ export const useMainStore = defineStore({
order.contactInfo.firstName = data?.customer?.firstName;
order.contactInfo.lastName = data?.customer?.lastName;
order.contactInfo.emailAddress = data?.customer?.emailAddress;
order.contactInfo.phoneNumber = data?.customer?.phoneNumber;
order.contactInfo.homePhone = data?.customer?.phoneNumber;
order.contactInfo.servicephone = data?.customer?.phoneNumber;
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
@ -1777,6 +1784,10 @@ export const useMainStore = defineStore({
this.order.policy.isDamageGlassOnly = welcomePageModel?.isDamageGlassOnly;
this.order.customer.phoneNumber = welcomePageModel?.phoneNumber;
this.order.customer.emailAddress = welcomePageModel?.email;
this.updatePhoneNumbers({
home: welcomePageModel?.phoneNumber,
service: welcomePageModel?.phoneNumber
});
},
updatePolicyHolderDetails(customerQuestions) {
this.order.customer.address.streetAddress = customerQuestions.addressQuestions.streetAddress;
@ -2123,11 +2134,17 @@ export const useMainStore = defineStore({
this.order.contactInfo.firstName = contactInfo?.firstName ?? '';
this.order.contactInfo.lastName = contactInfo?.lastName ?? '';
this.order.contactInfo.emailAddress = contactInfo?.emailAddress ?? '';
this.order.contactInfo.phoneNumber = contactInfo?.phoneNumber ?? '';
this.order.contactInfo.requestTextUpdates = contactInfo?.requestTextUpdates ?? false;
this.order.contactInfo.notesForTechnician = contactInfo?.notesForTechnician ?? '';
},
updatePhoneNumbers(phoneNumbers) {
const contact = this.order.contactInfo;
contact.homePhone = phoneNumbers.home !== undefined ? phoneNumbers.home : contact.homePhone;
contact.alternativePhone = phoneNumbers.alternative !== undefined ? phoneNumbers.alternative : contact.alternativePhone;
contact.servicePhone = phoneNumbers.service !== undefined ? phoneNumbers.service : contact.servicePhone;
},
GetExperimentsByUser(userId) {
return globalMethods.callHttpClient({
method: endpoints.GetExperimentsByUser.method,
@ -2279,8 +2296,11 @@ export const useMainStore = defineStore({
setBailoutContactInfo(contact) {
this.order.customer.firstName = contact.firstName;
this.order.customer.lastName = contact.lastName;
this.order.customer.phoneNumber = contact.phoneNumber;
this.order.customer.emailAddress = contact.email;
this.updatePhoneNumbers({
home: contact.phoneNumber,
service: contact.phoneNumber
});
this.pageData(issPageValues.BAILOUT_PAGE).submit = true;
},

View file

@ -478,7 +478,6 @@ describe('Store', () => {
const firstName = getRandomString(4, 10);
const lastName = getRandomString(5, 15);
const emailAddress = false;
const phoneNumber = getRandomInt(1000000000, 9999999999);
const requestTextUpdates = getRandomBoolean();
const notesForTechnician = getRandomString(50, 150);
@ -486,7 +485,6 @@ describe('Store', () => {
store.updateContactInfo({ firstName,
lastName,
emailAddress,
phoneNumber,
requestTextUpdates,
notesForTechnician });
@ -494,10 +492,27 @@ describe('Store', () => {
expect(store.contactInfo.firstName).toEqual(firstName);
expect(store.contactInfo.lastName).toEqual(lastName);
expect(store.contactInfo.emailAddress).toEqual(emailAddress);
expect(store.contactInfo.phoneNumber).toEqual(phoneNumber);
expect(store.contactInfo.requestTextUpdates).toEqual(requestTextUpdates);
expect(store.contactInfo.notesForTechnician).toEqual(notesForTechnician);
});
it('updatePhoneNumbers updates phone info in store', () => {
// Arrange
const homePhone = getRandomInt(1000000000, 9999999999);
const servicePhone = getRandomInt(1000000000, 9999999999);
const altPhone = getRandomInt(1000000000, 9999999999);
// Act
store.updatePhoneNumbers({
home: homePhone,
service: servicePhone,
alternative: altPhone
});
// Assert
expect(store.contactInfo.homePhone).toEqual(homePhone);
expect(store.contactInfo.servicePhone).toEqual(servicePhone);
expect(store.contactInfo.alternativePhone).toEqual(altPhone);
});
it('All null values => contact info set in store to all nulls', () => {
// Act
store.updateContactInfo({});
@ -506,7 +521,6 @@ describe('Store', () => {
expect(store.contactInfo.firstName).toEqual('');
expect(store.contactInfo.lastName).toEqual('');
expect(store.contactInfo.emailAddress).toEqual('');
expect(store.contactInfo.phoneNumber).toEqual('');
expect(store.contactInfo.requestTextUpdates).toEqual(false);
expect(store.contactInfo.notesForTechnician).toEqual('');
});
@ -708,12 +722,16 @@ describe('Store', () => {
const contactFirstName = getRandomString(6, 6);
const contactLastName = getRandomString(6, 6);
const contactEmail = getRandomString(6, 6);
const contactPhoneNumber = getRandomString(6, 6);
const contactHomePhone = getRandomString(6, 6);
const contactServicePhone = getRandomString(6, 6);
const contactAlternativePhone = getRandomString(6, 6);
const requestTextUpdates = getRandomBoolean();
store.order.contactInfo.firstName = contactFirstName;
store.order.contactInfo.lastName = contactLastName;
store.order.contactInfo.emailAddress = contactEmail;
store.order.contactInfo.phoneNumber = contactPhoneNumber;
store.order.contactInfo.homePhone = contactHomePhone;
store.order.contactInfo.servicePhone = contactServicePhone;
store.order.contactInfo.alternativePhone = contactAlternativePhone;
store.order.contactInfo.requestTextUpdates = requestTextUpdates;
store.order.customer.address.streetAddress = streetAddress;
store.order.customer.address.streetAddress2 = streetAddress2;
@ -740,8 +758,10 @@ describe('Store', () => {
emailAddress: contactEmail,
firstName: contactFirstName,
lastName: contactLastName,
phoneNumber: contactPhoneNumber,
optInSms: requestTextUpdates
homePhone: contactHomePhone,
servicePhone: contactServicePhone,
alternativePhone: contactAlternativePhone,
isSmsOptIn: requestTextUpdates
})
})
}));