CASH-2967: Show ServicePackageNameTest names in cart
This commit is contained in:
parent
30b2e3b3d2
commit
14934ff62b
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 { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
|
||||
import { packageNames } from "@/constants/package-names";
|
||||
|
||||
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 = {
|
||||
logInformation: jest.fn(),
|
||||
logWarning: jest.fn(),
|
||||
|
|
@ -354,9 +370,73 @@ describe("cart.vue", () => {
|
|||
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({
|
||||
...options,
|
||||
});
|
||||
|
|
@ -365,7 +445,9 @@ function setupMocks({ options, props }) {
|
|||
methods: {
|
||||
getTierOnePackagePrice: jest.fn(),
|
||||
filterOutFees: jest.fn(),
|
||||
getCmsContent: jest.fn(),
|
||||
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||
return cmsContent?.[widgetName]?.[cmsFieldName];
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@
|
|||
|
||||
<!-- Service Type -->
|
||||
<div class="service-type">
|
||||
<textBlock :cmsWidgetName="servicePackageTitleWidget" />
|
||||
<textBlock
|
||||
:cmsWidgetName="servicePackageTitleWidget"
|
||||
:customText="servicePackageTitleText" />
|
||||
<span>
|
||||
{{ getLineItemAmount(packagePrice) }}
|
||||
</span>
|
||||
|
|
@ -193,6 +195,7 @@ import { formatToUSDollar } from "@/helpers/cms-content-helper";
|
|||
|
||||
// Constants
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { packageNames } from "@/constants/package-names";
|
||||
import { cartItemCategories } from "@/constants/cart-item-categories";
|
||||
import { cartItemTypes } from "@/constants/cart-item-types";
|
||||
import { coverageStatus, cartItemTypesCoveredByInsurance } from "@/constants/insurance";
|
||||
|
|
@ -267,6 +270,24 @@ export default {
|
|||
|
||||
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() {
|
||||
const quotePageDiscountLineItems = this.quotePageDiscountCartItem;
|
||||
let subTotal = 0;
|
||||
|
|
@ -547,6 +568,9 @@ export default {
|
|||
|
||||
return currentPackage.SubWidgetName;
|
||||
},
|
||||
servicePackageTitleText() {
|
||||
return this.getExperimentPackageLabel(this.packageLevel);
|
||||
},
|
||||
packageLevel() {
|
||||
const tier = getHighestFullySatisfiedTier(
|
||||
this.glassToReplace,
|
||||
|
|
|
|||
Loading…
Reference in a new issue