79 lines
3.7 KiB
TypeScript
79 lines
3.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
emailMarketingCommercialProducts,
|
|
emailMarketingProductCodes,
|
|
entitlementLimitTypes,
|
|
featureKeys,
|
|
getEmailMarketingCommercialProduct,
|
|
standardEntitlementPlans,
|
|
} from "./index.js";
|
|
|
|
describe("email marketing commercial contract", () => {
|
|
it("keeps email marketing outside every base plan", () => {
|
|
for (const plan of standardEntitlementPlans) {
|
|
for (const featureKey of [featureKeys.emailMarketing, featureKeys.importedLists, featureKeys.crmBasedLists]) {
|
|
expect(plan.features.find((feature) => feature.featureKey === featureKey)?.limitType).toBe(entitlementLimitTypes.notIncluded);
|
|
}
|
|
}
|
|
});
|
|
|
|
it("defines the five exact recurring monthly tiers", () => {
|
|
expect(emailMarketingCommercialProducts.map(({ code, monthlyEmailLimit, amountCents }) => ({ code, monthlyEmailLimit, amountCents }))).toEqual([
|
|
{ code: emailMarketingProductCodes.s, monthlyEmailLimit: 10_000, amountCents: 5_900 },
|
|
{ code: emailMarketingProductCodes.m, monthlyEmailLimit: 50_000, amountCents: 14_900 },
|
|
{ code: emailMarketingProductCodes.l, monthlyEmailLimit: 100_000, amountCents: 24_900 },
|
|
{ code: emailMarketingProductCodes.xl, monthlyEmailLimit: 250_000, amountCents: 49_900 },
|
|
{ code: emailMarketingProductCodes.xxl, monthlyEmailLimit: 500_000, amountCents: 89_900 },
|
|
]);
|
|
expect(
|
|
emailMarketingCommercialProducts.every(
|
|
(product) =>
|
|
product.source === "recurring_add_on" &&
|
|
product.featureLimits?.[featureKeys.emailMarketing]?.limitType === entitlementLimitTypes.monthly &&
|
|
product.featureLimits[featureKeys.emailMarketing]?.limit === product.monthlyEmailLimit
|
|
)
|
|
).toBe(true);
|
|
});
|
|
|
|
it("persists stable translation keys for every catalog label", () => {
|
|
expect(emailMarketingCommercialProducts.map(({ code, title, description, groupTitle }) => ({ code, title, description, groupTitle }))).toEqual([
|
|
{
|
|
code: emailMarketingProductCodes.s,
|
|
title: "billing:selfServiceSubscription.emailMarketing.packages.s.title",
|
|
description: "billing:selfServiceSubscription.emailMarketing.packages.s.description",
|
|
groupTitle: "billing:selfServiceSubscription.emailMarketing.title",
|
|
},
|
|
{
|
|
code: emailMarketingProductCodes.m,
|
|
title: "billing:selfServiceSubscription.emailMarketing.packages.m.title",
|
|
description: "billing:selfServiceSubscription.emailMarketing.packages.m.description",
|
|
groupTitle: "billing:selfServiceSubscription.emailMarketing.title",
|
|
},
|
|
{
|
|
code: emailMarketingProductCodes.l,
|
|
title: "billing:selfServiceSubscription.emailMarketing.packages.l.title",
|
|
description: "billing:selfServiceSubscription.emailMarketing.packages.l.description",
|
|
groupTitle: "billing:selfServiceSubscription.emailMarketing.title",
|
|
},
|
|
{
|
|
code: emailMarketingProductCodes.xl,
|
|
title: "billing:selfServiceSubscription.emailMarketing.packages.xl.title",
|
|
description: "billing:selfServiceSubscription.emailMarketing.packages.xl.description",
|
|
groupTitle: "billing:selfServiceSubscription.emailMarketing.title",
|
|
},
|
|
{
|
|
code: emailMarketingProductCodes.xxl,
|
|
title: "billing:selfServiceSubscription.emailMarketing.packages.xxl.title",
|
|
description: "billing:selfServiceSubscription.emailMarketing.packages.xxl.description",
|
|
groupTitle: "billing:selfServiceSubscription.emailMarketing.title",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("resolves only canonical product codes", () => {
|
|
expect(getEmailMarketingCommercialProduct(emailMarketingProductCodes.m)?.monthlyEmailLimit).toBe(50_000);
|
|
expect(getEmailMarketingCommercialProduct("email_marketing_custom")).toBeUndefined();
|
|
});
|
|
});
|