diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 28a8ca473..3589596df 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -812,6 +812,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.", () => { @@ -949,6 +1030,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 @@ -1057,6 +1274,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); + }); }); }); }); diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 37e9b3aee..bbc6b96c9 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -25,6 +25,19 @@ cmsWidgetName="AlertMobileOnlyWidget" v-if="displayServiceableMobileOnly" alertClass="alert-warning" /> + + + item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL" + ); + }, + displayRecalibrationWarning() { + return this.isDualOrStaticRecalibration; + }, + displayServiceableInshopOnly() { + return ( + !this.displayRecalibrationWarning && + this.isServiceableInshop && + !this.isServiceableMobile + ); + }, displayMilitaryZipAlert() { return this.zipContainsMilitaryBase && this.isServiceableMobile; }, @@ -297,6 +329,9 @@ export default { this.$route ); }, + openModalAction(modalName) { + this.$refs[modalName].openModal(); + }, }, components: { alert, @@ -309,6 +344,7 @@ export default { Form, loadingModal, textboxQuestion, + contentGroupModal, }, }; diff --git a/src/ux-components/alert/alert.vue b/src/ux-components/alert/alert.vue index cecbad90c..62c4b4d99 100644 --- a/src/ux-components/alert/alert.vue +++ b/src/ux-components/alert/alert.vue @@ -11,12 +11,11 @@ @@ -40,11 +51,13 @@