Merge pull request #1299 from Safelite/feature/CSR-1422-Techreviewchanges

CSR-1422 - Added unit tests and other tech review changes
This commit is contained in:
Leah Schumann 2023-08-09 10:45:31 -04:00 committed by GitHub
commit 78efc06bf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 20 deletions

View file

@ -35,12 +35,10 @@ const storeMutations = {
UPDATE_SERVICE_ZIP: "updateServiceZip",
UPDATE_SERVICE_LOCATION: "updateServiceLocation",
UPDATE_SERVICE_LOCATION_TECH_NOTES: "updateServiceLocationTechNotes",
UPDATE_TECH_NOTES: "updateTechNotes",
UPDATE_SCHEDULE: "updateSchedule",
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
// CUSTOMER MUTATIONS
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
UPDATE_CUSTOMER_DETAILS: "updateCustomerDetails",
// ORDER MUTATIONS

View file

@ -32,7 +32,7 @@
<checkboxQuestion
class="mb-5"
cmsWidgetName="TextMeQuestionWidget"
v-model="isSmsOptin" />
v-model="isSmsOptIn" />
<textareaQuestion
class="mb-4"
v-model="techNotes"
@ -110,7 +110,7 @@ export default {
lastName: this.getLastNameFromStore(),
emailAddress: this.getEmailAddressFromStore(),
phoneNumber: this.getPhoneNumberFromStore(),
isSmsOptin: this.getIsSmsOptinFromStore(),
isSmsOptIn: this.getIsSmsOptInFromStore(),
techNotes: this.getTechNotesFromStore(),
};
},
@ -135,8 +135,8 @@ export default {
getPhoneNumberFromStore() {
return store.getters.order.customer.phoneNumber;
},
getIsSmsOptinFromStore() {
return store.getters.order.customer.isSmsOptin;
getIsSmsOptInFromStore() {
return store.getters.order.customer.isSmsOptIn;
},
getTechNotesFromStore() {
return store.getters.order.serviceLocation.techNotes;
@ -152,7 +152,7 @@ export default {
lastName: this.lastName,
emailAddress: this.emailAddress,
phoneNumber: this.phoneNumber,
isSmsOptin: this.isSmsOptin,
isSmsOptIn: this.isSmsOptIn,
},
false
);

View file

@ -66,7 +66,7 @@ const getDefaultState = () => {
lastName: null,
emailAddress: null,
phoneNumber: null,
isSmsOptin: null,
isSmsOptIn: null,
},
damage: {
isRepair: null,
@ -291,7 +291,7 @@ export const mutations = {
state.order.customer.lastName = customerDetails.lastName;
state.order.customer.emailAddress = customerDetails.emailAddress;
state.order.customer.phoneNumber = customerDetails.phoneNumber;
state.order.customer.isSmsOptin = customerDetails.isSmsOptin;
state.order.customer.isSmsOptIn = customerDetails.isSmsOptIn;
}
},
@ -493,7 +493,7 @@ export const mutations = {
state.order.customer.firstName = sessionInformation.order.customer.firstName;
state.order.customer.lastName = sessionInformation.order.customer.lastName;
state.order.customer.phoneNumber = sessionInformation.order.customer.phoneNumber;
state.order.customer.isSmsOptin = sessionInformation.order.customer.isSmsOptin;
state.order.customer.isSmsOptIn = sessionInformation.order.customer.isSmsOptIn;
state.order.existingPromoCode = sessionInformation.order.existingPromoCode;
state.applicationUser.experiments = sessionInformation.applicationUser.experiments;
@ -1406,7 +1406,7 @@ export const actions = {
emailAddress: order.customer.emailAddress,
firstName: order.customer.firstName,
lastName: order.customer.lastName,
isSmsOptin: order.customer.isSmsOptin,
isSmsOptIn: order.customer.isSmsOptIn,
phoneNumber: order.customer.phoneNumber,
},
damage: {

View file

@ -335,6 +335,28 @@ describe("Mutations", () => {
expect(storeState.order.serviceLocation.state).toEqual("OH");
expect(storeState.order.serviceLocation.zipCodeCtu).toEqual("01820");
});
it("updateCustomerDetails, should set customer details in state", () => {
// Arrange
const storeState = state;
const customerDetails = {
firstName: "foo",
lastName: "bar",
emailAddress: "foo@bar.com",
phoneNumber: "555-555-5555",
isSmsOptIn: true,
};
// Act
mutations.updateCustomerDetails(storeState, customerDetails);
// Assert
expect(state.order.customer.firstName).toEqual("foo");
expect(state.order.customer.lastName).toEqual("bar");
expect(state.order.customer.emailAddress).toEqual("foo@bar.com");
expect(state.order.customer.phoneNumber).toEqual("555-555-5555");
expect(state.order.customer.isSmsOptIn).toEqual(true);
});
});
describe("Actions", () => {
@ -938,7 +960,7 @@ describe("Actions", () => {
);
});
it("saveServiceZipCodeInfo, should call mutation and save zip code to state", () => {
it("saveServiceZipCodeInfo, should call mutation", () => {
// Arrange
const context = state;
const commit = jest.fn();
@ -953,7 +975,6 @@ describe("Actions", () => {
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo);
expect(state.order.serviceLocation.zipCode).toEqual("43212");
});
it("saveServiceZipCodeInfo, should reset if zip code is different", () => {
@ -1022,7 +1043,7 @@ describe("Actions", () => {
);
});
it("saveServiceLocation, should call mutation and save service address to state", () => {
it("saveServiceLocation, should call mutation", () => {
// Arrange
const context = state;
const commit = jest.fn();
@ -1041,11 +1062,6 @@ describe("Actions", () => {
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocation);
expect(state.order.serviceLocation.address).toEqual("123 Test Lane");
expect(state.order.serviceLocation.city).toEqual("Columbus");
expect(state.order.serviceLocation.zipCode).toEqual("43212");
expect(state.order.serviceLocation.state).toEqual("OH");
expect(state.order.serviceLocation.zipCodeCtu).toEqual("01820");
});
it("saveServiceLocation, should reset if zipcode is different", () => {
@ -1292,6 +1308,27 @@ describe("Actions", () => {
expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
});
it("saveCustomerDetails, should call mutation", () => {
// Arrange
const context = state;
const commit = jest.fn();
context.commit = commit;
const customerDetails = {
firstName: "foo",
lastName: "bar",
emailAddress: "foo@bar.com",
phoneNumber: "555-555-5555",
isSmsOptIn: true,
};
// Act
actions.saveCustomerDetails(context, customerDetails);
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_CUSTOMER_DETAILS, customerDetails);
});
it("saveGlassParts, should call mutation", () => {
// Arrange
const context = {