From f18032d92ef7a7c9c65d105998f8e70c3dc11eac Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 30 Mar 2023 16:37:56 -0400 Subject: [PATCH 1/6] Initial iteration - added modals and some of the logic. --- .../service-location/service-location.vue | 26 +++++++++++++++++++ src/store/index.js | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 69b4f4926..6c8ef58d1 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -25,6 +25,18 @@ cmsWidgetName="AlertMobileOnlyWidget" v-if="displayServiceableMobileOnly" alertClass="alert-warning" /> + + + diff --git a/src/store/index.js b/src/store/index.js index 2dbc7b2cc..abcf231f0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -931,8 +931,8 @@ 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/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop + //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 }); From 8daa078c299967c324a0dac4fc2abfd1185b600a Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 4 Apr 2023 15:11:38 -0400 Subject: [PATCH 2/6] Add text link rendering to alert + hook into opening modal. --- .../service-location/service-location.vue | 6 ++++- src/ux-components/alert/alert.vue | 23 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 6c8ef58d1..846a1731e 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -30,6 +30,7 @@ class="my-4" cmsWidgetName="AlertRecalNoMobileWidget" v-if="displayRecalibrationWarning" + @text-link-clicked="openModalAction" alertClass="alert-warning" />

@@ -40,11 +51,13 @@ From f87a64380bd85d3ca58ecbb849dcaa6e7d3b720c Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 4 Apr 2023 16:38:49 -0400 Subject: [PATCH 3/6] Add recalibration-checking logic. --- src/layouts/service-location/service-location.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 846a1731e..577120c85 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -232,9 +232,13 @@ export default { return this.isGlassServiceableInshop; } }, + isDualOrStaticRecalibration() { + const supportingItems = store.getters.lineItems.supportingItems; + + return supportingItems.some((item) => item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL"); + }, displayRecalibrationWarning() { - //TODO: Check lineItems for static or dual recalibration. - return true; + return this.isDualOrStaticRecalibration; }, displayServiceableInshopOnly() { return ( From 572831254d60ee1e3a0bb7c245971f1fade06409 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 5 Apr 2023 08:57:01 -0400 Subject: [PATCH 4/6] Formatting --- src/layouts/service-location/service-location.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 577120c85..800f7ee52 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -234,8 +234,10 @@ export default { }, isDualOrStaticRecalibration() { const supportingItems = store.getters.lineItems.supportingItems; - - return supportingItems.some((item) => item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL"); + + return supportingItems.some( + (item) => item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL" + ); }, displayRecalibrationWarning() { return this.isDualOrStaticRecalibration; From 031453f4275e5dafe829507a64110c4fc8a6afa7 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 6 Apr 2023 10:55:32 -0400 Subject: [PATCH 5/6] Added new tests. --- .../service-location/service-location.spec.js | 362 ++++++++++++++++++ 1 file changed, 362 insertions(+) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index b0a06b16f..1062a6f34 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -8,6 +8,7 @@ import { getMountOptions } from "@/helpers/unit-test-helper"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; import { getServiceabilityDetails } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; +import { TRUE } from "sass"; // Define Mocks jest.mock("@/helpers/cms-content-helper", () => ({ @@ -733,6 +734,87 @@ describe("service-location.vue", () => { expect(wrapper.vm.isServiceableInshop).toEqual(false); expect(wrapper.vm.displayNoShopsAlert).toEqual(false); }); + + test("displayServiceableInshopOnly should be true if inshop is true and mobile is false", 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.displayServiceableInshopOnly).toEqual(true); + }); + + test("displayServiceableInshopOnly should be false if inshop 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.displayServiceableInshopOnly).toEqual(false); + }); + + test("displayServiceableInshopOnly should be false if 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.displayServiceableInshopOnly).toEqual(false); + }); }); describe("should be based only on glass serviceability if recalibration is not defined.", () => { @@ -870,6 +952,142 @@ describe("service-location.vue", () => { }); }); + describe("should check for dual or static recalibration", () => { + test("isDualOrStaticRecalibration should be true if dual recalibration is present", async () => { + // Arrange + store.getters = { + lineItems: { + supportingItems: [ + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "SUPPLIES-REPAIR", + partType: "REPAIR FEE", + sellingPrice: 7.99, + }, + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "RECAL DUAL", + partType: "RECALIBRATION", + sellingPrice: 0, + }, + ], + }, + order: { + serviceLocation: { + zipCode: "43235", + state: "OH", + }, + }, + damage: { + isRepair: false, + }, + payment: { + isInsurance: false, + }, + vehicle: { + registration: { + address: "5555 Sulgrave Dr", + city: "New Albany", + state: "OH", + zipCode: "43054", + }, + }, + }; + + const { wrapper } = setupMocks({}); + + // Act + await serviceLocation.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "serviceLocation" } }, + undefined, + (c) => c(wrapper.vm) + ); + + // Assert + expect(wrapper.vm.isDualOrStaticRecalibration).toBe(true); + }); + + test("isDualOrStaticRecalibration should be true if static recalibration is present", async () => { + // Arrange + store.getters = { + lineItems: { + supportingItems: [ + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "SUPPLIES-REPAIR", + partType: "REPAIR FEE", + sellingPrice: 7.99, + }, + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "RECAL STATIC", + partType: "RECALIBRATION", + sellingPrice: 0, + }, + ], + }, + order: { + serviceLocation: { + zipCode: "43235", + state: "OH", + }, + }, + damage: { + isRepair: false, + }, + payment: { + isInsurance: false, + }, + vehicle: { + registration: { + address: "5555 Sulgrave Dr", + city: "New Albany", + state: "OH", + zipCode: "43054", + }, + }, + }; + + const { wrapper } = setupMocks({}); + + // Act + await serviceLocation.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "serviceLocation" } }, + undefined, + (c) => c(wrapper.vm) + ); + + // Assert + expect(wrapper.vm.isDualOrStaticRecalibration).toBe(true); + }); + + test("isDualOrStaticRecalibration should be false if neither are present.", async () => { + // Arrange + const { wrapper } = setupMocks({}); + + // Act + await serviceLocation.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "serviceLocation" } }, + undefined, + (c) => c(wrapper.vm) + ); + + // Assert + expect(wrapper.vm.isDualOrStaticRecalibration).toBe(false); + }); + }); + describe("should properly display alerts.", () => { test("Should show mobile-only error if only mobile is available.", async () => { // Arrange @@ -978,6 +1196,150 @@ describe("service-location.vue", () => { // Assert expect(alertComponent.exists()).toBe(false); }); + + test("Should show inshop-only error if only inshop is available", 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) + ); + + const alertComponent = wrapper.findComponent({ ref: "alertInshopOnly" }); + + // Assert + expect(alertComponent.exists()).toBe(true); + }); + + test("Should not show inshop-only error if not inshop-only", 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: "alertInshopOnly" }); + + // Assert + expect(alertComponent.exists()).toBe(false); + }); + + test("Should not show inshop-only error if dual or static recalibration, but should show that error instead.", async () => { + // Arrange + store.getters = { + lineItems: { + supportingItems: [ + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "SUPPLIES-REPAIR", + partType: "REPAIR FEE", + sellingPrice: 7.99, + }, + { + description: null, + kitPrice: 0, + laborAmount: 0, + partNumber: "RECAL STATIC", + partType: "RECALIBRATION", + sellingPrice: 0, + }, + ], + }, + order: { + serviceLocation: { + zipCode: "43235", + state: "OH", + }, + }, + damage: { + isRepair: false, + }, + payment: { + isInsurance: false, + }, + vehicle: { + registration: { + address: "5555 Sulgrave Dr", + city: "New Albany", + state: "OH", + zipCode: "43054", + }, + }, + }; + + 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 alertInshopComponent = wrapper.findComponent({ ref: "alertInshopOnly" }); + const alertRecalComponent = wrapper.findComponent({ ref: "alertRecalNoMobile" }); + + // Assert + expect(alertInshopComponent.exists()).toBe(false); + expect(alertRecalComponent.exists()).toBe(true); + }); + + test("Should not show dual/static recalibration error if not those recalibration types", async () => { + // Arrange + const { wrapper } = setupMocks({}); + + // Act + await serviceLocation.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "serviceLocation" } }, + undefined, + (c) => c(wrapper.vm) + ); + + const alertComponent = wrapper.findComponent({ ref: "alertRecalNoMobile" }); + + // Assert + expect(alertComponent.exists()).toBe(false); + }); }); }); }); From bb14d11a15b0560d7230a8da27ed0c3eff05790e Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 6 Apr 2023 13:38:52 -0400 Subject: [PATCH 6/6] Remove accidentally auto-added import. --- src/layouts/service-location/service-location.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 5f5ae90b4..3589596df 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -8,7 +8,6 @@ import { getMountOptions } from "@/helpers/unit-test-helper"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; import { getServiceabilityDetails } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; -import { TRUE } from "sass"; // Define Mocks jest.mock("@/helpers/cms-content-helper", () => ({