Merge pull request #742 from Safelite/feature/CSR-779

Feature/csr 779
This commit is contained in:
CarlNation 2022-09-15 13:41:12 -04:00 committed by GitHub
commit 419b996c40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 23 deletions

View file

@ -181,13 +181,13 @@ export default {
state: zipCodeData.state,
}, false);
if (!zipCodeData.isZipValid) {
if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true;
return this.$refs.funnelFooter.removeLoader();
}
this.displayInvalidZipAlert = false;
if (!zipCodeData.isZipServiceable) {
if (!zipCodeData.isServiceable) {
this.displayNonServiceableZipAlert = true;
return this.$refs.funnelFooter.removeLoader();
}
@ -220,7 +220,6 @@ export default {
},
computed: {
AlertNonServiceableZipHeader(){
console.log(this.getCmsContent("AlertNonServiceableZipWidget", "HeadlineText"));
return this.getCmsContent("AlertNonServiceableZipWidget", "HeadlineText").replaceAll("{custom:serviceZip}", this.serviceZipCode);
},
AlertNonServiceableZipBody(){

View file

@ -226,6 +226,9 @@ function mockOutPromises(carId = 'C00000') {
const apiResponses = {
vehicleLookupResponse: {
carId: carId
},
zipCodeData: {
isValid: true, isServiceable: true, state: "OH"
}
};

View file

@ -238,13 +238,16 @@ export default {
resultKey: "vehicleLookupResponse",
promise: vehicleLookupResponse,
},
{
resultKey: "zipCodeData",
promise: this.getZipCodeData(this.serviceZipCode)
}
];
const resultMap = await settleAllPromises(promiseResultMap);
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
// If a Service Zip is entered and it is an invalid zip code (ex. 11111) then show an alert
const isZipValid = zipCodeData.isValid;
const isZipValid = resultMap.zipCodeData.isValid;
if (this.serviceZipCode && !isZipValid) {
this.displayInvalidZipAlert = true;
return this.$refs.funnelFooter.removeLoader();
@ -252,14 +255,14 @@ export default {
this.displayInvalidZipAlert = false;
// If either lookup fails, remove the loader and stop processing the page.
if (!resultMap.vehicleLookupResponse || !zipCodeData.isServiceable) {
if (!resultMap.vehicleLookupResponse || !resultMap.zipCodeData.isServiceable) {
// If the vehicle result is undefined, the vin entered was invalid.
if(!resultMap.vehicleLookupResponse) {
this.displayVinNotFoundAlert = true;
}
// Check if Service Zip entered is serviceable, if not display an alert
if (!zipCodeData.isServiceable) {
if (!resultMap.zipCodeData.isServiceable) {
this.displayNonServiceableZipAlert = true;
}
@ -293,7 +296,7 @@ export default {
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, {
zipCode: this.serviceZipCode,
state: zipCodeData.state,
state: resultMap.zipCodeData.state,
}, false);
return await this.navigateForward();

View file

@ -49,21 +49,12 @@ export default {
return footerInfoBox ? footerInfoBox.offsetHeight : 0;
},
async getZipCodeData(zipCode) {
const serviceZipValidationResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { zip: zipCode });
const promiseResultMap = [
{
resultKey: "serviceZipValidationResponse",
promise: serviceZipValidationResponse,
}
];
const resultMap = await settleAllPromises(promiseResultMap);
const serviceZipValidationResponse = await this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { zip: zipCode });
return {
isZipValid: resultMap.serviceZipValidationResponse.isValid,
isZipServiceable: resultMap.serviceZipValidationResponse.isServiceable,
state: resultMap.serviceZipValidationResponse.state
isValid: serviceZipValidationResponse.data.isValid,
isServiceable: serviceZipValidationResponse.data.isServiceable,
state: serviceZipValidationResponse.data.state
};
}
},

View file

@ -99,7 +99,7 @@ describe("baseMixin.js", () => {
test("getZipCodeData calls dispatch", () => {
const mixIn = getMixInInstance({});
mixIn.methods.dispatchStoreAction = jest.fn();
mixIn.methods.dispatchStoreAction.mockReturnValue({ isValid:true, isServiceable:true, state:"OH" });
mixIn.methods.dispatchStoreAction.mockReturnValue({data: { isValid:true, isServiceable:true, state:"OH" }});
const type = "";
const payload = { zip: 43015 };