create-ailk 0.46.0 → 0.46.1

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.
@@ -37,6 +37,7 @@ const LABELS: OfferingsPricingLabels = {
37
37
  oneTime: (amount) => "O⟪" + amount,
38
38
  withRequired: (plan, required) => "W⟪" + plan + "⟫" + required,
39
39
  depositNote: (deposit) => "D⟪" + deposit,
40
+ billedYearly: (amount) => "B⟪" + amount,
40
41
  };
41
42
 
42
43
  const OPTIONS = { locale: "en-US", labels: LABELS };
@@ -278,7 +279,8 @@ describe("offeringsPricing — one card per Product (AC-1)", () => {
278
279
  describe("offeringsPricing — periods, the switch and the fields (AC-2)", () => {
279
280
  it("maps yearly to annual and lands unit, note and terms note in their fields", () => {
280
281
  const growth = card(mapped(), "growth");
281
- expect(growth.price).toEqual({ monthly: "M⟪$49", annual: "Y⟪$490" });
282
+ // #12139 D1: annual mode shows the yearly Price per month.
283
+ expect(growth.price).toEqual({ monthly: "M⟪$49", annual: "M⟪$40.83" });
282
284
  expect(growth.priceUnit).toBe("per seat");
283
285
  expect(growth.priceSubhead).toBe("Billed per active seat");
284
286
  expect(growth.priceFootnote).toBe("Cancel any time from your account");
@@ -701,6 +703,7 @@ describe("offeringsPricing — no copy of its own (AC-7)", () => {
701
703
  ),
702
704
  );
703
705
  if (plan.highlightLabel) visible.push(plan.highlightLabel);
706
+ if (plan.annualPriceNote) visible.push(plan.annualPriceNote);
704
707
  }
705
708
  for (const t of addonsOf(result)) {
706
709
  visible.push(t.cta!.label, t.price);
@@ -927,3 +930,271 @@ describe("offeringsPricing — exclude (#12103 D2)", () => {
927
930
  expect(addonsOf(result).map((t) => t.key)).toEqual(["seo-audit", "audit-pack"]);
928
931
  });
929
932
  });
933
+
934
+ describe("offeringsPricing — the annual price per month (#12139 D1, AC-2)", () => {
935
+ /** A shown set of the spec's plan fixtures, in this order. */
936
+ function perMonthSet(edit: (set: WorkspaceShownSet) => void = () => {}) {
937
+ return shownSet((set) => {
938
+ set.offerings = [
939
+ product(
940
+ "annual-plan",
941
+ "plan",
942
+ [
943
+ price("annual-plan", "monthly", 9900, "usd"),
944
+ price("annual-plan", "yearly", 96000, "usd"),
945
+ ],
946
+ { termsNote: "Cancel any time" },
947
+ ),
948
+ product("monthly-plan", "plan", [price("monthly-plan", "monthly", 4900, "usd")], { termsNote: "Terms" }),
949
+ product("yearly-plan", "plan", [price("yearly-plan", "yearly", 96000, "usd")]),
950
+ product("once-plan", "plan", [price("once-plan", "once", 150000, "usd")]),
951
+ product("odd-plan", "plan", [price("odd-plan", "monthly", 4900, "usd"), price("odd-plan", "yearly", 49000, "usd")]),
952
+ product("yen-plan", "plan", [price("yen-plan", "monthly", 1000, "jpy"), price("yen-plan", "yearly", 10000, "jpy")]),
953
+ product("round-up-plan", "plan", [price("round-up-plan", "monthly", 4900, "usd"), price("round-up-plan", "yearly", 59900, "usd")]),
954
+ product("whole-plan", "plan", [price("whole-plan", "monthly", 900, "usd"), price("whole-plan", "yearly", 12001, "usd")]),
955
+ ];
956
+ set.productIds = set.offerings.map((o) => o.productId);
957
+ set.recommended = { plan: null, addon: null };
958
+ edit(set);
959
+ });
960
+ }
961
+
962
+ it("phrases the yearly Price per month, with the yearly total in the note, and keeps the yearly link", () => {
963
+ const annual = card(mapped(perMonthSet()), "annual-plan");
964
+ expect(annual.price).toEqual({ monthly: "M⟪$99", annual: "M⟪$80" });
965
+ expect(annual.annualPriceNote).toBe("B⟪$960");
966
+ expect(annual.annualCtaHref).toBe("/api/offerings/checkout/annual-plan_yearly");
967
+ });
968
+
969
+ it("rounds the per-month amount to the nearest minor unit", () => {
970
+ const result = mapped(perMonthSet());
971
+ expect(card(result, "odd-plan").price.annual).toBe("M⟪$40.83");
972
+ expect(card(result, "round-up-plan").price.annual).toBe("M⟪$49.92");
973
+ expect(card(result, "whole-plan").price.annual).toBe("M⟪$10");
974
+ expect(card(result, "yen-plan").price.annual).toBe("M⟪¥833");
975
+ expect(card(result, "yen-plan").annualPriceNote).toBe("B⟪¥10,000");
976
+ });
977
+
978
+ it("leaves monthly-only, yearly-only and one-time plans as they were, with no note", () => {
979
+ const result = mapped(perMonthSet());
980
+ expect(card(result, "monthly-plan").price).toEqual({ monthly: "M⟪$49" });
981
+ expect(card(result, "yearly-plan").price).toEqual({ annual: "Y⟪$960" });
982
+ expect(card(result, "once-plan").price).toEqual({ custom: "O⟪$1,500" });
983
+ for (const key of ["monthly-plan", "yearly-plan", "once-plan"])
984
+ expect(card(result, key)).not.toHaveProperty("annualPriceNote");
985
+ });
986
+
987
+ it("keeps a bundle card's annual phrase", () => {
988
+ const set = shownSet((s) => {
989
+ s.offerings = [
990
+ product("rebuild", "plan", [price("rebuild", "once", 2500000, "usd")], { requires: "managed" }),
991
+ product("managed", "plan", [price("managed", "monthly", 300000, "usd"), price("managed", "yearly", 3000000, "usd")]),
992
+ ];
993
+ s.productIds = ["prod_rebuild", "prod_managed"];
994
+ s.recommended = { plan: null, addon: null };
995
+ });
996
+ const rebuild = card(mapped(set), "rebuild");
997
+ expect(rebuild.price.annual).toBe("W⟪O⟪$25,000⟫Y⟪$30,000");
998
+ expect(rebuild).not.toHaveProperty("annualPriceNote");
999
+ });
1000
+ });
1001
+
1002
+ describe("offeringsPricing — the terms note of a both-prices card is annual-only (#12139 D2, AC-3)", () => {
1003
+ it("flags the terms note on a plan with monthly and yearly Prices, and on no other plan", () => {
1004
+ const set = shownSet((s) => {
1005
+ s.offerings = [
1006
+ product(
1007
+ "annual-plan",
1008
+ "plan",
1009
+ [
1010
+ price("annual-plan", "monthly", 9900, "usd"),
1011
+ price("annual-plan", "yearly", 96000, "usd"),
1012
+ ],
1013
+ { termsNote: "Cancel any time" },
1014
+ ),
1015
+ product("monthly-plan", "plan", [price("monthly-plan", "monthly", 4900, "usd")], { termsNote: "Terms" }),
1016
+ ];
1017
+ s.productIds = s.offerings.map((o) => o.productId);
1018
+ s.recommended = { plan: null, addon: null };
1019
+ });
1020
+ const result = mapped(set);
1021
+ expect(card(result, "annual-plan").priceFootnote).toBe("Cancel any time");
1022
+ expect(card(result, "annual-plan").priceFootnoteAnnualOnly).toBe(true);
1023
+ expect(card(result, "monthly-plan").priceFootnote).toBe("Terms");
1024
+ expect(card(result, "monthly-plan")).not.toHaveProperty("priceFootnoteAnnualOnly");
1025
+ });
1026
+
1027
+ it("flags a bundle's terms note when its required product has both Prices", () => {
1028
+ const set = shownSet((s) => {
1029
+ s.offerings = [
1030
+ product("rebuild", "plan", [price("rebuild", "once", 2500000, "usd")], { requires: "managed", termsNote: "Cancel any time" }),
1031
+ product("managed", "plan", [price("managed", "monthly", 300000, "usd"), price("managed", "yearly", 3000000, "usd")]),
1032
+ ];
1033
+ s.productIds = ["prod_rebuild", "prod_managed"];
1034
+ s.recommended = { plan: null, addon: null };
1035
+ });
1036
+ const rebuild = card(mapped(set), "rebuild");
1037
+ expect(rebuild.priceFootnote).toBe("Cancel any time");
1038
+ expect(rebuild.priceFootnoteAnnualOnly).toBe(true);
1039
+ });
1040
+
1041
+ it("never flags a deposit note", () => {
1042
+ const plan = shownSet((s) => {
1043
+ const basic = offering(s, "basic");
1044
+ basic.prices = basic.prices.filter((p) => p.period === "once");
1045
+ basic.deposit = 50000;
1046
+ basic.termsNote = "Terms";
1047
+ });
1048
+ expect(card(mapped(plan), "basic").priceFootnote).toBe("D⟪$500");
1049
+ expect(card(mapped(plan), "basic")).not.toHaveProperty("priceFootnoteAnnualOnly");
1050
+
1051
+ const bundle = shownSet((s) => {
1052
+ s.offerings = [
1053
+ product("rebuild", "plan", [price("rebuild", "once", 2500000, "jpy")], { requires: "managed", deposit: 500000, termsNote: "Terms" }),
1054
+ product("managed", "plan", [price("managed", "monthly", 300000, "jpy"), price("managed", "yearly", 3000000, "jpy")]),
1055
+ ];
1056
+ s.productIds = ["prod_rebuild", "prod_managed"];
1057
+ s.recommended = { plan: null, addon: null };
1058
+ });
1059
+ const rebuild = card(mapped(bundle), "rebuild");
1060
+ expect(rebuild.priceFootnote).toBe("D⟪¥500,000");
1061
+ expect(rebuild).not.toHaveProperty("priceFootnoteAnnualOnly");
1062
+ });
1063
+ });
1064
+
1065
+ // ─── #12140 — the page picks the layout (spec 12140 D3, D4) ────────────────
1066
+
1067
+ const LAYOUTS = [
1068
+ "three-tiers-with-toggle",
1069
+ "with-comparison-table",
1070
+ "two-tiers-with-extra-tier",
1071
+ "single-price-with-details",
1072
+ "features-and-plans",
1073
+ "band-hero",
1074
+ ] as const;
1075
+
1076
+ describe("offeringsPricing — one mapping per layout (#12140 D3, AC-1)", () => {
1077
+ it("maps exactly as today without a layout, and the same with three-tiers-with-toggle", () => {
1078
+ expect(offeringsPricing(shownSet(), OPTIONS)).toEqual(
1079
+ offeringsPricing(shownSet(), { ...OPTIONS, layout: "three-tiers-with-toggle" }),
1080
+ );
1081
+ });
1082
+
1083
+ it.each(["with-comparison-table", "two-tiers-with-extra-tier", "band-hero"] as const)(
1084
+ "%s: centred cards, no billing toggle",
1085
+ (layout) => {
1086
+ const result = offeringsPricing(shownSet(), { ...OPTIONS, layout })!;
1087
+ expect(result.plans).toStrictEqual({
1088
+ variant: layout,
1089
+ cardLayout: "centered",
1090
+ plans: plansOf(mapped()),
1091
+ });
1092
+ },
1093
+ );
1094
+
1095
+ it("single-price-with-details: the first card only, no card layout and no toggle", () => {
1096
+ const result = offeringsPricing(shownSet(), { ...OPTIONS, layout: "single-price-with-details" })!;
1097
+ expect(result.plans).toStrictEqual({
1098
+ variant: "single-price-with-details",
1099
+ plans: [plansOf(mapped())[0]],
1100
+ });
1101
+ expect(result.plans!.plans[0]!.key).toBe("starter");
1102
+ });
1103
+
1104
+ it("leaves the add-ons fragment as it is for every layout", () => {
1105
+ for (const layout of LAYOUTS) {
1106
+ expect(offeringsPricing(shownSet(), { ...OPTIONS, layout })!.addons).toEqual(mapped().addons);
1107
+ }
1108
+ });
1109
+ });
1110
+
1111
+ describe("offeringsPricing — features-and-plans splits one product into two blocks (#12140 D4, AC-3)", () => {
1112
+ const FEATURES_AND_PLANS = { ...OPTIONS, layout: "features-and-plans" } as const;
1113
+
1114
+ it("one product with monthly and yearly Prices → a monthly block and a yearly block beside its features", () => {
1115
+ expect(
1116
+ offeringsPricing(shownSet(), { ...FEATURES_AND_PLANS, plans: ["growth"] })!.plans,
1117
+ ).toStrictEqual({
1118
+ variant: "features-and-plans",
1119
+ features: [{ title: "Ten sites" }, { title: "Priority support" }],
1120
+ plans: [
1121
+ {
1122
+ key: "growth",
1123
+ name: "Growth",
1124
+ description: "For teams that ship weekly",
1125
+ price: { monthly: "M⟪$49" },
1126
+ features: ["Ten sites", "Priority support"],
1127
+ cta: { label: "CTA⟪", href: hrefFor("growth_monthly") },
1128
+ priceUnit: "per seat",
1129
+ priceSubhead: "Billed per active seat",
1130
+ highlighted: true,
1131
+ highlightStyle: "pill",
1132
+ highlightLabel: "REC⟪",
1133
+ },
1134
+ {
1135
+ key: "growth_yearly",
1136
+ name: "Growth",
1137
+ price: { annual: "Y⟪$490" },
1138
+ features: ["Ten sites", "Priority support"],
1139
+ cta: { label: "CTA⟪", href: hrefFor("growth_yearly") },
1140
+ priceUnit: "per seat",
1141
+ priceSubhead: "Billed per active seat",
1142
+ priceFootnote: "Cancel any time from your account",
1143
+ },
1144
+ ],
1145
+ });
1146
+ });
1147
+
1148
+ it("a product with one Price is one card as built, with its features", () => {
1149
+ const only = { ...OPTIONS, plans: ["starter"] };
1150
+ expect(
1151
+ offeringsPricing(shownSet(), { ...FEATURES_AND_PLANS, plans: ["starter"] })!.plans,
1152
+ ).toStrictEqual({
1153
+ variant: "features-and-plans",
1154
+ features: [{ title: "One site" }, { title: "Email support" }],
1155
+ plans: plansOf(offeringsPricing(shownSet(), only)!),
1156
+ });
1157
+ });
1158
+
1159
+ it("two products are the cards as built, with no features key", () => {
1160
+ const both = { ...OPTIONS, plans: ["growth", "basic"] };
1161
+ expect(
1162
+ offeringsPricing(shownSet(), { ...FEATURES_AND_PLANS, plans: ["growth", "basic"] })!.plans,
1163
+ ).toStrictEqual({
1164
+ variant: "features-and-plans",
1165
+ plans: plansOf(offeringsPricing(shownSet(), both)!),
1166
+ });
1167
+ });
1168
+
1169
+ it("a bundle is never split, though its built card carries both prices", () => {
1170
+ const set = shownSet((s) => {
1171
+ s.offerings = [
1172
+ product("rebuild", "plan", [price("rebuild", "once", 2500000, "usd")], { requires: "managed" }),
1173
+ product("managed", "plan", [price("managed", "monthly", 300000, "usd"), price("managed", "yearly", 3000000, "usd")]),
1174
+ ];
1175
+ s.productIds = ["prod_rebuild", "prod_managed"];
1176
+ s.recommended = { plan: null, addon: null };
1177
+ });
1178
+ const built = plansOf(offeringsPricing(set, { ...OPTIONS, plans: ["rebuild"] })!);
1179
+ expect(built[0]!.price).toHaveProperty("monthly");
1180
+ expect(built[0]!.price).toHaveProperty("annual");
1181
+ expect(built[0]!.cta.href.endsWith("rebuild_once?with=managed_monthly")).toBe(true);
1182
+ expect(built[0]!.annualCtaHref!.endsWith("rebuild_once?with=managed_yearly")).toBe(true);
1183
+ expect(
1184
+ offeringsPricing(set, { ...FEATURES_AND_PLANS, plans: ["rebuild"] })!.plans,
1185
+ ).toStrictEqual({ variant: "features-and-plans", plans: [built[0]] });
1186
+ });
1187
+ });
1188
+
1189
+ describe("offeringsPricing — no layout names a vendor; every link is ours (#12140 AC-5)", () => {
1190
+ it.each([undefined, ...LAYOUTS])("layout %s", (layout) => {
1191
+ const result = offeringsPricing(shownSet(), { ...OPTIONS, ...(layout ? { layout } : {}) })!;
1192
+ expect(JSON.stringify(result)).not.toMatch(/stripe/i);
1193
+ const links = [
1194
+ ...plansOf(result).flatMap((c) => [c.cta.href, ...(c.annualCtaHref ? [c.annualCtaHref] : [])]),
1195
+ ...addonsOf(result).map((t) => t.cta?.href ?? ""),
1196
+ ];
1197
+ expect(links.length).toBeGreaterThan(0);
1198
+ for (const href of links) expect(href.startsWith(OFFERINGS_CHECKOUT_PATH)).toBe(true);
1199
+ });
1200
+ });