Merge pull request #2069 from Safelite/feature/CSR-2303
CSR-2303 itac and nocomp should allow recal
This commit is contained in:
commit
6eddb0d652
5 changed files with 155 additions and 6 deletions
|
|
@ -32,7 +32,7 @@ module.exports = {
|
||||||
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
statements: 76,
|
statements: 75,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Uncomment this to avoid the massive amount of warnings we are getting for onSubmit and onInvalidSubmit
|
// Uncomment this to avoid the massive amount of warnings we are getting for onSubmit and onInvalidSubmit
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ import { nextTick } from "vue";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
import experimentMixin from "@/mixins/experiment-mixin.js";
|
||||||
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
|
|
||||||
|
const mockExperimentSettings = experimentSettings;
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
|
@ -66,6 +70,9 @@ beforeEach(() => {
|
||||||
customer: {
|
customer: {
|
||||||
emailAddress: "test@test.com",
|
emailAddress: "test@test.com",
|
||||||
},
|
},
|
||||||
|
policy: {
|
||||||
|
isNoComp: false,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
damage: {},
|
damage: {},
|
||||||
payment: {
|
payment: {
|
||||||
|
|
@ -552,6 +559,136 @@ describe("computed properties...", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual("Duration: Overnight");
|
expect(testValue).toEqual("Duration: Overnight");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("NoComp should return false for shouldHideRecalibration", () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
wrapper.vm.submittedOrder = {
|
||||||
|
vehicle: {
|
||||||
|
imageUrl: "",
|
||||||
|
},
|
||||||
|
schedule: {
|
||||||
|
endTime: "10:00",
|
||||||
|
date: "2024-09-28",
|
||||||
|
jobMaxMinutes: 120,
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
routeCode: "",
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
isNoComp: true,
|
||||||
|
},
|
||||||
|
serviceLocation: store.getters.order.serviceLocation,
|
||||||
|
};
|
||||||
|
wrapper.vm.submittedOrder.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.shouldHideRecalibration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(false);
|
||||||
|
});
|
||||||
|
test("Itac should return false for shouldHideRecalibration", () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
wrapper.vm.submittedOrder = {
|
||||||
|
vehicle: {
|
||||||
|
imageUrl: "",
|
||||||
|
},
|
||||||
|
schedule: {
|
||||||
|
endTime: "10:00",
|
||||||
|
date: "2024-09-28",
|
||||||
|
jobMaxMinutes: 120,
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
routeCode: "",
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
isItac: true,
|
||||||
|
},
|
||||||
|
serviceLocation: store.getters.order.serviceLocation,
|
||||||
|
};
|
||||||
|
wrapper.vm.submittedOrder.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.shouldHideRecalibration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(false);
|
||||||
|
});
|
||||||
|
test("Not Itac/NoComp with Recal should return true for shouldHideRecalibration", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [{
|
||||||
|
partType: "RECALIBRATION",
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.vm.submittedOrder = {
|
||||||
|
vehicle: {
|
||||||
|
imageUrl: "",
|
||||||
|
},
|
||||||
|
schedule: {
|
||||||
|
endTime: "10:00",
|
||||||
|
date: "2024-09-28",
|
||||||
|
jobMaxMinutes: 120,
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
routeCode: "",
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
isItac: false,
|
||||||
|
isNoComp: false,
|
||||||
|
},
|
||||||
|
lineItems: {
|
||||||
|
glassParts: {
|
||||||
|
partType: "Recalibration",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
serviceLocation: store.getters.order.serviceLocation,
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.setData({ lineItems: lineItems });
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.shouldHideRecalibration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(true);
|
||||||
|
});
|
||||||
|
test ("Itac/NoComp with Recal should return false for shouldHideRecalibration", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [{
|
||||||
|
partType: "RECALIBRATION",
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.vm.submittedOrder = {
|
||||||
|
vehicle: {
|
||||||
|
imageUrl: "",
|
||||||
|
},
|
||||||
|
schedule: {
|
||||||
|
endTime: "10:00",
|
||||||
|
date: "2024-09-28",
|
||||||
|
jobMaxMinutes: 120,
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
routeCode: "",
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
isItac: true,
|
||||||
|
isNoComp: false,
|
||||||
|
},
|
||||||
|
serviceLocation: store.getters.order.serviceLocation,
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper.setData({ lineItems: lineItems });
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.shouldHideRecalibration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ customMountOptions }) {
|
function setupMocks({ customMountOptions }) {
|
||||||
|
|
@ -565,10 +702,17 @@ function setupMocks({ customMountOptions }) {
|
||||||
getCmsContent: jest.fn().mockImplementation(() => {
|
getCmsContent: jest.fn().mockImplementation(() => {
|
||||||
return wordingText;
|
return wordingText;
|
||||||
}),
|
}),
|
||||||
getSettingValue: jest.fn(),
|
getSettingValue: jest.fn((settingName) => {
|
||||||
|
if (settingName === experimentSettings.RECAL_PRICE_REMOVE) {
|
||||||
|
return "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "false";
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const wrapper = shallowMount(confirmation, mountOptions);
|
const wrapper = shallowMount(confirmation, mountOptions);
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,10 @@ export default {
|
||||||
return containsRecalParts(this?.lineItems);
|
return containsRecalParts(this?.lineItems);
|
||||||
},
|
},
|
||||||
shouldHideRecalibration() {
|
shouldHideRecalibration() {
|
||||||
|
if (this.isNoComp || this.isItac) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.getSettingValue(experimentSettings.RECAL_PRICE_REMOVE)?.toLowerCase() ===
|
this.getSettingValue(experimentSettings.RECAL_PRICE_REMOVE)?.toLowerCase() ===
|
||||||
"true" && this.isRecalibrationOnOrder
|
"true" && this.isRecalibrationOnOrder
|
||||||
|
|
|
||||||
|
|
@ -596,10 +596,7 @@ export default {
|
||||||
return containsRecalParts(order.lineItems);
|
return containsRecalParts(order.lineItems);
|
||||||
},
|
},
|
||||||
shouldHideRecalibration() {
|
shouldHideRecalibration() {
|
||||||
return (
|
return this.$store.getters.shouldHideRecalibration;
|
||||||
this.getSettingValue(experimentSettings.RECAL_PRICE_REMOVE)?.toLowerCase() ===
|
|
||||||
"true" && this.isRecalibrationOnOrder
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
showApplePay() {
|
showApplePay() {
|
||||||
return baseMixin.methods.showApplePay();
|
return baseMixin.methods.showApplePay();
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,10 @@ export const getters = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
shouldHideRecalibration: (state) => {
|
shouldHideRecalibration: (state) => {
|
||||||
|
if (state.order.policy.isNoComp || state.order.policy.isItac) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
experimentMixin.methods
|
experimentMixin.methods
|
||||||
.getSettingValue(experimentSettings.RECAL_PRICE_REMOVE)
|
.getSettingValue(experimentSettings.RECAL_PRICE_REMOVE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue