Add tests (including figma matching)
This commit is contained in:
parent
f0a8c0f952
commit
1c23919854
1 changed files with 967 additions and 1 deletions
|
|
@ -1,3 +1,969 @@
|
|||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import servicePackageReview from "@/layouts/review/review-sections/service-package-review/service-package-review";
|
||||
|
||||
import { packageNames } from "@/constants/package-names";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { damageLocationsSelected as glassConstants } from "@/constants/damage-locations-selected";
|
||||
|
||||
const testConstants = {
|
||||
cmsPropValues: {
|
||||
servicePackageOptionsCmsName: "ServicePackageTitle",
|
||||
defaultPackageItemsCmsName: "DefaultPackageItemDescriptions",
|
||||
vapsItemsCmsName: "VapsItemDescriptions",
|
||||
},
|
||||
widgetNames: {
|
||||
tierOneTitle: "EconomyServiceTitle",
|
||||
tierTwoTitle: "StandardServiceTitle",
|
||||
tierThreeTitle: "PremiumServiceTitle",
|
||||
},
|
||||
defaultItemCopy: {
|
||||
itemOne: "Item Description 1",
|
||||
itemTwo: "Item Description 2",
|
||||
itemThree: "Item Description 3",
|
||||
itemFour: "Item Description 4",
|
||||
defaultItemCopyArray: ["Item Description 1", "Item Description 2", "Item Description 3"],
|
||||
},
|
||||
vapsCopy: {
|
||||
frontWiperCopy: "Front Wiper copy",
|
||||
rearWiperCopy: "Rear Wiper copy",
|
||||
rainDefenseCopy: "Rain defense copy",
|
||||
},
|
||||
parts: {
|
||||
frontWiperPart: {
|
||||
partNumber: "SBB16",
|
||||
description: "SAFELITE BEAM BLADE 16",
|
||||
partType: "FRONT WIPER",
|
||||
price: 32.64,
|
||||
},
|
||||
rearWiperPart: {
|
||||
partNumber: "SBBR12A",
|
||||
description: "SAFELITE REAR BLADE 12A",
|
||||
partType: "REAR WIPER",
|
||||
price: 24.48,
|
||||
},
|
||||
rainDefensePart: {
|
||||
partNumber: "RAIN DEFENSE",
|
||||
description: null,
|
||||
partType: "RAIN DEFENSE",
|
||||
price: 35.5,
|
||||
},
|
||||
recalPart: {
|
||||
partNumber: "RECAL STATIC",
|
||||
Description: "Recalibration",
|
||||
partType: "recalibration",
|
||||
Quantity: "1",
|
||||
price: 150.0,
|
||||
},
|
||||
},
|
||||
damages: {
|
||||
frontWindshield: {
|
||||
glassLocation: glassConstants.WINDSHIELD,
|
||||
glassName: glassConstants.SINGLE,
|
||||
},
|
||||
rearWindshield: {
|
||||
glassLocation: glassConstants.REAR,
|
||||
glassName: glassConstants.STATIONARY,
|
||||
},
|
||||
sideGlass: {
|
||||
glassLocation: glassConstants.PASSENGER,
|
||||
glassName: glassConstants.QUARTER,
|
||||
},
|
||||
},
|
||||
imageId: "00000000-0000-0000-0000-000000000000",
|
||||
};
|
||||
|
||||
const figmaScenarios = [
|
||||
{
|
||||
name: "05_01_CSR_Quote_Cash",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.frontWindshield],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard+RearWiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart, testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// 05_01_CSR_Quote_Standard_Repair & 05_01_CSR_Quote_Recal have identical outcomes to above, but included in case that changes in the future.
|
||||
{
|
||||
name: "05_01_CSR_Quote_Standard_Repair",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: true,
|
||||
glassToReplace: [],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard+RearWiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart, testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "05_01_CSR_Quote_Recal",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.frontWindshield],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [testConstants.parts.recalPart],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard+RearWiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart, testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// 05_01_CSR_Quote_RearGlass omitted as a duplicate of below.
|
||||
{
|
||||
name: "05_01_CSR_Quote_RearGlass+NonWindshield",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.rearWindshield],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Frontwiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard+RainDefense",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart, testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart, testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "05_01_CSR_Quote_RearGlass+Windshield",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [
|
||||
testConstants.damages.frontWindshield,
|
||||
testConstants.damages.rearWindshield,
|
||||
],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Frontwiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Rearwiper",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+RainDefense",
|
||||
vapsCombo: [testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Frontwiper+RainDefense",
|
||||
vapsCombo: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Rearwiper+RainDefense",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart, testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart, testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "05_01_CSR_Quote_RearGlassNoFrontFit",
|
||||
params: {
|
||||
availableVaps: [testConstants.parts.rearWiperPart, testConstants.parts.rainDefensePart],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.rearWindshield],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Raindefense",
|
||||
vapsCombo: [testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart, testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// 05_01_CSR_Quote_Windshield+SideGlass has identical outcomes to 05_01_CSR_Quote_Cash, but included in case that changes in the future.
|
||||
{
|
||||
name: "05_01_CSR_Quote_Windshield+SideGlass",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [
|
||||
testConstants.damages.frontWindshield,
|
||||
testConstants.damages.sideGlass,
|
||||
],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Standard+RearWiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart, testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierTwoTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// Has no standard package
|
||||
{
|
||||
name: "05_01_CSR_Quote_SideGlass",
|
||||
params: {
|
||||
availableVaps: [
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
testConstants.parts.rainDefensePart,
|
||||
],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.sideGlass],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Frontwiper",
|
||||
vapsCombo: [testConstants.parts.frontWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+RainDefense",
|
||||
vapsCombo: [testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Economy+Rearwiper",
|
||||
vapsCombo: [testConstants.parts.rearWiperPart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium+Rearwiper",
|
||||
vapsCombo: [
|
||||
testConstants.parts.rainDefensePart,
|
||||
testConstants.parts.frontWiperPart,
|
||||
testConstants.parts.rearWiperPart,
|
||||
],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.frontWiperCopy,
|
||||
testConstants.vapsCopy.rearWiperCopy,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// Has no standard package
|
||||
{
|
||||
name: "05_01_CSR_Quote_NoWiperFit",
|
||||
params: {
|
||||
availableVaps: [testConstants.parts.rainDefensePart],
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.frontWindshield],
|
||||
},
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
},
|
||||
iterations: [
|
||||
{
|
||||
name: "Economy",
|
||||
vapsCombo: [],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierOneTitle,
|
||||
displayContent: testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Premium",
|
||||
vapsCombo: [testConstants.parts.rainDefensePart],
|
||||
expected: {
|
||||
packageNameWidget: testConstants.widgetNames.tierThreeTitle,
|
||||
displayContent: [
|
||||
...testConstants.defaultItemCopy.defaultItemCopyArray,
|
||||
testConstants.vapsCopy.rainDefenseCopy,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
let cmsContent;
|
||||
|
||||
describe("Service Package Review Block", () => {
|
||||
test.todo("Add more tests as specific functionality is added.");
|
||||
beforeEach(() => {
|
||||
cmsContent = {
|
||||
ServicePackageTitle: {
|
||||
Answers: [
|
||||
{
|
||||
Name: packageNames.TIER_ONE,
|
||||
Text: "",
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: testConstants.widgetNames.tierOneTitle,
|
||||
},
|
||||
{
|
||||
Name: packageNames.TIER_TWO,
|
||||
Text: "",
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: testConstants.widgetNames.tierTwoTitle,
|
||||
},
|
||||
{
|
||||
Name: packageNames.TIER_THREE,
|
||||
Text: "",
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: testConstants.widgetNames.tierThreeTitle,
|
||||
},
|
||||
],
|
||||
},
|
||||
DefaultPackageItemDescriptions: {
|
||||
Answers: [
|
||||
{
|
||||
Name: "Item1",
|
||||
Text: testConstants.defaultItemCopy.itemOne,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
{
|
||||
Name: "Item2",
|
||||
Text: testConstants.defaultItemCopy.itemTwo,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
{
|
||||
Name: "Item3",
|
||||
Text: testConstants.defaultItemCopy.itemThree,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
VapsItemDescriptions: {
|
||||
Answers: [
|
||||
{
|
||||
Name: partTypeStrings.FRONT_WIPER,
|
||||
Text: testConstants.vapsCopy.frontWiperCopy,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
{
|
||||
Name: partTypeStrings.REAR_WIPER,
|
||||
Text: testConstants.vapsCopy.rearWiperCopy,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
{
|
||||
Name: partTypeStrings.RAIN_DEFENSE,
|
||||
Text: testConstants.vapsCopy.rainDefenseCopy,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
describe("General functionality", () => {
|
||||
it('Should properly "Round Down" package tier', async () => {
|
||||
// Slightly longer explanation:
|
||||
// Should only return the highest tier where *every* offered VAP is part of the order.
|
||||
// However, there may be vaps not offered in the qualifying tier. Hence rounding *down*.
|
||||
//
|
||||
// I.e. Economy=[], Standard=[front wipers], Premium=[front wipers, rain defense].
|
||||
// Current vaps=[rain defense]. Though rain defense is in Premium, we don't satisfy it or standard.
|
||||
// So our tier should still be Economy.
|
||||
// Should still display extra vaps.
|
||||
|
||||
// Arrange
|
||||
let props = generateDefaultProps();
|
||||
|
||||
props.lineItems.vaps = [testConstants.parts.rainDefensePart];
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
propsData: props,
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.packageNameWidget).toEqual(testConstants.widgetNames.tierOneTitle);
|
||||
|
||||
let containsRainDefenseCopy = wrapper.vm.displayContent.includes(
|
||||
testConstants.vapsCopy.rainDefenseCopy
|
||||
);
|
||||
expect(containsRainDefenseCopy).toBe(true);
|
||||
});
|
||||
|
||||
it("Should display all default items from cms", async () => {
|
||||
// Arrange
|
||||
cmsContent.DefaultPackageItemDescriptions.Answers.push({
|
||||
Name: "Item4",
|
||||
Text: testConstants.defaultItemCopy.itemFour,
|
||||
SubText: "",
|
||||
ImageId: testConstants.imageId,
|
||||
Image: "",
|
||||
SubWidgetName: "",
|
||||
});
|
||||
|
||||
let props = generateDefaultProps();
|
||||
props.lineItems.vaps = [];
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
propsData: props,
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
let expectedResult = [
|
||||
testConstants.defaultItemCopy.itemOne,
|
||||
testConstants.defaultItemCopy.itemTwo,
|
||||
testConstants.defaultItemCopy.itemThree,
|
||||
testConstants.defaultItemCopy.itemFour,
|
||||
];
|
||||
|
||||
expect(wrapper.vm.displayContent).toEqual(expectedResult);
|
||||
});
|
||||
|
||||
it("Should display vaps if and only if they are added", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({
|
||||
propsData: generateDefaultProps(),
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
const includesFrontWiperCopy = wrapper.vm.displayContent.includes(
|
||||
testConstants.vapsCopy.frontWiperCopy
|
||||
);
|
||||
const includesRainDefenseCopy = wrapper.vm.displayContent.includes(
|
||||
testConstants.vapsCopy.rainDefenseCopy
|
||||
);
|
||||
expect(includesFrontWiperCopy).toBe(true);
|
||||
expect(includesRainDefenseCopy).toBe(false);
|
||||
});
|
||||
|
||||
it("Should not error if cms content is missing (though may display poorly).", async () => {
|
||||
// Arrange
|
||||
cmsContent = {};
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
propsData: generateDefaultProps(),
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.packageNameWidget).toEqual("");
|
||||
expect(wrapper.vm.displayContent).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Match Figma Scenarios", () => {
|
||||
figmaScenarios.forEach((scenario) => {
|
||||
scenario.iterations.forEach((iteration) => {
|
||||
it(`Should match figma scenario "${scenario.name}", iteration "${iteration.name}"`, async () => {
|
||||
// Arrange
|
||||
let props = generateDefaultProps();
|
||||
props.availableVaps = scenario.params.availableVaps;
|
||||
props.damage = scenario.params.damage;
|
||||
props.glassParts = scenario.params.glassParts;
|
||||
props.lineItems.supportingItems = scenario.params.supportingItems;
|
||||
props.lineItems.vaps = iteration.vapsCombo;
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
propsData: props,
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.packageNameWidget).toEqual(
|
||||
iteration.expected.packageNameWidget
|
||||
);
|
||||
expect(wrapper.vm.displayContent).toEqual(iteration.expected.displayContent);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function generateDefaultProps() {
|
||||
return {
|
||||
servicePackageOptionsCmsName: testConstants.cmsPropValues.servicePackageOptionsCmsName,
|
||||
defaultPackageItemsCmsName: testConstants.cmsPropValues.defaultPackageItemsCmsName,
|
||||
vapsItemsCmsName: testConstants.cmsPropValues.vapsItemsCmsName,
|
||||
availableVaps: [testConstants.parts.frontWiperPart, testConstants.parts.rainDefensePart],
|
||||
lineItems: {
|
||||
glassParts: [],
|
||||
supportingItems: [],
|
||||
vaps: [testConstants.parts.frontWiperPart],
|
||||
},
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.damages.frontWindshield],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function setupMocks(customMountOptions) {
|
||||
const mountOptions = getMountOptions(customMountOptions);
|
||||
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||
return (cmsContent?.[widgetName]?.[cmsFieldName]) ?? "";
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
mountOptions.global.mixins = [mockMixin];
|
||||
|
||||
const wrapper = shallowMount(servicePackageReview, mountOptions);
|
||||
wrapper.vm.setCmsContent = jest.fn();
|
||||
return { wrapper };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue