create-ailk 0.46.3 → 0.46.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,7 @@ import {
24
24
  } from "../offerings-pricing";
25
25
  import {
26
26
  offeringPricingPages,
27
+ offeringsCopy,
27
28
  offeringsFragments,
28
29
  pagePlans,
29
30
  PRICING_HUB_SLUG,
@@ -193,6 +194,11 @@ const LABELS: OfferingsPricingLabels = {
193
194
  depositNote: (deposit) => "D⟪" + deposit,
194
195
  billedYearly: (amount) => "B⟪" + amount,
195
196
  custom: "C⟪",
197
+ perMonth: "PM⟪",
198
+ perYear: "PY⟪",
199
+ unitWithLabel: (period, label) => "U⟪" + period + "⟫" + label,
200
+ savings: (percent) => "S⟪" + percent,
201
+ regularPrice: (regular, current) => "R⟪" + regular + "⟫" + current,
196
202
  };
197
203
  const RECOMMENDED_LABEL = "FOR-YOU⟪";
198
204
  const ADDONS_HEADLINE = "ADDONS⟪";
@@ -327,7 +333,8 @@ describe("plan groups — offeringPlans on a pricing section (#12103 D2, AC-2)",
327
333
  expect(dataOf(placed, "retainers").billingToggle).toBe(false);
328
334
  expect(keysOf(placed, "writing-skills")).toEqual(["writing"]);
329
335
  expect(dataOf(placed, "writing-skills").billingToggle).toBe(true);
330
- expect(dataOf(placed, "extras").addons?.map((t) => t.name)).toEqual(["seo"]);
336
+ expect(keysOf(placed, "extras")).toEqual(["seo"]);
337
+ expect(dataOf(placed, "extras")).not.toHaveProperty("addons");
331
338
  });
332
339
 
333
340
  it("an unlisted plans section shows the page's plans less the listed ones", () => {
@@ -454,7 +461,6 @@ describe("the authored card layout survives (#12103 D6, AC-5)", () => {
454
461
 
455
462
  const PLAN_VARIANTS = [
456
463
  "three-tiers-with-toggle",
457
- "with-comparison-table",
458
464
  "two-tiers-with-extra-tier",
459
465
  "single-price-with-details",
460
466
  "features-and-plans",
@@ -472,7 +478,7 @@ describe("a bound section renders the variant the page sets (#12140 AC-1)", () =
472
478
  expect(placed.map((s) => s.id)).toEqual(["hero", "p"]);
473
479
  expect(dataOf(placed, "p").variant).toBe(variant);
474
480
  expect(dataOf(placed, "p").source).toBe("offerings");
475
- if (variant === "with-comparison-table")
481
+ if (variant === "band-hero")
476
482
  expect(keysOf(placed, "p")).toEqual(ALL_KEYS);
477
483
  if (variant === "single-price-with-details")
478
484
  expect(keysOf(placed, "p")).toEqual(["essentials"]);
@@ -507,14 +513,16 @@ describe("a bound section renders the variant the page sets (#12140 AC-1)", () =
507
513
  expect(keysOf(placed, "p")).toEqual(ALL_KEYS);
508
514
  });
509
515
 
510
- it("a bound add-ons section takes the tiles; a bound plans section beside it takes none", () => {
516
+ it("a bound add-ons section takes the add-on cards; a bound plans section beside it takes none", () => {
511
517
  const { placed } = render([
512
518
  pricingSection("a", { source: "offerings", variant: "addons" }),
513
- pricingSection("c", { source: "offerings", variant: "with-comparison-table" }),
519
+ pricingSection("c", { source: "offerings", variant: "band-hero" }),
514
520
  ]);
515
521
  expect(placed.map((s) => s.id)).toEqual(["a", "c"]);
516
- expect(dataOf(placed, "a").addons?.map((t) => t.name)).toEqual(["seo"]);
522
+ expect(keysOf(placed, "a")).toEqual(["seo"]);
523
+ expect(dataOf(placed, "a")).not.toHaveProperty("addons");
517
524
  expect(dataOf(placed, "a").source).toBe("offerings");
525
+ expect(keysOf(placed, "c")).not.toContain("seo");
518
526
  expect(dataOf(placed, "c")).not.toHaveProperty("addons");
519
527
  });
520
528
  });
@@ -522,8 +530,7 @@ describe("a bound section renders the variant the page sets (#12140 AC-1)", () =
522
530
  describe("a section with no source renders exactly as in 0.74.0 (#12140 AC-2)", () => {
523
531
  const AUTHORED = {
524
532
  headline: "Plans",
525
- variant: "with-comparison-table",
526
- comparisonGroups: [{ groupName: "Core", rows: [{ featureName: "Reports", values: { growth: true } }] }],
533
+ variant: "band-hero",
527
534
  features: [{ title: "Row", description: "One" }],
528
535
  extraTier: { name: "Big", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/contact" } },
529
536
  };
@@ -582,64 +589,11 @@ describe("features-and-plans on one product with two Prices (#12140 AC-3)", () =
582
589
  });
583
590
  });
584
591
 
585
- describe("comparisonGroups survive the swap, matched by plan slug (#12140 AC-4)", () => {
586
- const NAMED = workspaceShownSetSchema.parse({
587
- ...stripeSet(),
588
- offerings: stripeSet().offerings.map((o) => ({
589
- ...o,
590
- name: o.plan.charAt(0).toUpperCase() + o.plan.slice(1),
591
- })),
592
- });
593
- const G = [
594
- { groupName: "Core", rows: [{ featureName: "Reports", values: { essentials: true, growth: "Weekly", absent: true } }] },
595
- ];
596
- const section = (groups: unknown) =>
597
- pricingSection("c", {
598
- source: "offerings",
599
- variant: "with-comparison-table",
600
- offeringPlans: ["essentials", "growth"],
601
- comparisonGroups: groups,
602
- });
603
-
604
- it("keeps the grid and keys the cards by slug, not by name", () => {
605
- const { placed } = render([HERO, section(G)], { set: NAMED });
606
- expect(dataOf(placed, "c").comparisonGroups).toEqual(G);
607
- expect(keysOf(placed, "c")).toEqual(["essentials", "growth"]);
608
- expect(dataOf(placed, "c").plans.map((c) => c.name)).toEqual(["Essentials", "Growth"]);
609
- });
610
-
611
- it("drops a cell's authored link and keeps every other value", () => {
612
- const linked = [
613
- {
614
- groupName: "Core",
615
- rows: [
616
- {
617
- featureName: "Reports",
618
- values: {
619
- essentials: true,
620
- growth: { text: "Weekly", verdict: "yes", link: { label: "See", href: "https://example.com" } },
621
- absent: true,
622
- },
623
- },
624
- ],
625
- },
626
- ];
627
- const { placed } = render([section(linked)], { set: NAMED });
628
- expect(dataOf(placed, "c").comparisonGroups).toEqual([
629
- { groupName: "Core", rows: [{ featureName: "Reports", values: { essentials: true, growth: { text: "Weekly", verdict: "yes" }, absent: true } }] },
630
- ]);
631
- });
632
- });
633
-
634
592
  describe("no vendor, and every price link on a non-written section is a checkout key (#12140 AC-5, NFR-2)", () => {
635
593
  it("holds over a page of every bound variant, a bound add-ons section and an unbound section", () => {
636
- const linkedGrid = [
637
- { groupName: "Core", rows: [{ featureName: "R", values: { growth: { text: "W", link: { label: "See", href: "/elsewhere" } } } }] },
638
- ];
639
594
  const authored = {
640
595
  plans: [{ key: "own", name: "Own", price: { custom: "$1" }, features: [], cta: { label: "Go", href: "/elsewhere" } }],
641
596
  extraTier: { name: "Big", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/elsewhere" } },
642
- comparisonGroups: linkedGrid,
643
597
  };
644
598
  const { placed } = render([
645
599
  HERO,
@@ -659,10 +613,6 @@ describe("no vendor, and every price link on a non-written section is a checkout
659
613
  expect(ours(card.annualCtaHref)).toBe(true);
660
614
  }
661
615
  for (const tile of data.addons ?? []) expect(ours(tile.cta?.href)).toBe(true);
662
- for (const group of data.comparisonGroups ?? [])
663
- for (const row of group.rows)
664
- for (const value of Object.values(row.values))
665
- if (typeof value === "object") expect(value).not.toHaveProperty("link");
666
616
  }
667
617
  });
668
618
  });
@@ -728,31 +678,14 @@ describe("a written section (#12140 AC-6)", () => {
728
678
  expect(keysOf(render([W3, pricingSection("p")]).placed, "w")).toEqual(["custom", "malformed"]);
729
679
  });
730
680
 
731
- it("drops a written add-on tile and a cell link that reach the Offerings checkout", () => {
681
+ it("drops a written add-on tile that reaches the Offerings checkout", () => {
732
682
  const tile = (name: string, href: string) => ({ name, price: "$1", cta: { label: "Add", href } });
733
683
  const W4 = pricingSection("w", {
734
684
  source: "written",
735
685
  addons: [tile("Kept", "/contact"), tile("Sold", "/api/offerings/checkout/rush_once")],
736
- comparisonGroups: [
737
- {
738
- groupName: "G",
739
- rows: [
740
- {
741
- featureName: "Row",
742
- values: {
743
- custom: { text: "Yes", link: { label: "Buy", href: "/api/offerings/checkout/writing_monthly" } },
744
- other: { text: "Ask", link: { label: "Ask", href: "/contact" } },
745
- },
746
- },
747
- ],
748
- },
749
- ],
750
686
  });
751
687
  const data = dataOf(render([W4, pricingSection("p")]).placed, "w");
752
688
  expect(data.addons?.map((a) => a.name)).toEqual(["Kept"]);
753
- const values = data.comparisonGroups?.[0]?.rows[0]?.values ?? {};
754
- expect(values["custom"]).toEqual({ text: "Yes" });
755
- expect(values["other"]).toEqual({ text: "Ask", link: { label: "Ask", href: "/contact" } });
756
689
  });
757
690
 
758
691
  it("drops them through pricingSections for page plans: [] too", async () => {
@@ -826,17 +759,14 @@ describe("a written section (#12140 AC-6)", () => {
826
759
  });
827
760
 
828
761
  describe("the plan bar options survive the Stripe path (#12141 D9, AC-1)", () => {
829
- const REC_GRID = { pickerLabel: "Plan", pinnedGroups: true, groupsOpen: "first" };
762
+ const ALL_CARDS = { price: true, button: true, billingSwitch: true };
830
763
 
831
764
  it.each([
832
765
  ["an unbound plans slot", {}],
833
- ["a bound section", { source: "offerings", variant: "with-comparison-table" }],
834
- ])("%s keeps planBar and comparisonPlanBar over the Offerings cards, deep-equal", (_label, extra) => {
835
- const { placed } = render([
836
- pricingSection("p", { ...extra, planBar: {}, comparisonPlanBar: REC_GRID }),
837
- ]);
838
- expect(dataOf(placed, "p").planBar).toEqual({});
839
- expect(dataOf(placed, "p").comparisonPlanBar).toEqual(REC_GRID);
766
+ ["a bound section", { source: "offerings", variant: "band-hero" }],
767
+ ])("%s keeps planBar over the Offerings cards, deep-equal", (_label, extra) => {
768
+ const { placed } = render([pricingSection("p", { ...extra, planBar: ALL_CARDS })]);
769
+ expect(dataOf(placed, "p").planBar).toEqual(ALL_CARDS);
840
770
  });
841
771
  });
842
772
 
@@ -1011,7 +941,7 @@ describe("a selecting bound section builds its cards from Stripe (#12193 D5, AC-
1011
941
  expect(keysOf(render(sections, { set: tagged(pro), plans: ["essentials"] }).placed, "c")).toEqual(["growth", "pro", "writing"]);
1012
942
  });
1013
943
 
1014
- it("an add-ons section selects its collection, the contact tile included", () => {
944
+ it("an add-ons section selects its collection, the contact card included", () => {
1015
945
  const set = stripeSetWith((o) => {
1016
946
  o.find((p) => p.plan === "seo")!.collection = "growth-hub";
1017
947
  }, [COMMERCE]);
@@ -1019,7 +949,7 @@ describe("a selecting bound section builds its cards from Stripe (#12193 D5, AC-
1019
949
  [pricingSection("p"), pricingSection("a", { source: "offerings", variant: "addons", offeringCollection: "growth-hub" })],
1020
950
  { set },
1021
951
  );
1022
- expect(dataOf(placed, "a").addons!.map((t) => (t as { key?: string }).key)).toEqual(["seo", "commerce"]);
952
+ expect(keysOf(placed, "a")).toEqual(["seo", "commerce"]);
1023
953
  });
1024
954
 
1025
955
  it("a section with offeringPlans keeps one card per plan though the plans carry a tier (AC-17)", () => {
@@ -1198,3 +1128,581 @@ describe("a bound section keeps the level card's settings (#12209 D2, D8, D11, D
1198
1128
  expect(dataOf(placed, "two")).not.toHaveProperty("separateTiers");
1199
1129
  });
1200
1130
  });
1131
+
1132
+ // ─── #12238 — a collection of contacts on a live page ───────────────────────
1133
+
1134
+ /** The report's shape: two plan contacts and one add-on contact of `growth-hub`. */
1135
+ const HUB_CONTACTS: OfferingsContactProduct[] = [
1136
+ { ...COMMERCE, productId: "prod_hub_pro", plan: "growth-hub-pro", ailkGroup: "plan", name: "Growth Hub Pro", ailkOrder: 10 },
1137
+ { ...COMMERCE, productId: "prod_hub_pro_plus", plan: "growth-hub-pro-plus", ailkGroup: "plan", name: "Growth Hub Pro Plus", ailkOrder: 20 },
1138
+ { ...COMMERCE, productId: "prod_hub_commerce", plan: "growth-hub-commerce", ailkGroup: "addon", name: "AI-Native Commerce", ailkOrder: 30 },
1139
+ ];
1140
+ const HUB_PLANS = HUB_CONTACTS.map((c) => c.plan);
1141
+
1142
+ /** A shown set whose only members are the report's contacts: no priced product at all. */
1143
+ function contactsOnlySet(): WorkspaceShownSet {
1144
+ return workspaceShownSetSchema.parse({
1145
+ ...stripeSet(),
1146
+ productIds: [],
1147
+ recommended: { plan: null, addon: null },
1148
+ offerings: [],
1149
+ contacts: HUB_CONTACTS,
1150
+ });
1151
+ }
1152
+
1153
+ describe("a collection of contacts renders on the live page (#12238)", () => {
1154
+ // Past every earlier suite's mocked clock (#12193's is 10 ** 12 ahead), so
1155
+ // no shared read of theirs is reused.
1156
+ let now = Date.now() + 2 * 10 ** 12;
1157
+ beforeEach(() => {
1158
+ now += 16_000;
1159
+ jest.spyOn(Date, "now").mockReturnValue(now);
1160
+ });
1161
+ afterEach(() => jest.restoreAllMocks());
1162
+
1163
+ const answer = (shownSet: unknown) =>
1164
+ fetchMock.mockImplementation(async () => ({
1165
+ ok: true,
1166
+ status: 200,
1167
+ json: async () => ({ ok: true, data: { status: "shown", shownSet } }),
1168
+ }));
1169
+ const bound = (id: string, data: Record<string, unknown> = {}) =>
1170
+ pricingSection(id, {
1171
+ source: "offerings",
1172
+ offeringCollection: "growth-hub",
1173
+ variant: "three-tiers-with-toggle",
1174
+ billingToggle: false,
1175
+ ...data,
1176
+ });
1177
+ // #12241 D3 — an add-on, its contact included, is a card in the section's plans.
1178
+ const tileKeys = (placed: PageSection[], id: string) => keysOf(placed, id);
1179
+
1180
+ it("the cause: a page whose own `plans` is [] never reads the shown set, so its bound section keeps no card", async () => {
1181
+ answer(contactsOnlySet());
1182
+ const sections = await pricingSections([HERO, bound("plans")], { plans: [], plan: undefined, locale: "en" });
1183
+ expect(fetchMock).not.toHaveBeenCalled();
1184
+ expect(keysOf(sections, "plans")).toEqual([]);
1185
+ });
1186
+
1187
+ it("a shown set of contacts only: the plan contacts are cards and the add-on contact a tile, never the contact email", async () => {
1188
+ answer(contactsOnlySet());
1189
+ const sections = await pricingSections(
1190
+ [HERO, bound("plans"), bound("extras", { variant: "addons" })],
1191
+ { plans: HUB_PLANS, plan: undefined, locale: "en" },
1192
+ );
1193
+ expect(sections.map((s) => s.id)).toEqual(["hero", "plans", "extras"]);
1194
+ expect(keysOf(sections, "plans")).toEqual(["growth-hub-pro", "growth-hub-pro-plus"]);
1195
+ expect(dataOf(sections, "plans").plans[0]).toMatchObject({ price: { custom: "From 179 USD a month" }, offerPrices: [] });
1196
+ expect(tileKeys(sections, "extras")).toEqual(["growth-hub-commerce"]);
1197
+ });
1198
+
1199
+ it("the report's page — one bound plans section on a page listing the slugs — shows both plan contacts", async () => {
1200
+ answer(contactsOnlySet());
1201
+ const sections = await pricingSections([HERO, bound("plans")], { plans: HUB_PLANS, plan: undefined, locale: "en" });
1202
+ expect(keysOf(sections, "plans")).toEqual(["growth-hub-pro", "growth-hub-pro-plus"]);
1203
+ });
1204
+
1205
+ it("an expired shown set takes the contact email, even beside a bound section's written cards", async () => {
1206
+ const written = { key: "written", name: "Written", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/contact" } };
1207
+ answer(workspaceShownSetSchema.parse({ ...stripeSet(), state: "expired" }));
1208
+ const sections = await pricingSections([HERO, bound("plans", { writtenPlans: [written] })], { plans: HUB_PLANS, plan: undefined, locale: "en" });
1209
+ expect(sections.map((s) => s.id)).toEqual(["hero", "offerings-contact"]);
1210
+ });
1211
+
1212
+ it("a shown set with no priced product and no contact of the collection still takes the contact email", async () => {
1213
+ answer(workspaceShownSetSchema.parse({ ...contactsOnlySet(), contacts: [{ ...HUB_CONTACTS[0]!, collection: "other" }] }));
1214
+ const sections = await pricingSections([HERO, bound("plans")], { plans: HUB_PLANS, plan: undefined, locale: "en" });
1215
+ expect(sections.map((s) => s.id)).toEqual(["hero", "offerings-contact"]);
1216
+ });
1217
+ });
1218
+
1219
+ describe("offeringPlans may name a contact by its slug (#12238, operator 2026-11-23)", () => {
1220
+ const set = () =>
1221
+ stripeSetWith(() => {}, [
1222
+ { ...COMMERCE, productId: "prod_e", plan: "enterprise", ailkGroup: "plan", name: "Enterprise", shortName: "Enterprise", collection: "growth-platform" },
1223
+ COMMERCE,
1224
+ ]);
1225
+
1226
+ it("a bound section naming a plan contact renders its card beside the named plans", () => {
1227
+ const { placed } = render([pricingSection("p", { source: "offerings", offeringPlans: ["growth", "enterprise"] })], { set: set() });
1228
+ expect(keysOf(placed, "p")).toEqual(["growth", "enterprise"]);
1229
+ expect(dataOf(placed, "p").plans[1]).toMatchObject({ name: "Enterprise", price: { custom: "From 179 USD a month" } });
1230
+ });
1231
+
1232
+ it("a bound section naming only a contact renders that contact's card", () => {
1233
+ const { placed } = render([pricingSection("p", { source: "offerings", offeringPlans: ["enterprise"] })], { set: set() });
1234
+ expect(keysOf(placed, "p")).toEqual(["enterprise"]);
1235
+ });
1236
+
1237
+ it("a plan group with no source (#12103) naming a contact renders its card", () => {
1238
+ const { placed } = render([pricingSection("p", { offeringPlans: ["enterprise", "writing"] })], { set: set() });
1239
+ expect(keysOf(placed, "p")).toEqual(["writing", "enterprise"]);
1240
+ });
1241
+
1242
+ it("a bound add-ons section naming an add-on contact renders its tile", () => {
1243
+ const { placed } = render(
1244
+ [pricingSection("p"), pricingSection("a", { source: "offerings", variant: "addons", offeringPlans: ["seo", "commerce"] })],
1245
+ { set: set() },
1246
+ );
1247
+ // #12241 D3 — the add-ons, the contact included, are cards in the section's plans.
1248
+ expect(keysOf(placed, "a")).toEqual(["seo", "commerce"]);
1249
+ });
1250
+
1251
+ it("the page's own `plans` naming a contact still shows it in no unbound slot", () => {
1252
+ const { placed } = render([pricingSection("p")], { set: set(), plans: ["growth", "enterprise"] });
1253
+ expect(allKeys(placed)).toEqual(["growth"]);
1254
+ });
1255
+ });
1256
+
1257
+ describe("a contact offeringPlans names keeps the same-origin link rule (#12238)", () => {
1258
+ const base = process.env["NEXT_PUBLIC_BASE_URL"];
1259
+ beforeEach(() => {
1260
+ process.env["NEXT_PUBLIC_BASE_URL"] = "https://example.com";
1261
+ });
1262
+ afterEach(() => {
1263
+ if (base === undefined) delete process.env["NEXT_PUBLIC_BASE_URL"];
1264
+ else process.env["NEXT_PUBLIC_BASE_URL"] = base;
1265
+ });
1266
+ const setWithUrl = (url: string) =>
1267
+ stripeSetWith(() => {}, [{ ...COMMERCE, productId: "prod_e", plan: "enterprise", ailkGroup: "plan", name: "Enterprise", url }]);
1268
+
1269
+ it.each([
1270
+ ["a bound section", { source: "offerings", offeringPlans: ["enterprise"] }],
1271
+ ["a plan group with no source", { offeringPlans: ["growth", "enterprise"] }],
1272
+ ])("%s gives no card for a named contact linking the site's own /api/", (_label, data) => {
1273
+ const { placed } = render([pricingSection("p", data)], { set: setWithUrl("https://example.com/api/offerings/checkout/growth_monthly") });
1274
+ expect(allKeys(placed)).not.toContain("enterprise");
1275
+ });
1276
+
1277
+ it.each([
1278
+ ["a bound section", { source: "offerings", offeringPlans: ["enterprise"] }],
1279
+ ["a plan group with no source", { offeringPlans: ["growth", "enterprise"] }],
1280
+ ])("%s links a named contact's same-origin page internally", (_label, data) => {
1281
+ const { placed } = render([pricingSection("p", data)], { set: setWithUrl("https://example.com/contact") });
1282
+ const card = dataOf(placed, "p").plans.find((c) => c.key === "enterprise");
1283
+ expect(card?.cta).toEqual({ label: "Talk to us", href: "/contact" });
1284
+ });
1285
+ });
1286
+
1287
+ // ─── #12246 — a comparison table's plan columns on a pricing page ───────────
1288
+
1289
+ describe("pricingSections — comparison tables with plan columns (#12246 D3, D4, D7)", () => {
1290
+ // Past every other suite's clock (#12238's is 2 * 10 ** 12 ahead), so no earlier shared read is reused.
1291
+ let now = Date.now() + 3 * 10 ** 12;
1292
+ beforeEach(() => {
1293
+ now += 16_000;
1294
+ jest.spyOn(Date, "now").mockReturnValue(now);
1295
+ });
1296
+ afterEach(() => jest.restoreAllMocks());
1297
+
1298
+ const answer = (data: unknown) =>
1299
+ fetchMock.mockImplementation(async () => ({
1300
+ ok: true,
1301
+ status: 200,
1302
+ json: async () => ({ ok: true, data }),
1303
+ }));
1304
+
1305
+ const both = (plan: string, monthly: number, yearly: number) => [
1306
+ stripePrice(plan, "monthly", monthly),
1307
+ stripePrice(plan, "yearly", yearly),
1308
+ ];
1309
+ /** S3: three plans priced both ways, `growth` titled "Growth" and Recommended, and an add-on. */
1310
+ function s3(): WorkspaceShownSet {
1311
+ const offerings = [
1312
+ stripeProduct("essentials", "plan", both("essentials", 220000, 2376000), { name: "Essentials" }),
1313
+ stripeProduct("growth", "plan", both("growth", 440000, 4752000), {
1314
+ shortName: "Growth",
1315
+ name: "Growth plan",
1316
+ recommended: true,
1317
+ }),
1318
+ stripeProduct("scale", "plan", both("scale", 650000, 7020000), { name: "Scale" }),
1319
+ stripeProduct("extra", "addon", [stripePrice("extra", "monthly", 9900)]),
1320
+ ];
1321
+ return workspaceShownSetSchema.parse({
1322
+ workspaceId: "wksp_01890a5d-ac96-774b-bcce-b302099a8057",
1323
+ organizationId: "org_01890a5d-ac96-774b-bcce-b302099a8058",
1324
+ productIds: offerings.map((o) => o.productId),
1325
+ recommended: { plan: "prod_growth", addon: null },
1326
+ offerings,
1327
+ state: "current",
1328
+ snapshotAt: "2026-11-20T00:00:00.000Z",
1329
+ });
1330
+ }
1331
+
1332
+ type Table = Extract<PageSection, { type: "comparison-table" }>;
1333
+ type Column = Table["data"]["columns"][number] & { offering?: { name: string; cta: { href: string } } };
1334
+ const GROUPS = [{ groupName: "Writing", rows: [{ featureName: "Pieces", values: { growth: "8", us: true } }] }];
1335
+ const table = (id: string, columns: unknown[], groups: unknown = GROUPS, extra: Record<string, unknown> = {}) =>
1336
+ ({ id, type: "comparison-table", data: { columns, groups, ...extra } }) as PageSection;
1337
+ const MIXED = [{ key: "us", name: "Us" }, { key: "growth", plan: "growth" }, { key: "them", name: "Them" }];
1338
+ const PLAN3 = ["essentials", "growth", "scale"].map((key) => ({ key, plan: key }));
1339
+ const tableOf = (sections: PageSection[], id = "t") => {
1340
+ const found = sections.find((s) => s.id === id);
1341
+ if (!found || found.type !== "comparison-table") throw new Error(`no table ${id}`);
1342
+ return found.data as Omit<Table["data"], "columns"> & { billingPeriod?: string; columns: Column[] };
1343
+ };
1344
+ const options = (extra: Partial<Parameters<typeof pricingSections>[1]> = {}) => ({
1345
+ plans: undefined,
1346
+ plan: undefined,
1347
+ locale: "en",
1348
+ ...extra,
1349
+ });
1350
+
1351
+ it("AC-1: a plan column takes its plan from the shown set, whatever the page's plans list", async () => {
1352
+ answer({ status: "shown", shownSet: s3() });
1353
+ const sections = await pricingSections([HERO, table("t", MIXED)], options({ plans: ["scale"] }));
1354
+ const columns = tableOf(sections).columns;
1355
+ expect(columns.map((c) => c.offering?.name)).toEqual([undefined, "Growth", undefined]);
1356
+ expect(columns[1]!.offering?.cta.href).toBe(`${OFFERINGS_CHECKOUT_PATH}/growth_monthly`);
1357
+ });
1358
+
1359
+ it("AC-2: an authored offering never reaches a column, typed or plan", async () => {
1360
+ answer({ status: "shown", shownSet: s3() });
1361
+ const forged = { name: "Free", price: { monthly: "$0" }, cta: { label: "Take", href: "https://evil.example" } };
1362
+ const sections = await pricingSections(
1363
+ [
1364
+ HERO,
1365
+ table("t", [
1366
+ { key: "us", name: "Us", offering: forged },
1367
+ { key: "ghost", plan: "ghost", offering: forged },
1368
+ { key: "growth", plan: "growth", offering: forged },
1369
+ ]),
1370
+ ],
1371
+ options(),
1372
+ );
1373
+ const columns = tableOf(sections).columns;
1374
+ expect(columns[0]).not.toHaveProperty("offering");
1375
+ expect(columns[1]).not.toHaveProperty("offering");
1376
+ expect(columns[2]!.offering?.cta.href).toBe(`${OFFERINGS_CHECKOUT_PATH}/growth_monthly`);
1377
+ });
1378
+
1379
+ describe("AC-3: the table opens on the period the page's cards open on", () => {
1380
+ beforeEach(() => answer({ status: "unconnected" }));
1381
+ const cards = (data: Record<string, unknown>) =>
1382
+ pricingSection("p", { plans: [{ key: "a", name: "A", price: { monthly: "$1", annual: "$10" }, features: [], cta: { label: "Go", href: "/a" } }], ...data });
1383
+
1384
+ it("annual with a toggle, monthly without, and ?billing= over both", async () => {
1385
+ const period = async (data: Record<string, unknown>, extra = {}) =>
1386
+ tableOf(await pricingSections([cards(data), table("t", PLAN3)], options(extra))).billingPeriod;
1387
+ expect(await period({ billingToggle: true })).toBe("annual");
1388
+ expect(await period({ hideBillingToggle: true })).toBe("annual");
1389
+ expect(await period({})).toBe("monthly");
1390
+ expect(await period({ billingToggle: true }, { period: "monthly" })).toBe("monthly");
1391
+ expect(await period({}, { period: "annual" })).toBe("annual");
1392
+ expect(await period({ billingToggle: true }, { period: "weekly" })).toBe("annual");
1393
+ });
1394
+
1395
+ it("monthly beside a layout that shows monthly prices only, whatever its stored toggle", async () => {
1396
+ const period = async (variant: string) =>
1397
+ tableOf(await pricingSections([cards({ variant, billingToggle: true }), table("t", PLAN3)], options())).billingPeriod;
1398
+ for (const variant of ["two-tiers-with-extra-tier", "band-hero", "single-price-with-details", "features-and-plans"])
1399
+ expect(await period(variant)).toBe("monthly");
1400
+ expect(await period("three-tiers-with-toggle")).toBe("annual");
1401
+ });
1402
+
1403
+ it("annual on the shown path, where the mapper turns the toggle on", async () => {
1404
+ answer({ status: "shown", shownSet: s3() });
1405
+ const sections = await pricingSections([cards({}), table("t", PLAN3)], options());
1406
+ expect(tableOf(sections).billingPeriod).toBe("annual");
1407
+ });
1408
+
1409
+ it("an authored billingPeriod never reaches the table, and a typed table takes none", async () => {
1410
+ const sections = await pricingSections(
1411
+ [cards({}), table("t", PLAN3, GROUPS, { billingPeriod: "annual" }), table("u", MIXED.filter((c) => !("plan" in c)))],
1412
+ options(),
1413
+ );
1414
+ expect(tableOf(sections).billingPeriod).toBe("monthly");
1415
+ expect(tableOf(sections, "u")).not.toHaveProperty("billingPeriod");
1416
+ });
1417
+ });
1418
+
1419
+ it("AC-4: a slug the shown set lacks stays unresolved", async () => {
1420
+ answer({ status: "shown", shownSet: s3() });
1421
+ const GHOST = { key: "ghost", plan: "ghost" };
1422
+ const shown = await pricingSections([HERO, table("t", [GHOST, { key: "growth", plan: "growth" }])], options());
1423
+ expect(tableOf(shown).columns.map((c) => c.offering?.name)).toEqual([undefined, "Growth"]);
1424
+ });
1425
+
1426
+ it("AC-4: every plan column stays unresolved on the contact path", async () => {
1427
+ answer({ status: "empty" });
1428
+ const contact = await pricingSections([HERO, pricingSection("p"), table("t", PLAN3)], options());
1429
+ expect(contact.map((s) => s.id)).toEqual(["hero", "offerings-contact", "t"]);
1430
+ expect(tableOf(contact).columns.every((c) => c.offering === undefined)).toBe(true);
1431
+ });
1432
+
1433
+ it("AC-6: a stored with-comparison-table page reads as cards and a table of three resolved plan columns", async () => {
1434
+ answer({ status: "shown", shownSet: s3() });
1435
+ const stored = PageSectionsSchema.parse([
1436
+ HERO,
1437
+ {
1438
+ id: "plans",
1439
+ type: "pricing",
1440
+ data: {
1441
+ variant: "with-comparison-table",
1442
+ source: "offerings",
1443
+ offeringPlans: ["essentials", "growth", "scale"],
1444
+ plans: [],
1445
+ comparisonGroups: [
1446
+ {
1447
+ groupName: "Writing",
1448
+ rows: [{ featureName: "Samples", values: { essentials: { text: "See", link: { label: "Samples", href: "/samples" } } } }],
1449
+ },
1450
+ ],
1451
+ },
1452
+ },
1453
+ ]);
1454
+ const sections = await pricingSections(stored, options());
1455
+ expect(sections.map((s) => [s.id, s.type])).toEqual([
1456
+ ["hero", "hero"],
1457
+ ["plans", "pricing"],
1458
+ ["plans-comparison", "comparison-table"],
1459
+ ]);
1460
+ expect(keysOf(sections, "plans")).toEqual(["essentials", "growth", "scale"]);
1461
+ const data = tableOf(sections, "plans-comparison");
1462
+ expect(data.columns.map((c) => c.offering?.name)).toEqual(["Essentials", "Growth", "Scale"]);
1463
+ expect(data.groups[0]!.rows[0]!.values).toEqual({ essentials: { text: "See" } });
1464
+ });
1465
+
1466
+ it("AC-6: a written table cell that links the Offerings checkout loses its link, in any URL form", async () => {
1467
+ answer({ status: "unconnected" });
1468
+ const cell = (href: string) => ({ text: "Buy", link: { label: "Buy", href } });
1469
+ const groups = [
1470
+ {
1471
+ groupName: "G",
1472
+ rows: [
1473
+ {
1474
+ featureName: "Row",
1475
+ values: {
1476
+ a: cell("/api/offerings/checkout/x"),
1477
+ b: cell("/api/%6Ffferings/checkout/x"),
1478
+ c: cell("/contact"),
1479
+ d: cell("/api//offerings/checkout/x"),
1480
+ e: cell("/api/offerings//checkout/x"),
1481
+ f: cell("/api/\\offerings/checkout/x"),
1482
+ g: cell("/api/%2Fofferings/checkout/x"),
1483
+ },
1484
+ },
1485
+ ],
1486
+ },
1487
+ ];
1488
+ const sections = await pricingSections([table("t", [{ key: "a", name: "A" }], groups)], options());
1489
+ expect(tableOf(sections).groups[0]!.rows[0]!.values).toEqual({
1490
+ a: { text: "Buy" },
1491
+ b: { text: "Buy" },
1492
+ c: cell("/contact"),
1493
+ d: { text: "Buy" },
1494
+ e: { text: "Buy" },
1495
+ f: { text: "Buy" },
1496
+ g: { text: "Buy" },
1497
+ });
1498
+ });
1499
+
1500
+ it("returns a typed table with no checkout link as the same object", async () => {
1501
+ answer({ status: "unconnected" });
1502
+ const typed = table("t", [{ key: "us", name: "Us" }]);
1503
+ const sections = await pricingSections([HERO, typed], options());
1504
+ expect(sections[1]).toBe(typed);
1505
+ });
1506
+ });
1507
+
1508
+ // ─── #12242 — the price unit on a Stripe section ────────────────────────────
1509
+
1510
+ describe("the price unit's words and a bound section's options (#12242)", () => {
1511
+ const seatSet = () => {
1512
+ const set = structuredClone(stripeSet());
1513
+ set.offerings.find((o) => o.plan === "writing")!.unitLabel = "seat";
1514
+ set.offerings.push(
1515
+ stripeProduct("hub", "plan", [stripePrice("hub", "monthly", 3000), stripePrice("hub", "yearly", 30000)], {
1516
+ unitLabel: "site",
1517
+ }),
1518
+ );
1519
+ set.productIds = set.offerings.map((o) => o.productId);
1520
+ return set;
1521
+ };
1522
+ type Card = { key?: string; annualPriceNote?: string; priceParts?: { monthly?: { unit: string }; annual?: { was?: string } } };
1523
+ const cardIn = (placed: PageSection[], key: string) =>
1524
+ (dataOf(placed, "p").plans as Card[]).find((c) => c.key === key)!;
1525
+
1526
+ it("AC-2, AC-9 — the shipped catalog gives /mo, /yr and the one join", async () => {
1527
+ const { labels } = await offeringsCopy("en");
1528
+ expect(labels.perMonth).toBe("/mo");
1529
+ expect(labels.perYear).toBe("/yr");
1530
+ expect(labels.unitWithLabel("/mo", "seat")).toBe("/mo/seat");
1531
+ expect(labels.unitWithLabel("/mo", "site")).toBe("/mo/site");
1532
+ expect(labels.unitWithLabel("/mo", "$& $1")).toBe("/mo/$& $1");
1533
+ expect(labels.savings("17")).toBe("Save 17% billed annually");
1534
+ expect(labels.regularPrice("$20", "$17")).toBe("Regular price $20, now $17");
1535
+ });
1536
+
1537
+ it("AC-4, AC-5 — a bound section's yearly line and strike reach its mapping, and are not placed", () => {
1538
+ const { placed } = render([pricingSection("p", { source: "offerings", annualPriceLine: "savings", annualStrikePrice: true })], {
1539
+ set: seatSet(),
1540
+ });
1541
+ expect(cardIn(placed, "writing").annualPriceNote).toBe("S⟪17");
1542
+ expect(cardIn(placed, "writing").priceParts?.annual?.was).toBe("$30");
1543
+ expect(cardIn(placed, "writing").priceParts?.monthly?.unit).toBe("U⟪PM⟪⟫seat");
1544
+ expect(cardIn(placed, "hub").priceParts?.monthly?.unit).toBe("U⟪PM⟪⟫site");
1545
+ const unset = render([pricingSection("p", { source: "offerings" })], { set: seatSet() }).placed;
1546
+ expect(cardIn(unset, "writing").annualPriceNote).toBe("B⟪$300");
1547
+ expect(cardIn(unset, "writing").priceParts?.annual).not.toHaveProperty("was");
1548
+ });
1549
+
1550
+ it("AC-6 — a bound section keeps its price size and tone", () => {
1551
+ const { placed } = render([pricingSection("p", { source: "offerings", priceAmountSize: "xl", priceUnitTone: "muted" })]);
1552
+ expect(dataOf(placed, "p")).toMatchObject({ priceAmountSize: "xl", priceUnitTone: "muted" });
1553
+ });
1554
+
1555
+ it("AC-7 — an unbound page keeps the billed line; an authored priceParts never reaches a section", async () => {
1556
+ const { placed } = render([pricingSection("p")], { set: seatSet() });
1557
+ expect(cardIn(placed, "writing").annualPriceNote).toBe("B⟪$300");
1558
+ fetchMock.mockImplementation(async () => ({
1559
+ ok: true,
1560
+ status: 200,
1561
+ json: async () => ({ ok: true, data: { status: "unconnected" } }),
1562
+ }));
1563
+ const priceParts = { monthly: { amount: "$1", unit: "/forged" } };
1564
+ const plan = { key: "a", name: "A", price: { monthly: "$9" }, features: [], cta: { label: "Go", href: "/go" }, priceParts };
1565
+ const section = pricingSection("w", {
1566
+ source: "written",
1567
+ plans: [{ ...plan, levels: [{ ...plan, label: "L1" }, { ...plan, label: "L2" }] }],
1568
+ extraTier: plan,
1569
+ });
1570
+ const [out] = await pricingSections([section], { plans: undefined, plan: undefined, locale: "en" });
1571
+ const data = out!.data as Record<string, unknown> & { plans: Array<Record<string, unknown> & { levels: Record<string, unknown>[] }> };
1572
+ expect(data.plans[0]).not.toHaveProperty("priceParts");
1573
+ for (const level of data.plans[0]!.levels) expect(level).not.toHaveProperty("priceParts");
1574
+ expect(data.extraTier).not.toHaveProperty("priceParts");
1575
+ });
1576
+ });
1577
+
1578
+ // SOFT_LOCK_OK: #12243 AC-6 — every section reads the site's origin, so a
1579
+ // same-origin footnote link is an internal path whichever way the section
1580
+ // picks its plans, not only in tier mode.
1581
+ describe("a card footnote's link on the site's own origin (#12243 AC-6)", () => {
1582
+ const ORIGIN_ENV = process.env["NEXT_PUBLIC_BASE_URL"];
1583
+ beforeAll(() => {
1584
+ process.env["NEXT_PUBLIC_BASE_URL"] = "https://site.test";
1585
+ });
1586
+ afterAll(() => {
1587
+ if (ORIGIN_ENV === undefined) delete process.env["NEXT_PUBLIC_BASE_URL"];
1588
+ else process.env["NEXT_PUBLIC_BASE_URL"] = ORIGIN_ENV;
1589
+ });
1590
+
1591
+ function footnoted(): WorkspaceShownSet {
1592
+ const set = stripeSet();
1593
+ for (const o of set.offerings) {
1594
+ if (o.plan !== "growth") continue;
1595
+ o.footnote = "*Plus onboarding.";
1596
+ o.footnoteLink = { label: "Learn more", url: "https://site.test/onboarding#fee" };
1597
+ }
1598
+ return set;
1599
+ }
1600
+ const growthLink = (placed: PageSection[], id: string) =>
1601
+ dataOf(placed, id).plans.find((card) => card.key === "growth")?.footnoteLink;
1602
+
1603
+ it.each([
1604
+ ["a bound section that names its plans", pricingSection("p", { source: "offerings", offeringPlans: ["essentials", "growth"] })],
1605
+ ["a bound section that builds its cards from Stripe", pricingSection("p", { source: "offerings" })],
1606
+ ["a listed plan group", pricingSection("p", { offeringPlans: ["essentials", "growth"] })],
1607
+ ["the page's plans section", pricingSection("p")],
1608
+ ])("%s links it as an internal path", (_label, section) => {
1609
+ const { placed } = render([HERO, section], { set: footnoted() });
1610
+ expect(growthLink(placed, "p")).toEqual({ label: "Learn more", href: "/onboarding#fee" });
1611
+ });
1612
+ });
1613
+
1614
+ // ─── #12241 — one pricing card for plans and add-ons ─────────────────────────
1615
+
1616
+ describe("a bound section keeps the card settings (#12241 D1, D9)", () => {
1617
+ it("AC-2 page: a bound addons section keeps cardLayout, featureListStyle, levelSwitchControl and levelSwitchPlacement", () => {
1618
+ const settings = {
1619
+ cardLayout: "centered",
1620
+ featureListStyle: "included-dots",
1621
+ levelSwitchControl: "select",
1622
+ levelSwitchPlacement: "above-button",
1623
+ } as const;
1624
+ const { placed } = render([pricingSection("a", { source: "offerings", variant: "addons", ...settings })]);
1625
+ expect(dataOf(placed, "a")).toMatchObject({ variant: "addons", ...settings });
1626
+ expect(keysOf(placed, "a")).toEqual(["seo"]);
1627
+ });
1628
+
1629
+ const LOOK = {
1630
+ featureDetails: [{ feature: "timeline", detail: "Six weeks", plan: "writing" }, { feature: "Support", detail: "Weekdays" }],
1631
+ featureRowStyle: "opens",
1632
+ loneCard: "column",
1633
+ wideSide: {
1634
+ media: "rotate",
1635
+ images: [{ src: "/a.png", alt: "A" }, { src: "/b.png", alt: "B" }],
1636
+ quote: { quote: "Q", author: "A" },
1637
+ },
1638
+ } as const;
1639
+
1640
+ it.each([
1641
+ ["a bound plans section", pricingSection("p", { source: "offerings", offeringPlans: ["writing"], ...LOOK })],
1642
+ ["a bound addons section", pricingSection("p", { source: "offerings", variant: "addons", ...LOOK })],
1643
+ ["the page's plans section", pricingSection("p", LOOK)],
1644
+ ])("AC-6 / AC-17 page: %s keeps featureDetails, featureRowStyle, loneCard and wideSide", (_label, section) => {
1645
+ const data = dataOf(render([section]).placed, "p");
1646
+ expect(data.featureDetails).toEqual(LOOK.featureDetails);
1647
+ expect(data.featureRowStyle).toBe("opens");
1648
+ expect(data.loneCard).toBe("column");
1649
+ expect(data.wideSide).toEqual(LOOK.wideSide);
1650
+ });
1651
+
1652
+ it("AC-14 page: a bound single-price-with-details section over a both-periods plan places billingToggle: true", () => {
1653
+ const { placed } = render([
1654
+ pricingSection("s", { source: "offerings", variant: "single-price-with-details", offeringPlans: ["writing"] }),
1655
+ ]);
1656
+ expect(dataOf(placed, "s")).toMatchObject({ variant: "single-price-with-details", billingToggle: true });
1657
+ expect(keysOf(placed, "s")).toEqual(["writing"]);
1658
+ });
1659
+ });
1660
+
1661
+ describe("an authored card's images never reach the page (#12241 D8, security)", () => {
1662
+ // Past every earlier suite's mocked clock (#12246's is 3 × 10 ** 12 ahead),
1663
+ // so no shared read of theirs is reused.
1664
+ let now = Date.now() + 4 * 10 ** 12;
1665
+ beforeEach(() => {
1666
+ now += 16_000;
1667
+ jest.spyOn(Date, "now").mockReturnValue(now);
1668
+ });
1669
+ afterEach(() => jest.restoreAllMocks());
1670
+ const answer = (data: unknown) => {
1671
+ fetchMock.mockImplementation(async () => ({
1672
+ ok: true,
1673
+ status: 200,
1674
+ json: async () => ({ ok: true, data }),
1675
+ }));
1676
+ };
1677
+ const images = [{ src: "https://evil.example/x.png", alt: "X" }];
1678
+ const plan = { key: "a", name: "A", price: { monthly: "$9" }, features: [], cta: { label: "Go", href: "/go" }, images };
1679
+
1680
+ it("AC-8 page: an authored images on a written card, its levels, its extra tier or a bound section's written card is stripped", async () => {
1681
+ answer({ status: "unconnected" });
1682
+ const section = pricingSection("w", {
1683
+ source: "written",
1684
+ plans: [{ ...plan, levels: [{ ...plan, label: "L1" }, { ...plan, label: "L2" }] }],
1685
+ extraTier: plan,
1686
+ });
1687
+ for (const options of [
1688
+ { plans: undefined, plan: undefined, locale: "en" },
1689
+ { plans: [] as string[], plan: undefined, locale: "en" },
1690
+ ]) {
1691
+ const [out] = await pricingSections([section], options);
1692
+ expect(JSON.stringify(out!.data)).not.toContain("evil.example");
1693
+ const data = out!.data as { plans: Array<Record<string, unknown> & { levels: Record<string, unknown>[] }> };
1694
+ expect(data.plans[0]).not.toHaveProperty("images");
1695
+ for (const level of data.plans[0]!.levels) expect(level).not.toHaveProperty("images");
1696
+ }
1697
+ answer({ status: "shown", shownSet: stripeSet() });
1698
+ const [placed] = await pricingSections([pricingSection("b", { source: "offerings", writtenPlans: [plan] })], {
1699
+ plans: undefined,
1700
+ plan: undefined,
1701
+ locale: "en",
1702
+ });
1703
+ const written = (placed!.data as { plans: Array<Record<string, unknown>> }).plans.find((c) => c.key === "a")!;
1704
+ expect(written).toBeDefined();
1705
+ expect(written).not.toHaveProperty("images");
1706
+ expect(JSON.stringify(placed!.data)).not.toContain("evil.example");
1707
+ });
1708
+ });