Merge pull request #1058 from Safelite/feature/CSR-1063

Feature/csr 1063 Tech Review Feedback
This commit is contained in:
chloeherdsafelite 2023-04-11 13:31:21 -04:00 committed by GitHub
commit a3e2fbecb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 173 deletions

View file

@ -945,6 +945,34 @@ describe("service-location.vue", () => {
expect(wrapper.vm.isServiceableInshop).toEqual(true); expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.displayServiceableInshopOnly).toEqual(false); 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.", () => { 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.isServiceableInshop).toEqual(true);
expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false); expect(wrapper.vm.displayServiceableMobileOnly).toEqual(false);
}); });
});
describe("should check for dual or static recalibration", () => { test("requiresInshopRecalibration should not be true if recalibration info is null.", async () => {
test("isDualOrStaticRecalibration should be true if dual recalibration is present", async () => {
// Arrange // Arrange
store.getters = { getServiceabilityDetails.mockImplementation(() =>
lineItems: { Promise.resolve({
supportingItems: [ isGlassServiceableInshop: true,
{ isRecalibrationServiceableInshop: null,
description: null, isGlassServiceableMobile: true,
kitPrice: 0, isRecalibrationServiceableMobile: null,
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({}); const { wrapper } = setupMocks({});
@ -1139,82 +1131,9 @@ describe("service-location.vue", () => {
); );
// Assert // Assert
expect(wrapper.vm.isDualOrStaticRecalibration).toBe(true); expect(wrapper.vm.isServiceableMobile).toEqual(true);
}); expect(wrapper.vm.isServiceableInshop).toEqual(true);
expect(wrapper.vm.requiresInshopRecalibration).toEqual(false);
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);
}); });
}); });
@ -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 () => { test("Should not show inshop-only error if dual or static recalibration, but should show that error instead.", async () => {
// Arrange // 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(() => getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({ Promise.resolve({
isGlassServiceableInshop: false, isGlassServiceableInshop: true,
isRecalibrationServiceableInshop: false, isRecalibrationServiceableInshop: true,
isGlassServiceableMobile: false, isGlassServiceableMobile: true,
isRecalibrationServiceableMobile: false, isRecalibrationServiceableMobile: false,
}) })
); );
@ -1455,6 +1331,15 @@ describe("service-location.vue", () => {
test("Should not show dual/static recalibration error if not those recalibration types", async () => { test("Should not show dual/static recalibration error if not those recalibration types", async () => {
// Arrange // Arrange
getServiceabilityDetails.mockImplementation(() =>
Promise.resolve({
isGlassServiceableInshop: true,
isRecalibrationServiceableInshop: true,
isGlassServiceableMobile: true,
isRecalibrationServiceableMobile: true,
})
);
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
// Act // Act

View file

@ -244,15 +244,16 @@ export default {
return this.isGlassServiceableInshop; return this.isGlassServiceableInshop;
} }
}, },
isDualOrStaticRecalibration() { // Specifically check for isRecalibrationServiceableMobile === false, not null or true.
const supportingItems = store.getters.lineItems.supportingItems; requiresInshopRecalibration() {
return (
return supportingItems.some( this.isServiceableInshop &&
(item) => item.partNumber === "RECAL STATIC" || item.partNumber === "RECAL DUAL" this.isGlassServiceableMobile &&
this.isRecalibrationServiceableMobile === false
); );
}, },
displayRecalibrationWarning() { displayRecalibrationWarning() {
return this.isDualOrStaticRecalibration; return this.requiresInshopRecalibration;
}, },
displayServiceableInshopOnly() { displayServiceableInshopOnly() {
return ( return (