Merge pull request #3256 from Safelite/feature/CASH-2967
Feature/CASH 2967
This commit is contained in:
commit
9997ad5d5f
2 changed files with 109 additions and 3 deletions
|
|
@ -5,8 +5,24 @@ import cart from "@/fmg-components/cart/cart.vue";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
|
||||||
|
import { packageNames } from "@/constants/package-names";
|
||||||
|
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
|
jest.mock("@/mixins/experiment-mixin.js", () => ({
|
||||||
|
methods: {
|
||||||
|
getSettingValue(settingName) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
hasSetting(settingName) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
hasSettingEqualTo(settingName, settingValue) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
global.$logger = {
|
global.$logger = {
|
||||||
logInformation: jest.fn(),
|
logInformation: jest.fn(),
|
||||||
logWarning: jest.fn(),
|
logWarning: jest.fn(),
|
||||||
|
|
@ -354,9 +370,73 @@ describe("cart.vue", () => {
|
||||||
expect(found).toBe(true);
|
expect(found).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("servicePackageTitle", () => {
|
||||||
|
const servicePackageCmsContent = {
|
||||||
|
ServicePackageTitle: {
|
||||||
|
Answers: [
|
||||||
|
{
|
||||||
|
Name: packageNames.TIER_ONE,
|
||||||
|
SubWidgetName: "EconomyServiceTitle",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: packageNames.TIER_TWO,
|
||||||
|
SubWidgetName: "StandardServiceTitle",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: packageNames.TIER_THREE,
|
||||||
|
SubWidgetName: "PremiumServiceTitle",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
EconomyServiceTitle: {
|
||||||
|
Text: "Glass service only",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultServicePackageProps = {
|
||||||
|
servicePackageOptionsCmsName: "ServicePackageTitle",
|
||||||
|
damage: {
|
||||||
|
glassToReplace: [{ glassLocation: "Windshield" }],
|
||||||
|
isRepair: false,
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
},
|
||||||
|
availableVaps: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
test("uses CMS widget name when experiment is not active", () => {
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
props: defaultServicePackageProps,
|
||||||
|
cmsContent: servicePackageCmsContent,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.vm.servicePackageTitleWidget).toBe("EconomyServiceTitle");
|
||||||
|
expect(wrapper.vm.servicePackageTitleText).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("uses experiment display name when ServicePackageNameTest is active", () => {
|
||||||
|
const getExperimentPackageLabelSpy = jest
|
||||||
|
.spyOn(cart.methods, "getExperimentPackageLabel")
|
||||||
|
.mockReturnValue("Essential");
|
||||||
|
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
props: defaultServicePackageProps,
|
||||||
|
cmsContent: servicePackageCmsContent,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.vm.servicePackageTitleText).toBe("Essential");
|
||||||
|
|
||||||
|
getExperimentPackageLabelSpy.mockRestore();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ options, props }) {
|
function setupMocks({ options, props, cmsContent }) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
@ -365,7 +445,9 @@ function setupMocks({ options, props }) {
|
||||||
methods: {
|
methods: {
|
||||||
getTierOnePackagePrice: jest.fn(),
|
getTierOnePackagePrice: jest.fn(),
|
||||||
filterOutFees: jest.fn(),
|
filterOutFees: jest.fn(),
|
||||||
getCmsContent: jest.fn(),
|
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||||
|
return cmsContent?.[widgetName]?.[cmsFieldName];
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@
|
||||||
|
|
||||||
<!-- Service Type -->
|
<!-- Service Type -->
|
||||||
<div class="service-type">
|
<div class="service-type">
|
||||||
<textBlock :cmsWidgetName="servicePackageTitleWidget" />
|
<textBlock
|
||||||
|
:cmsWidgetName="servicePackageTitleWidget"
|
||||||
|
:customText="servicePackageTitleText" />
|
||||||
<span>
|
<span>
|
||||||
{{ getLineItemAmount(packagePrice) }}
|
{{ getLineItemAmount(packagePrice) }}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -193,6 +195,7 @@ import { formatToUSDollar } from "@/helpers/cms-content-helper";
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
|
import { packageNames } from "@/constants/package-names";
|
||||||
import { cartItemCategories } from "@/constants/cart-item-categories";
|
import { cartItemCategories } from "@/constants/cart-item-categories";
|
||||||
import { cartItemTypes } from "@/constants/cart-item-types";
|
import { cartItemTypes } from "@/constants/cart-item-types";
|
||||||
import { coverageStatus, cartItemTypesCoveredByInsurance } from "@/constants/insurance";
|
import { coverageStatus, cartItemTypesCoveredByInsurance } from "@/constants/insurance";
|
||||||
|
|
@ -267,6 +270,24 @@ export default {
|
||||||
|
|
||||||
return subTotal;
|
return subTotal;
|
||||||
},
|
},
|
||||||
|
getExperimentPackageLabel(tierName) {
|
||||||
|
if (
|
||||||
|
!experimentMixin.methods.hasSettingEqualTo(
|
||||||
|
experimentSettings.SHOW_SERVICE_PACKAGE_NAME_TEST,
|
||||||
|
"true"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tierSettingKey = {
|
||||||
|
[packageNames.TIER_ONE]: experimentSettings.TIER_ONE,
|
||||||
|
[packageNames.TIER_TWO]: experimentSettings.TIER_TWO,
|
||||||
|
[packageNames.TIER_THREE]: experimentSettings.TIER_THREE,
|
||||||
|
}[tierName];
|
||||||
|
|
||||||
|
return tierSettingKey ? experimentMixin.methods.getSettingValue(tierSettingKey) : null;
|
||||||
|
},
|
||||||
getQuotePageDiscount() {
|
getQuotePageDiscount() {
|
||||||
const quotePageDiscountLineItems = this.quotePageDiscountCartItem;
|
const quotePageDiscountLineItems = this.quotePageDiscountCartItem;
|
||||||
let subTotal = 0;
|
let subTotal = 0;
|
||||||
|
|
@ -547,6 +568,9 @@ export default {
|
||||||
|
|
||||||
return currentPackage.SubWidgetName;
|
return currentPackage.SubWidgetName;
|
||||||
},
|
},
|
||||||
|
servicePackageTitleText() {
|
||||||
|
return this.getExperimentPackageLabel(this.packageLevel);
|
||||||
|
},
|
||||||
packageLevel() {
|
packageLevel() {
|
||||||
const tier = getHighestFullySatisfiedTier(
|
const tier = getHighestFullySatisfiedTier(
|
||||||
this.glassToReplace,
|
this.glassToReplace,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue