create-ailk 0.46.0 → 0.46.2

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.
@@ -3,7 +3,9 @@
3
3
  * lists, the card it lists each with, and `plans: []` reading no Stripe data.
4
4
  * #12103: plan groups (AC-2), the default Recommended's pill (AC-3) and the
5
5
  * authored card layout (AC-5), through the pure `offeringsFragments` and
6
- * `withOfferings`.
6
+ * `withOfferings`. #12140: bound (`source: offerings`) and written sections,
7
+ * the layout the page picks, the kept comparison grid, and the 0.74.0 page
8
+ * for a section with no `source`.
7
9
  */
8
10
  import {
9
11
  PageSectionsSchema,
@@ -15,6 +17,7 @@ import {
15
17
  } from "@working-theory/validation";
16
18
 
17
19
  import {
20
+ OFFERINGS_CHECKOUT_PATH,
18
21
  offeringsPricing,
19
22
  type OfferingsPricingLabels,
20
23
  } from "../offerings-pricing";
@@ -25,6 +28,7 @@ import {
25
28
  PRICING_HUB_SLUG,
26
29
  pricingPageCard,
27
30
  pricingSections,
31
+ withContactFallback,
28
32
  withOfferings,
29
33
  } from "../pricing-page";
30
34
  import type { DetailPage } from "@working-theory/site-pages/lib/route-family";
@@ -164,6 +168,7 @@ const LABELS: OfferingsPricingLabels = {
164
168
  oneTime: (amount) => "O⟪" + amount,
165
169
  withRequired: (plan, required) => "W⟪" + plan + "⟫" + required,
166
170
  depositNote: (deposit) => "D⟪" + deposit,
171
+ billedYearly: (amount) => "B⟪" + amount,
167
172
  };
168
173
  const RECOMMENDED_LABEL = "FOR-YOU⟪";
169
174
  const ADDONS_HEADLINE = "ADDONS⟪";
@@ -420,3 +425,500 @@ describe("the authored card layout survives (#12103 D6, AC-5)", () => {
420
425
  expect(dataOf(placed, "retainers").billingToggle).toBe(false);
421
426
  });
422
427
  });
428
+
429
+ // ─── #12140 — bound and written sections (spec 12140 D2, D6, D7) ────────────
430
+
431
+ const PLAN_VARIANTS = [
432
+ "three-tiers-with-toggle",
433
+ "with-comparison-table",
434
+ "two-tiers-with-extra-tier",
435
+ "single-price-with-details",
436
+ "features-and-plans",
437
+ "band-hero",
438
+ ] as const;
439
+
440
+ const ALL_KEYS = ["essentials", "growth", "writing"];
441
+
442
+ describe("a bound section renders the variant the page sets (#12140 AC-1)", () => {
443
+ it.each(PLAN_VARIANTS)("%s", (variant) => {
444
+ const { placed } = render([
445
+ HERO,
446
+ pricingSection("p", { source: "offerings", variant }),
447
+ ]);
448
+ expect(placed.map((s) => s.id)).toEqual(["hero", "p"]);
449
+ expect(dataOf(placed, "p").variant).toBe(variant);
450
+ expect(dataOf(placed, "p").source).toBe("offerings");
451
+ if (variant === "with-comparison-table")
452
+ expect(keysOf(placed, "p")).toEqual(ALL_KEYS);
453
+ if (variant === "single-price-with-details")
454
+ expect(keysOf(placed, "p")).toEqual(["essentials"]);
455
+ });
456
+
457
+ it("a bound section with no variant gets the toggle layout", () => {
458
+ const { placed } = render([pricingSection("p", { source: "offerings" })]);
459
+ expect(dataOf(placed, "p").variant).toBe("three-tiers-with-toggle");
460
+ expect(dataOf(placed, "p").billingToggle).toBe(true);
461
+ });
462
+
463
+ it("drops an authored extra tier and plan card, and keeps a band's key points", () => {
464
+ const keyPointsPanel = { items: [{ title: "Fast" }] };
465
+ const { placed } = render([
466
+ pricingSection("two", {
467
+ source: "offerings",
468
+ variant: "two-tiers-with-extra-tier",
469
+ extraTier: { name: "Big", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/elsewhere" } },
470
+ plans: [{ key: "own", name: "Own", price: { custom: "$1" }, features: [], cta: { label: "Go", href: "/elsewhere" } }],
471
+ }),
472
+ pricingSection("band", { source: "offerings", variant: "band-hero", keyPointsPanel }),
473
+ ]);
474
+ expect(dataOf(placed, "two")).not.toHaveProperty("extraTier");
475
+ expect(keysOf(placed, "two")).toEqual(ALL_KEYS);
476
+ expect(dataOf(placed, "band").keyPointsPanel).toEqual(keyPointsPanel);
477
+ });
478
+
479
+ it("an unbound section ignores its variant and renders as in 0.74.0", () => {
480
+ const { placed } = render([HERO, pricingSection("p", { variant: "features-and-plans" })]);
481
+ expect(dataOf(placed, "p").variant).toBe("three-tiers-with-toggle");
482
+ expect(dataOf(placed, "p").cardLayout).toBe("centered");
483
+ expect(keysOf(placed, "p")).toEqual(ALL_KEYS);
484
+ });
485
+
486
+ it("a bound add-ons section takes the tiles; a bound plans section beside it takes none", () => {
487
+ const { placed } = render([
488
+ pricingSection("a", { source: "offerings", variant: "addons" }),
489
+ pricingSection("c", { source: "offerings", variant: "with-comparison-table" }),
490
+ ]);
491
+ expect(placed.map((s) => s.id)).toEqual(["a", "c"]);
492
+ expect(dataOf(placed, "a").addons?.map((t) => t.name)).toEqual(["seo"]);
493
+ expect(dataOf(placed, "a").source).toBe("offerings");
494
+ expect(dataOf(placed, "c")).not.toHaveProperty("addons");
495
+ });
496
+ });
497
+
498
+ describe("a section with no source renders exactly as in 0.74.0 (#12140 AC-2)", () => {
499
+ const AUTHORED = {
500
+ headline: "Plans",
501
+ variant: "with-comparison-table",
502
+ comparisonGroups: [{ groupName: "Core", rows: [{ featureName: "Reports", values: { growth: true } }] }],
503
+ features: [{ title: "Row", description: "One" }],
504
+ extraTier: { name: "Big", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/contact" } },
505
+ };
506
+ const TODAY_KEYS = ["billingToggle", "cardLayout", "headline", "plans", "recommendedLabel", "variant"];
507
+
508
+ it("an unbound plans slot keeps only today's fields", () => {
509
+ const { placed } = render([pricingSection("p", AUTHORED)]);
510
+ expect(Object.keys(dataOf(placed, "p")).sort()).toEqual(TODAY_KEYS);
511
+ expect(dataOf(placed, "p").variant).toBe("three-tiers-with-toggle");
512
+ });
513
+
514
+ it("an unbound plan group keeps only today's fields", () => {
515
+ const { placed } = render([pricingSection("g", { ...AUTHORED, offeringPlans: ["writing"] })]);
516
+ expect(Object.keys(dataOf(placed, "g")).sort()).toEqual(TODAY_KEYS);
517
+ });
518
+
519
+ it("still inserts the plans and add-ons after a leading hero on a page with no pricing section", () => {
520
+ const { placed } = render([HERO]);
521
+ expect(placed.map((s) => s.id)).toEqual(["hero", "offerings-plans", "offerings-addons"]);
522
+ });
523
+ });
524
+
525
+ describe("features-and-plans on one product with two Prices (#12140 AC-3)", () => {
526
+ const WRITING = stripeProduct(
527
+ "writing",
528
+ "plan",
529
+ [stripePrice("writing", "monthly", 3000), stripePrice("writing", "yearly", 30000)],
530
+ { marketingFeatures: ["Edits", "Briefs"] },
531
+ );
532
+ const set = workspaceShownSetSchema.parse({
533
+ ...stripeSet(),
534
+ offerings: [WRITING],
535
+ productIds: ["prod_writing"],
536
+ recommended: { plan: null, addon: null },
537
+ });
538
+
539
+ it("renders a monthly and a yearly block, each with its own checkout, beside the product's features", () => {
540
+ const { placed } = render(
541
+ [HERO, pricingSection("w", { source: "offerings", variant: "features-and-plans", offeringPlans: ["writing"] })],
542
+ { set },
543
+ );
544
+ expect(keysOf(placed, "w")).toEqual(["writing", "writing_yearly"]);
545
+ const hrefs = dataOf(placed, "w").plans.map((c) => c.cta.href);
546
+ expect(hrefs[0]!.endsWith("writing_monthly")).toBe(true);
547
+ expect(hrefs[1]!.endsWith("writing_yearly")).toBe(true);
548
+ expect(dataOf(placed, "w").features).toEqual([{ title: "Edits" }, { title: "Briefs" }]);
549
+ });
550
+
551
+ it("keeps an authored features list over the product's", () => {
552
+ const own = [{ title: "Own", description: "Mine" }];
553
+ const { placed } = render(
554
+ [pricingSection("w", { source: "offerings", variant: "features-and-plans", offeringPlans: ["writing"], features: own })],
555
+ { set },
556
+ );
557
+ expect(dataOf(placed, "w").features).toEqual(own);
558
+ });
559
+ });
560
+
561
+ describe("comparisonGroups survive the swap, matched by plan slug (#12140 AC-4)", () => {
562
+ const NAMED = workspaceShownSetSchema.parse({
563
+ ...stripeSet(),
564
+ offerings: stripeSet().offerings.map((o) => ({
565
+ ...o,
566
+ name: o.plan.charAt(0).toUpperCase() + o.plan.slice(1),
567
+ })),
568
+ });
569
+ const G = [
570
+ { groupName: "Core", rows: [{ featureName: "Reports", values: { essentials: true, growth: "Weekly", absent: true } }] },
571
+ ];
572
+ const section = (groups: unknown) =>
573
+ pricingSection("c", {
574
+ source: "offerings",
575
+ variant: "with-comparison-table",
576
+ offeringPlans: ["essentials", "growth"],
577
+ comparisonGroups: groups,
578
+ });
579
+
580
+ it("keeps the grid and keys the cards by slug, not by name", () => {
581
+ const { placed } = render([HERO, section(G)], { set: NAMED });
582
+ expect(dataOf(placed, "c").comparisonGroups).toEqual(G);
583
+ expect(keysOf(placed, "c")).toEqual(["essentials", "growth"]);
584
+ expect(dataOf(placed, "c").plans.map((c) => c.name)).toEqual(["Essentials", "Growth"]);
585
+ });
586
+
587
+ it("drops a cell's authored link and keeps every other value", () => {
588
+ const linked = [
589
+ {
590
+ groupName: "Core",
591
+ rows: [
592
+ {
593
+ featureName: "Reports",
594
+ values: {
595
+ essentials: true,
596
+ growth: { text: "Weekly", verdict: "yes", link: { label: "See", href: "https://example.com" } },
597
+ absent: true,
598
+ },
599
+ },
600
+ ],
601
+ },
602
+ ];
603
+ const { placed } = render([section(linked)], { set: NAMED });
604
+ expect(dataOf(placed, "c").comparisonGroups).toEqual([
605
+ { groupName: "Core", rows: [{ featureName: "Reports", values: { essentials: true, growth: { text: "Weekly", verdict: "yes" }, absent: true } }] },
606
+ ]);
607
+ });
608
+ });
609
+
610
+ describe("no vendor, and every price link on a non-written section is a checkout key (#12140 AC-5, NFR-2)", () => {
611
+ it("holds over a page of every bound variant, a bound add-ons section and an unbound section", () => {
612
+ const linkedGrid = [
613
+ { groupName: "Core", rows: [{ featureName: "R", values: { growth: { text: "W", link: { label: "See", href: "/elsewhere" } } } }] },
614
+ ];
615
+ const authored = {
616
+ plans: [{ key: "own", name: "Own", price: { custom: "$1" }, features: [], cta: { label: "Go", href: "/elsewhere" } }],
617
+ extraTier: { name: "Big", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/elsewhere" } },
618
+ comparisonGroups: linkedGrid,
619
+ };
620
+ const { placed } = render([
621
+ HERO,
622
+ ...PLAN_VARIANTS.map((variant) => pricingSection(`b-${variant}`, { source: "offerings", variant, ...authored })),
623
+ pricingSection("a", { source: "offerings", variant: "addons" }),
624
+ pricingSection("u", authored),
625
+ ]);
626
+ const priced = placed.filter((s): s is Pricing => s.type === "pricing");
627
+ expect(priced.map((s) => s.id)).toEqual([...PLAN_VARIANTS.map((v) => `b-${v}`), "a", "u"]);
628
+ const ours = (href: string | undefined) =>
629
+ href === undefined || href.startsWith(OFFERINGS_CHECKOUT_PATH);
630
+ for (const { data } of priced) {
631
+ expect(JSON.stringify(data)).not.toMatch(/stripe/i);
632
+ expect(data).not.toHaveProperty("extraTier");
633
+ for (const card of data.plans) {
634
+ expect(ours(card.cta.href)).toBe(true);
635
+ expect(ours(card.annualCtaHref)).toBe(true);
636
+ }
637
+ for (const tile of data.addons ?? []) expect(ours(tile.cta?.href)).toBe(true);
638
+ for (const group of data.comparisonGroups ?? [])
639
+ for (const row of group.rows)
640
+ for (const value of Object.values(row.values))
641
+ if (typeof value === "object") expect(value).not.toHaveProperty("link");
642
+ }
643
+ });
644
+ });
645
+
646
+ describe("a written section (#12140 AC-6)", () => {
647
+ const W = pricingSection("w", {
648
+ source: "written",
649
+ plans: [{ key: "custom", name: "Custom", price: { custom: "Ask" }, features: [], cta: { label: "Talk", href: "/contact" } }],
650
+ });
651
+ const RECOMMENDED = RECOMMENDED_LABEL;
652
+
653
+ it("stays as written beside the Offerings cards, and never becomes the plans slot", () => {
654
+ const { placed } = render([HERO, W, pricingSection("p"), EXTRAS]);
655
+ expect(placed.map((s) => s.id)).toEqual(["hero", "w", "p", "extras"]);
656
+ expect(dataOf(placed, "w")).toEqual(W.data);
657
+ expect(keysOf(placed, "p")).toEqual(ALL_KEYS);
658
+ });
659
+
660
+ it("takes a {plan}-grammar ?plan= only", () => {
661
+ expect(dataOf(render([W, pricingSection("p")], { plan: "custom" }).placed, "w")).toEqual({
662
+ ...W.data,
663
+ recommended: "custom",
664
+ recommendedLabel: RECOMMENDED,
665
+ });
666
+ expect(dataOf(render([W, pricingSection("p")], { plan: "Custom" }).placed, "w")).toEqual(W.data);
667
+ });
668
+
669
+ const W2 = pricingSection("w", {
670
+ source: "written",
671
+ plans: [
672
+ ...W.data.plans,
673
+ { key: "sneak", name: "Sneak", price: { custom: "$1" }, features: [], cta: { label: "Buy", href: "/api/offerings/checkout/writing_monthly" } },
674
+ { key: "annual", name: "Annual", price: { custom: "$2" }, features: [], cta: { label: "Buy", href: "/x" }, annualCtaHref: "/api/offerings/checkout/writing_yearly" },
675
+ { key: "absolute", name: "Absolute", price: { custom: "$3" }, features: [], cta: { label: "Buy", href: "https://example.com/api/offerings/checkout/growth_monthly" } },
676
+ ],
677
+ extraTier: { name: "Big", price: { custom: "$9" }, features: [], cta: { label: "Buy", href: "/api/offerings/checkout/growth_monthly" } },
678
+ });
679
+
680
+ it("drops every card and extra tier that links the Offerings checkout", () => {
681
+ const { placed } = render([W2, pricingSection("p")]);
682
+ expect(keysOf(placed, "w")).toEqual(["custom"]);
683
+ expect(dataOf(placed, "w")).not.toHaveProperty("extraTier");
684
+ });
685
+
686
+ it("drops a percent-encoded link to the Offerings checkout too", () => {
687
+ const encoded = (key: string, href: string) => ({
688
+ key,
689
+ name: key,
690
+ price: { custom: "$1" },
691
+ features: [],
692
+ cta: { label: "Buy", href },
693
+ });
694
+ const W3 = pricingSection("w", {
695
+ source: "written",
696
+ plans: [
697
+ ...W.data.plans,
698
+ encoded("letter", "/api/%6Ffferings/checkout/writing_monthly"),
699
+ encoded("slash", "/api%2Fofferings%2Fcheckout/writing_monthly"),
700
+ encoded("upper", "/API/%4FFFERINGS/Checkout/writing_monthly"),
701
+ encoded("malformed", "/api/offerings/%E0%A4%A"),
702
+ ],
703
+ });
704
+ expect(keysOf(render([W3, pricingSection("p")]).placed, "w")).toEqual(["custom", "malformed"]);
705
+ });
706
+
707
+ it("drops a written add-on tile and a cell link that reach the Offerings checkout", () => {
708
+ const tile = (name: string, href: string) => ({ name, price: "$1", cta: { label: "Add", href } });
709
+ const W4 = pricingSection("w", {
710
+ source: "written",
711
+ addons: [tile("Kept", "/contact"), tile("Sold", "/api/offerings/checkout/rush_once")],
712
+ comparisonGroups: [
713
+ {
714
+ groupName: "G",
715
+ rows: [
716
+ {
717
+ featureName: "Row",
718
+ values: {
719
+ custom: { text: "Yes", link: { label: "Buy", href: "/api/offerings/checkout/writing_monthly" } },
720
+ other: { text: "Ask", link: { label: "Ask", href: "/contact" } },
721
+ },
722
+ },
723
+ ],
724
+ },
725
+ ],
726
+ });
727
+ const data = dataOf(render([W4, pricingSection("p")]).placed, "w");
728
+ expect(data.addons?.map((a) => a.name)).toEqual(["Kept"]);
729
+ const values = data.comparisonGroups?.[0]?.rows[0]?.values ?? {};
730
+ expect(values["custom"]).toEqual({ text: "Yes" });
731
+ expect(values["other"]).toEqual({ text: "Ask", link: { label: "Ask", href: "/contact" } });
732
+ });
733
+
734
+ it("drops them through pricingSections for page plans: [] too", async () => {
735
+ const sections = await pricingSections([W2], { plans: [], plan: undefined, locale: "en" });
736
+ expect(fetchMock).not.toHaveBeenCalled();
737
+ expect(keysOf(sections, "w")).toEqual(["custom"]);
738
+ expect(dataOf(sections, "w")).not.toHaveProperty("extraTier");
739
+ });
740
+
741
+ it("gives way to the contact email with every other pricing section", () => {
742
+ expect(withContactFallback([HERO, W, pricingSection("p"), EXTRAS]).map((s) => s.id)).toEqual([
743
+ "hero",
744
+ "offerings-contact",
745
+ ]);
746
+ });
747
+
748
+ describe("through pricingSections", () => {
749
+ let now = Date.now();
750
+ beforeEach(() => {
751
+ now += 16_000;
752
+ jest.spyOn(Date, "now").mockReturnValue(now);
753
+ });
754
+ afterEach(() => jest.restoreAllMocks());
755
+
756
+ const answer = (data: unknown) =>
757
+ fetchMock.mockImplementation(async () => ({
758
+ ok: true,
759
+ status: 200,
760
+ json: async () => ({ ok: true, data }),
761
+ }));
762
+
763
+ it("takes the contact path when the only pricing left would be written", async () => {
764
+ answer({ status: "shown", shownSet: stripeSet() });
765
+ const sections = await pricingSections([HERO, W, pricingSection("p")], {
766
+ plans: ["absent"],
767
+ plan: undefined,
768
+ locale: "en",
769
+ });
770
+ expect(sections.map((s) => s.id)).toEqual(["hero", "offerings-contact"]);
771
+ });
772
+
773
+ it("takes the contact path on an empty shown set", async () => {
774
+ answer({ status: "empty" });
775
+ const sections = await pricingSections([HERO, W, pricingSection("p")], {
776
+ plans: undefined,
777
+ plan: undefined,
778
+ locale: "en",
779
+ });
780
+ expect(sections.map((s) => s.id)).toEqual(["hero", "offerings-contact"]);
781
+ });
782
+
783
+ it("reads no Offerings for a page whose every pricing section is written", async () => {
784
+ answer({ status: "shown", shownSet: stripeSet() });
785
+ const sections = await pricingSections([HERO, W], { plans: undefined, plan: undefined, locale: "en" });
786
+ expect(sections.map((s) => s.id)).toEqual(["hero", "w"]);
787
+ expect(sections[1]).toEqual(W);
788
+ expect(fetchMock).not.toHaveBeenCalled();
789
+ });
790
+
791
+ it("reads once when an unbound section sits beside it", async () => {
792
+ answer({ status: "shown", shownSet: stripeSet() });
793
+ const sections = await pricingSections([HERO, W, pricingSection("p")], {
794
+ plans: undefined,
795
+ plan: undefined,
796
+ locale: "en",
797
+ });
798
+ expect(fetchMock).toHaveBeenCalledTimes(1);
799
+ expect(sections.map((s) => s.id)).toEqual(["hero", "w", "p"]);
800
+ });
801
+ });
802
+ });
803
+
804
+ describe("the plan bar options survive the Stripe path (#12141 D9, AC-1)", () => {
805
+ const REC_GRID = { pickerLabel: "Plan", pinnedGroups: true, groupsOpen: "first" };
806
+
807
+ it.each([
808
+ ["an unbound plans slot", {}],
809
+ ["a bound section", { source: "offerings", variant: "with-comparison-table" }],
810
+ ])("%s keeps planBar and comparisonPlanBar over the Offerings cards, deep-equal", (_label, extra) => {
811
+ const { placed } = render([
812
+ pricingSection("p", { ...extra, planBar: {}, comparisonPlanBar: REC_GRID }),
813
+ ]);
814
+ expect(dataOf(placed, "p").planBar).toEqual({});
815
+ expect(dataOf(placed, "p").comparisonPlanBar).toEqual(REC_GRID);
816
+ });
817
+ });
818
+
819
+ // ─── #12174 — level cards and written cards on a bound section ──────────────
820
+
821
+ describe("a bound section's offeringGroups and writtenPlans (#12174 AC-5, AC-7)", () => {
822
+ const ENTERPRISE = {
823
+ key: "enterprise",
824
+ name: "Enterprise",
825
+ price: { custom: "Book a call" },
826
+ features: ["Everything in Team"],
827
+ cta: { label: "Book a call", href: "/meet" },
828
+ };
829
+ const level = (label: string, plan: string) => ({ label, plan });
830
+ const GROUPS = [
831
+ { key: "individual", name: "Individual", levels: [level("Lite", "essentials"), level("Full", "writing")] },
832
+ { key: "team", name: "Team", levels: [level("Lite", "growth"), level("Full", "team-pro")] },
833
+ ];
834
+ /** `stripeSet()` plus one more plan product, `team-pro` (monthly 5000). */
835
+ const withTeamPro = (base: WorkspaceShownSet = stripeSet()) => {
836
+ const offerings = [...base.offerings, stripeProduct("team-pro", "plan", [stripePrice("team-pro", "monthly", 5000)])];
837
+ return workspaceShownSetSchema.parse({ ...base, offerings, productIds: offerings.map((o) => o.productId) });
838
+ };
839
+ const bound = (extra: Record<string, unknown> = {}) =>
840
+ pricingSection("p", { source: "offerings", offeringGroups: GROUPS, writtenPlans: [ENTERPRISE], ...extra });
841
+
842
+ it("groups the plans into one card per group, and leaves them out of the unbound slot (AC-5)", () => {
843
+ const { placed } = render([
844
+ HERO,
845
+ pricingSection("p", { source: "offerings", offeringGroups: [{ key: "team", name: "Team", levels: [level("Lite", "essentials"), level("Full", "writing")] }] }),
846
+ pricingSection("rest"),
847
+ ]);
848
+ expect(keysOf(placed, "p")).toEqual(["team"]);
849
+ expect(dataOf(placed, "p").plans[0]!.levels!.map((l) => l.key)).toEqual(["essentials", "writing"]);
850
+ expect(dataOf(placed, "p").billingToggle).toBe(true);
851
+ expect(keysOf(placed, "rest")).toEqual(["growth"]);
852
+ });
853
+
854
+ it("places the written card after the Offerings cards, in one grid: three columns (AC-7)", () => {
855
+ const { placed } = render([HERO, bound()], { set: withTeamPro() });
856
+ expect(keysOf(placed, "p")).toEqual(["individual", "team", "enterprise"]);
857
+ expect(dataOf(placed, "p").plans[2]).toEqual(ENTERPRISE);
858
+ expect(dataOf(placed, "p")).not.toHaveProperty("offeringGroups");
859
+ expect(dataOf(placed, "p")).not.toHaveProperty("writtenPlans");
860
+ });
861
+
862
+ it.each(["single-price-with-details", "two-tiers-with-extra-tier"])(
863
+ "appends no written card where %s hides cards",
864
+ (variant) => {
865
+ const { placed } = render([bound({ variant })], { set: withTeamPro() });
866
+ expect(keysOf(placed, "p")).not.toContain("enterprise");
867
+ },
868
+ );
869
+
870
+ it("drops a written card that links the Offerings checkout", () => {
871
+ const sneak = { ...ENTERPRISE, key: "sneak", cta: { label: "Buy", href: "/api/offerings/checkout/essentials_monthly" } };
872
+ const { placed } = render([bound({ writtenPlans: [ENTERPRISE, sneak] })], { set: withTeamPro() });
873
+ expect(keysOf(placed, "p")).toEqual(["individual", "team", "enterprise"]);
874
+ });
875
+
876
+ it("drops a written section's level card that links the checkout through any level", () => {
877
+ const levelled = {
878
+ ...ENTERPRISE,
879
+ key: "levelled",
880
+ levels: [
881
+ { label: "A", price: { custom: "$1" }, features: [], cta: { label: "Go", href: "/a" } },
882
+ { label: "B", price: { custom: "$2" }, features: [], cta: { label: "Go", href: "/b" }, annualCtaHref: "/API/offerings/checkout/x_yearly" },
883
+ ],
884
+ };
885
+ const written = pricingSection("w", { source: "written", plans: [ENTERPRISE, levelled] });
886
+ const { placed } = render([written, pricingSection("p")]);
887
+ expect(keysOf(placed, "w")).toEqual(["enterprise"]);
888
+ });
889
+
890
+ it("keeps the written cards when no group yields a card (decision 6)", () => {
891
+ const base = stripeSet();
892
+ const set = workspaceShownSetSchema.parse({
893
+ ...base,
894
+ offerings: base.offerings.filter((o) => o.plan === "seo"),
895
+ productIds: ["prod_seo"],
896
+ });
897
+ const { placed } = render([HERO, bound()], { set });
898
+ expect(keysOf(placed, "p")).toEqual(["enterprise"]);
899
+ expect(dataOf(placed, "p").plans[0]).toEqual(ENTERPRISE);
900
+ });
901
+
902
+ it("?plan= naming a level's plan highlights the card that sells it (decision 9)", () => {
903
+ const { placed } = render([bound()], { set: withTeamPro(), plan: "writing" });
904
+ expect(dataOf(placed, "p").recommended).toBe("individual");
905
+ });
906
+
907
+ it("an unconnected page renders the bound section's authored plans, no written card", async () => {
908
+ jest.spyOn(Date, "now").mockReturnValue(Date.now() + 10_000_000);
909
+ fetchMock.mockImplementation(async () => ({
910
+ ok: true,
911
+ status: 200,
912
+ json: async () => ({ ok: true, data: { status: "unconnected" } }),
913
+ }));
914
+ const fallback = { ...ENTERPRISE, key: "fallback" };
915
+ const sections = await pricingSections([bound({ plans: [fallback] })], {
916
+ plans: undefined,
917
+ plan: undefined,
918
+ locale: "en",
919
+ });
920
+ jest.restoreAllMocks();
921
+ const p = sections.find((s) => s.id === "p");
922
+ expect(p?.type === "pricing" && p.data.plans.map((c) => c.key)).toEqual(["fallback"]);
923
+ });
924
+ });