diff --git a/src/fmg-components/cart/cart.spec.js b/src/fmg-components/cart/cart.spec.js index f06a49a90..a920e39f6 100644 --- a/src/fmg-components/cart/cart.spec.js +++ b/src/fmg-components/cart/cart.spec.js @@ -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]; + }), }, }; diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index 5d48dc5ae..1bbfb0b76 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -34,7 +34,9 @@