Merge pull request #1034 from Safelite/feature/CSR-1093

Feature/csr 1093
This commit is contained in:
Leah Schumann 2023-03-30 13:07:41 -04:00 committed by GitHub
commit 2563da5f88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 201 additions and 24 deletions

View file

@ -545,7 +545,7 @@ describe("service-location.vue", () => {
expect(wrapper.vm.isServiceableInshop).toEqual(false);
});
test("isServiceableMobileOnly should be true if mobile is true and inshop is false.", async () => {
test("displayServiceableMobileOnly should be true if mobile is true and inshop is false.", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -569,10 +569,10 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(true);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(true);
});
test("isServiceableMobileOnly should be false if mobile is false.", async () => {
test("displayServiceableMobileOnly should be false if mobile is false.", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -596,10 +596,10 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(false);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(false);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false);
});
test("isServiceableMobileOnly should be false if inShop is true", async () => {
test("displayServiceableMobileOnly should be false if inShop is true", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -623,7 +623,115 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(false);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false);
});
test("displayNoShopsAlert should be true if inShop is false and mobile is false", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: false,
isRecalibrationServiceableInshop: false,
isGlassServiceableMobile: false,
isRecalibrationServiceableMobile: false,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(false);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.displayNoShopsAlert).toEqual(true);
});
test("displayNoShopsAlert should be false if inShop is true and mobile is true", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: true,
isRecalibrationServiceableInshop: true,
isGlassServiceableMobile: true,
isRecalibrationServiceableMobile: true,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.displayNoShopsAlert).toEqual(false);
});
test("displayNoShopsAlert should be false if inShop is true", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: true,
isRecalibrationServiceableInshop: true,
isGlassServiceableMobile: false,
isRecalibrationServiceableMobile: false,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(false);
expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.displayNoShopsAlert).toEqual(false);
});
test("displayNoShopsAlert should be false if mobile is true", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: false,
isRecalibrationServiceableInshop: false,
isGlassServiceableMobile: true,
isRecalibrationServiceableMobile: true,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.displayNoShopsAlert).toEqual(false);
});
});
@ -680,7 +788,7 @@ describe("service-location.vue", () => {
expect(wrapper.vm.isServiceableInshop).toEqual(false);
});
test("isServiceableMobileOnly should be true if mobile is true and inshop is false.", async () => {
test("displayServiceableMobileOnly should be true if mobile is true and inshop is false.", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -704,10 +812,10 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(true);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(true);
});
test("isServiceableMobileOnly should be false if mobile is false", async () => {
test("displayServiceableMobileOnly should be false if mobile is false", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -731,10 +839,10 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(false);
expect(wrapper.vm.isServiceableInshop).toEqual(false);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(false);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false);
});
test("isServiceableMobileOnly should be false if inShop is true", async () => {
test("displayServiceableMobileOnly should be false if inShop is true", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
@ -758,7 +866,7 @@ describe("service-location.vue", () => {
// Assert
expect(wrapper.vm.isServiceableMobile).toEqual(true);
expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.isServiceableMobileOnly).toEqual(false);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false);
});
});
@ -784,7 +892,7 @@ describe("service-location.vue", () => {
(c) => c(wrapper.vm)
);
const alertComponent = wrapper.findComponent('[data-test="mobileOnlyAlert"]');
const alertComponent = wrapper.findComponent({ ref: "alertMobileOnly" });
// Assert
expect(alertComponent.exists()).toBe(true);
@ -811,7 +919,61 @@ describe("service-location.vue", () => {
(c) => c(wrapper.vm)
);
const alertComponent = wrapper.findComponent('[data-test="mobileOnlyAlert"]');
const alertComponent = wrapper.findComponent({ ref: "alertMobileOnly" });
// Assert
expect(alertComponent.exists()).toBe(false);
});
test("Should show no-shop error if no shops are available.", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: false,
isRecalibrationServiceableInshop: false,
isGlassServiceableMobile: false,
isRecalibrationServiceableMobile: false,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
const alertComponent = wrapper.findComponent({ ref: "alertNoShops" });
// Assert
expect(alertComponent.exists()).toBe(true);
});
test("Should not show no-shop error if shops are available.", async () => {
// Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: true,
isRecalibrationServiceableInshop: true,
isGlassServiceableMobile: true,
isRecalibrationServiceableMobile: true,
})
);
const { wrapper } = setupMocks({});
// Act
await serviceLocation.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "serviceLocation" } },
undefined,
(c) => c(wrapper.vm)
);
const alertComponent = wrapper.findComponent({ ref: "alertNoShops" });
// Assert
expect(alertComponent.exists()).toBe(false);

View file

@ -14,20 +14,22 @@
linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget" />
<alert
ref="alertMilitaryBaseZip"
class="my-4"
cmsWidgetName="AlertMilitaryBaseZipWidget"
v-if="displayMilitaryZipAlert"
alertClass="alert-warning" />
<alert
ref="alertMobileOnly"
class="my-4"
cmsWidgetName="AlertMobileOnlyWidget"
v-if="isServiceableMobileOnly"
alertClass="alert-warning"
data-test="mobileOnlyAlert" />
v-if="displayServiceableMobileOnly"
alertClass="alert-warning" />
<alert
ref="alertNoShops"
class="my-4"
cmsWidgetName="AlertNoServiceWarningWidget"
v-if="displayNoServiceWarningAlert"
cmsWidgetName="AlertNoShopsWidget"
v-if="displayNoShopsAlert"
alertClass="alert-warning" />
<appointmentTypeQuestion
v-model="selectedAppointmentType"
@ -149,7 +151,6 @@ export default {
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
console.log(resultMap.serviceabilityDetails);
vm.setData(
resultMap.zipCodeData,
resultMap.serviceabilityDetails,
@ -216,9 +217,23 @@ export default {
return this.isGlassServiceableInshop;
}
},
isServiceableMobileOnly() {
displayServiceableMobileOnly() {
return this.isServiceableMobile && !this.isServiceableInshop;
},
displayNoShopsAlert() {
let mobileAvailable;
if (this.IsRecalibrationServiceableMobile == null) {
mobileAvailable = this.isGlassServiceableMobile;
} else {
mobileAvailable =
this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile;
}
const inshopAvailable =
this.isGlassServiceableInshop && this.isRecalibrationServiceableInshop;
return !inshopAvailable && !mobileAvailable;
},
},
methods: {
arePagePrerequisitesValid() {

View file

@ -43,7 +43,7 @@ const getDefaultState = () => {
state: null,
zipCode: null,
zipCodeCtu: null,
serviceType: null,
appointmentType: null,
},
customer: {
emailAddress: null,
@ -931,10 +931,10 @@ export const actions = {
return globalMethods.callMockHttpClient({
method: endpoints.GetServiceabilityDetails.method,
//TODO: Remove Mocky Endpoints
//endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable
endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable
//endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop
//endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile
endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options
//endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options
});
// TODO: Restore this when CSR-1104 is 100% complete