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:
commit
78efc06bf5
4 changed files with 55 additions and 20 deletions
|
|
@ -35,12 +35,10 @@ const storeMutations = {
|
||||||
UPDATE_SERVICE_ZIP: "updateServiceZip",
|
UPDATE_SERVICE_ZIP: "updateServiceZip",
|
||||||
UPDATE_SERVICE_LOCATION: "updateServiceLocation",
|
UPDATE_SERVICE_LOCATION: "updateServiceLocation",
|
||||||
UPDATE_SERVICE_LOCATION_TECH_NOTES: "updateServiceLocationTechNotes",
|
UPDATE_SERVICE_LOCATION_TECH_NOTES: "updateServiceLocationTechNotes",
|
||||||
UPDATE_TECH_NOTES: "updateTechNotes",
|
|
||||||
UPDATE_SCHEDULE: "updateSchedule",
|
UPDATE_SCHEDULE: "updateSchedule",
|
||||||
|
|
||||||
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
|
|
||||||
|
|
||||||
// CUSTOMER MUTATIONS
|
// CUSTOMER MUTATIONS
|
||||||
|
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
|
||||||
UPDATE_CUSTOMER_DETAILS: "updateCustomerDetails",
|
UPDATE_CUSTOMER_DETAILS: "updateCustomerDetails",
|
||||||
|
|
||||||
// ORDER MUTATIONS
|
// ORDER MUTATIONS
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<checkboxQuestion
|
<checkboxQuestion
|
||||||
class="mb-5"
|
class="mb-5"
|
||||||
cmsWidgetName="TextMeQuestionWidget"
|
cmsWidgetName="TextMeQuestionWidget"
|
||||||
v-model="isSmsOptin" />
|
v-model="isSmsOptIn" />
|
||||||
<textareaQuestion
|
<textareaQuestion
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
v-model="techNotes"
|
v-model="techNotes"
|
||||||
|
|
@ -110,7 +110,7 @@ export default {
|
||||||
lastName: this.getLastNameFromStore(),
|
lastName: this.getLastNameFromStore(),
|
||||||
emailAddress: this.getEmailAddressFromStore(),
|
emailAddress: this.getEmailAddressFromStore(),
|
||||||
phoneNumber: this.getPhoneNumberFromStore(),
|
phoneNumber: this.getPhoneNumberFromStore(),
|
||||||
isSmsOptin: this.getIsSmsOptinFromStore(),
|
isSmsOptIn: this.getIsSmsOptInFromStore(),
|
||||||
techNotes: this.getTechNotesFromStore(),
|
techNotes: this.getTechNotesFromStore(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -135,8 +135,8 @@ export default {
|
||||||
getPhoneNumberFromStore() {
|
getPhoneNumberFromStore() {
|
||||||
return store.getters.order.customer.phoneNumber;
|
return store.getters.order.customer.phoneNumber;
|
||||||
},
|
},
|
||||||
getIsSmsOptinFromStore() {
|
getIsSmsOptInFromStore() {
|
||||||
return store.getters.order.customer.isSmsOptin;
|
return store.getters.order.customer.isSmsOptIn;
|
||||||
},
|
},
|
||||||
getTechNotesFromStore() {
|
getTechNotesFromStore() {
|
||||||
return store.getters.order.serviceLocation.techNotes;
|
return store.getters.order.serviceLocation.techNotes;
|
||||||
|
|
@ -152,7 +152,7 @@ export default {
|
||||||
lastName: this.lastName,
|
lastName: this.lastName,
|
||||||
emailAddress: this.emailAddress,
|
emailAddress: this.emailAddress,
|
||||||
phoneNumber: this.phoneNumber,
|
phoneNumber: this.phoneNumber,
|
||||||
isSmsOptin: this.isSmsOptin,
|
isSmsOptIn: this.isSmsOptIn,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ const getDefaultState = () => {
|
||||||
lastName: null,
|
lastName: null,
|
||||||
emailAddress: null,
|
emailAddress: null,
|
||||||
phoneNumber: null,
|
phoneNumber: null,
|
||||||
isSmsOptin: null,
|
isSmsOptIn: null,
|
||||||
},
|
},
|
||||||
damage: {
|
damage: {
|
||||||
isRepair: null,
|
isRepair: null,
|
||||||
|
|
@ -291,7 +291,7 @@ export const mutations = {
|
||||||
state.order.customer.lastName = customerDetails.lastName;
|
state.order.customer.lastName = customerDetails.lastName;
|
||||||
state.order.customer.emailAddress = customerDetails.emailAddress;
|
state.order.customer.emailAddress = customerDetails.emailAddress;
|
||||||
state.order.customer.phoneNumber = customerDetails.phoneNumber;
|
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.firstName = sessionInformation.order.customer.firstName;
|
||||||
state.order.customer.lastName = sessionInformation.order.customer.lastName;
|
state.order.customer.lastName = sessionInformation.order.customer.lastName;
|
||||||
state.order.customer.phoneNumber = sessionInformation.order.customer.phoneNumber;
|
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.order.existingPromoCode = sessionInformation.order.existingPromoCode;
|
||||||
state.applicationUser.experiments = sessionInformation.applicationUser.experiments;
|
state.applicationUser.experiments = sessionInformation.applicationUser.experiments;
|
||||||
|
|
@ -1406,7 +1406,7 @@ export const actions = {
|
||||||
emailAddress: order.customer.emailAddress,
|
emailAddress: order.customer.emailAddress,
|
||||||
firstName: order.customer.firstName,
|
firstName: order.customer.firstName,
|
||||||
lastName: order.customer.lastName,
|
lastName: order.customer.lastName,
|
||||||
isSmsOptin: order.customer.isSmsOptin,
|
isSmsOptIn: order.customer.isSmsOptIn,
|
||||||
phoneNumber: order.customer.phoneNumber,
|
phoneNumber: order.customer.phoneNumber,
|
||||||
},
|
},
|
||||||
damage: {
|
damage: {
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,28 @@ describe("Mutations", () => {
|
||||||
expect(storeState.order.serviceLocation.state).toEqual("OH");
|
expect(storeState.order.serviceLocation.state).toEqual("OH");
|
||||||
expect(storeState.order.serviceLocation.zipCodeCtu).toEqual("01820");
|
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", () => {
|
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
|
// Arrange
|
||||||
const context = state;
|
const context = state;
|
||||||
const commit = jest.fn();
|
const commit = jest.fn();
|
||||||
|
|
@ -953,7 +975,6 @@ describe("Actions", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo);
|
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo);
|
||||||
expect(state.order.serviceLocation.zipCode).toEqual("43212");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("saveServiceZipCodeInfo, should reset if zip code is different", () => {
|
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
|
// Arrange
|
||||||
const context = state;
|
const context = state;
|
||||||
const commit = jest.fn();
|
const commit = jest.fn();
|
||||||
|
|
@ -1041,11 +1062,6 @@ describe("Actions", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocation);
|
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", () => {
|
it("saveServiceLocation, should reset if zipcode is different", () => {
|
||||||
|
|
@ -1292,6 +1308,27 @@ describe("Actions", () => {
|
||||||
expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
|
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", () => {
|
it("saveGlassParts, should call mutation", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const context = {
|
const context = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue