CSR-1168 | Added default service package unit tests
This commit is contained in:
parent
c70e161f11
commit
91df8c52c2
4 changed files with 221 additions and 7 deletions
|
|
@ -78,6 +78,8 @@ describe("quote.vue", () => {
|
|||
};
|
||||
});
|
||||
|
||||
wrapper.vm.pricedGlassParts = [];
|
||||
|
||||
//Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
|
|
@ -107,6 +109,8 @@ describe("quote.vue", () => {
|
|||
};
|
||||
});
|
||||
|
||||
wrapper.vm.pricedGlassParts = [];
|
||||
|
||||
//Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,9 @@ export default {
|
|||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const clonedGlassParts = store.getters.order.lineItems.glassParts ? JSON.parse(JSON.stringify(store.getters.order.lineItems.glassParts)) : [];
|
||||
const clonedGlassParts = store.getters.order.lineItems.glassParts
|
||||
? JSON.parse(JSON.stringify(store.getters.order.lineItems.glassParts))
|
||||
: [];
|
||||
const availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
|
|
@ -131,7 +133,7 @@ export default {
|
|||
selectedVaps: null,
|
||||
availableLineItems: null,
|
||||
supportingItems: null,
|
||||
pricedGlassParts: null
|
||||
pricedGlassParts: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -185,7 +187,7 @@ export default {
|
|||
if (this.$store.getters.order.accountNumber != applicationConfig.CASH_ACCOUNT_NUMBER) {
|
||||
this.supportingItems = this.filterOutFees(this.supportingItems);
|
||||
}
|
||||
if(this.pricedGlassParts.length > 0) {
|
||||
if (this.pricedGlassParts.length > 0) {
|
||||
this.dispatchStoreAction(
|
||||
this.storeActions.SAVE_GLASS_PARTS,
|
||||
this.pricedGlassParts,
|
||||
|
|
|
|||
|
|
@ -135,6 +135,213 @@ describe("service-package-question.vue", () => {
|
|||
expectedModifiedAnswers[packageNameKey].tierThree
|
||||
);
|
||||
});
|
||||
it("should not select a default package if ANY glass part or supporting item has no prices", async () => {
|
||||
// Note, only the first WSREPAIR item has a 0 for laborAmount, this is enough to not try and select a default package
|
||||
const wrapper = setupMocks({
|
||||
mountOptionsMockData: {
|
||||
store: {
|
||||
getters: {
|
||||
lineItems: {
|
||||
glassParts: [
|
||||
{
|
||||
partNumber: "FW02627GBYNOEE",
|
||||
description: "solar, 3rd visor band",
|
||||
color: "Green Tint, Blue Shade",
|
||||
partType: "WINDSHIELD",
|
||||
canSafeliteRecalibrate: false,
|
||||
requiresRecalibration: false,
|
||||
requiresCapabilityQuestions: false,
|
||||
recalibrationType: null,
|
||||
childParts: null,
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
supportingItems: [
|
||||
{
|
||||
partNumber: "SUPPLIES-REPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
order: {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [{ glassLocation: "Windshield" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Act
|
||||
wrapper.setProps({ availableLineItems: null });
|
||||
|
||||
await nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.selectedPackageName).toBe(null);
|
||||
});
|
||||
it("should select a default package if ALL glass parts and supporting items have prices", async () => {
|
||||
const wrapper = setupMocks({
|
||||
mountOptionsMockData: {
|
||||
store: {
|
||||
getters: {
|
||||
lineItems: {
|
||||
glassParts: [
|
||||
{
|
||||
partNumber: "FW02627GBYNOEE",
|
||||
description: "solar, 3rd visor band",
|
||||
color: "Green Tint, Blue Shade",
|
||||
partType: "WINDSHIELD",
|
||||
canSafeliteRecalibrate: false,
|
||||
requiresRecalibration: false,
|
||||
requiresCapabilityQuestions: false,
|
||||
recalibrationType: null,
|
||||
childParts: null,
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
supportingItems: [
|
||||
{
|
||||
partNumber: "SUPPLIES-REPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
order: {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [{ glassLocation: "Windshield" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Act
|
||||
wrapper.setProps({ availableLineItems: null });
|
||||
|
||||
await nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.selectedPackageName).toBe("TierOne");
|
||||
});
|
||||
it("should select TierThree default package if Rain Defense is on order", async () => {
|
||||
// This tests the business intent that when returning to the page, the selected package is the lowest package that contains all VAPs on the order.
|
||||
// In this case Rain Defense is only in Premium so Tier Three should be defaulted to
|
||||
const wrapper = setupMocks({
|
||||
mountOptionsMockData: {
|
||||
store: {
|
||||
getters: {
|
||||
lineItems: {
|
||||
glassParts: [
|
||||
{
|
||||
partNumber: "FW02627GBYNOEE",
|
||||
description: "solar, 3rd visor band",
|
||||
color: "Green Tint, Blue Shade",
|
||||
partType: "WINDSHIELD",
|
||||
canSafeliteRecalibrate: false,
|
||||
requiresRecalibration: false,
|
||||
requiresCapabilityQuestions: false,
|
||||
recalibrationType: null,
|
||||
childParts: null,
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
vaps: [
|
||||
{
|
||||
partNumber: "RAIN DEFENSE",
|
||||
partType: "RAIN DEFENSE",
|
||||
},
|
||||
],
|
||||
supportingItems: [
|
||||
{
|
||||
partNumber: "SUPPLIES-REPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
{
|
||||
partNumber: "WSREPAIR",
|
||||
description: null,
|
||||
partType: "REPAIR FEE",
|
||||
laborAmount: 5.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
order: {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [{ glassLocation: "Windshield" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Act
|
||||
wrapper.setProps({ availableLineItems: null });
|
||||
|
||||
await nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.selectedPackageName).toBe("TierThree");
|
||||
});
|
||||
});
|
||||
describe("service-package-question.vue, matching business rules for package display", () => {
|
||||
// mock scenarios in figma:
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ export default {
|
|||
if (this.allGlassPartsAndSupportingItemsHavePrices(this.$store.getters.lineItems)) {
|
||||
this.selectDefaultPackage();
|
||||
}
|
||||
|
||||
},
|
||||
selectedPackageName(newValue) {
|
||||
const VapsProductsInSelectedPackage = this.getVapsLineItemsForSelectedPackage(newValue);
|
||||
|
|
@ -247,9 +246,11 @@ export default {
|
|||
return true;
|
||||
},
|
||||
priceIsNullOrZero(lineItem) {
|
||||
return (lineItem.kitPrice == null || lineItem.kitPrice == 0) &&
|
||||
(lineItem.laborAmount == null || lineItem.laborAmount == 0) &&
|
||||
(lineItem.sellingPrice == null || lineItem.sellingPrice == 0);
|
||||
return (
|
||||
(lineItem.kitPrice == null || lineItem.kitPrice == 0) &&
|
||||
(lineItem.laborAmount == null || lineItem.laborAmount == 0) &&
|
||||
(lineItem.sellingPrice == null || lineItem.sellingPrice == 0)
|
||||
);
|
||||
},
|
||||
getLowestTierForThisItem(vapsItem) {
|
||||
let lowestTierForThisItem = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue