From 67154e9192c1e5c4704eb23cdfa9afe622078351 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 29 Mar 2023 09:21:02 -0400 Subject: [PATCH 1/4] WIP --- .../service-location/service-location.vue | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index d8167ad57..d4f632374 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -16,7 +16,12 @@ + Date: Thu, 30 Mar 2023 09:37:30 -0400 Subject: [PATCH 2/4] Ready for unit tests --- src/layouts/service-location/service-location.vue | 9 ++++----- src/store/index.js | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 3a38ab2b4..e0a736a43 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -20,8 +20,8 @@ alertClass="alert-warning" /> { vm.setCmsContent(resultMap.cmsContent); - console.log(resultMap.serviceabilityDetails); vm.setData( resultMap.zipCodeData, resultMap.serviceabilityDetails, @@ -201,7 +200,7 @@ export default { return this.zipContainsMilitaryBase && isZipServiceableMobile; }, - displayNoServiceWarningAlert() { + displayNoShopsAlert() { let mobileAvailable; if (this.IsRecalibrationServiceableMobile == null) { mobileAvailable = this.isGlassServiceableMobile; @@ -213,7 +212,7 @@ export default { const inshopAvailable = this.isGlassServiceableInshop && this.isRecalibrationServiceableInshop; - return inshopAvailable && !mobileAvailable; + return !inshopAvailable && !mobileAvailable; }, }, methods: { diff --git a/src/store/index.js b/src/store/index.js index 77289926b..b9d43e2f4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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 From 322c52c9759c7cbc6a95335ad1c5707eb104d9a3 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 30 Mar 2023 11:01:49 -0400 Subject: [PATCH 3/4] Completed unit tests --- .../service-location/service-location.spec.js | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 27f431884..b0a06b16f 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -625,6 +625,114 @@ describe("service-location.vue", () => { expect(wrapper.vm.isServiceableInshop).toEqual(true); 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); + }); }); describe("should be based only on glass serviceability if recalibration is not defined.", () => { @@ -816,6 +924,60 @@ describe("service-location.vue", () => { // 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); + }); }); }); }); From 26256cfd50e95177ea1d83f5793a2410a1568373 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 30 Mar 2023 11:12:25 -0400 Subject: [PATCH 4/4] Changed serviceType under serviceLocation to appointmentType --- src/store/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index b9d43e2f4..2dbc7b2cc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -43,7 +43,7 @@ const getDefaultState = () => { state: null, zipCode: null, zipCodeCtu: null, - serviceType: null, + appointmentType: null, }, customer: { emailAddress: null,