diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index aad61b630..6f2443a49 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -945,6 +945,34 @@ describe("service-location.vue", () => { expect(wrapper.vm.isServiceableInshop).toEqual(true); expect(wrapper.vm.displayServiceableInshopOnly).toEqual(false); }); + + test("displayServiceableInshopOnly should be false in the dual/static recalibration scenario", async () => { + // Arrange + getServiceabilityDetails.mockImplementation(() => + Promise.resolve({ + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + 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(false); + expect(wrapper.vm.displayRecalibrationWarning).toEqual(true); + }); }); describe("should be based only on glass serviceability if recalibration is not defined.", () => { @@ -1080,53 +1108,17 @@ describe("service-location.vue", () => { expect(wrapper.vm.isServiceableInshop).toEqual(true); expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false); }); - }); - describe("should check for dual or static recalibration", () => { - test("isDualOrStaticRecalibration should be true if dual recalibration is present", async () => { + test("requiresInshopRecalibration should not be true if recalibration info is null.", 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", - }, - }, - }; + getServiceabilityDetails.mockImplementation(() => + Promise.resolve({ + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: null, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: null, + }) + ); const { wrapper } = setupMocks({}); @@ -1139,82 +1131,9 @@ describe("service-location.vue", () => { ); // 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); + expect(wrapper.vm.isServiceableMobile).toEqual(true); + expect(wrapper.vm.isServiceableInshop).toEqual(true); + expect(wrapper.vm.requiresInshopRecalibration).toEqual(false); }); }); @@ -1383,54 +1302,11 @@ describe("service-location.vue", () => { 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, + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, isRecalibrationServiceableMobile: false, }) ); @@ -1455,6 +1331,15 @@ describe("service-location.vue", () => { test("Should not show dual/static recalibration error if not those recalibration types", async () => { // Arrange + getServiceabilityDetails.mockImplementation(() => + Promise.resolve({ + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }) + ); + const { wrapper } = setupMocks({}); // Act diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 1e5ffa384..85ee084f3 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -244,15 +244,16 @@ export default { return this.isGlassServiceableInshop; } }, - isDualOrStaticRecalibration() { - const supportingItems = store.getters.lineItems.supportingItems; - - return supportingItems.some( - (item) => item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL" + // Specifically check for isRecalibrationServiceableMobile === false, not null or true. + requiresInshopRecalibration() { + return ( + this.isServiceableInshop && + this.isGlassServiceableMobile && + this.isRecalibrationServiceableMobile === false ); }, displayRecalibrationWarning() { - return this.isDualOrStaticRecalibration; + return this.requiresInshopRecalibration; }, displayServiceableInshopOnly() { return (