create-ailk 0.44.0 → 0.46.0
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.
- package/README.md +6 -3
- package/component-catalog.json +24 -1
- package/component-catalog.md +6 -5
- package/dist/add-module.d.ts +7 -0
- package/dist/add-module.js +17 -2
- package/dist/apply-design.js +1 -12
- package/dist/lib/env-catalog.js +2 -2
- package/dist/lib/import-mdx.js +10 -2
- package/dist/lib/license-key-files.d.ts +2 -0
- package/dist/lib/license-key-files.js +11 -0
- package/dist/paid-sections.d.ts +19 -0
- package/dist/paid-sections.js +41 -0
- package/dist/programmatic.js +56 -6
- package/dist/seed-workspace.d.ts +1 -1
- package/dist/seed-workspace.js +10 -3
- package/dist/surfaces.js +1 -1
- package/dist/update.d.ts +21 -2
- package/dist/update.js +188 -10
- package/package.json +3 -3
- package/templates/apps/api/.env.example +23 -0
- package/templates/apps/api/CLAUDE.md +17 -7
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
- package/templates/apps/mcp/.env.example +14 -3
- package/templates/apps/mcp/CLAUDE.md +47 -24
- package/templates/apps/mcp/src/index.ts +1 -1
- package/templates/apps/web/.env.example +1 -1
- package/templates/apps/web/CLAUDE.md +47 -16
- package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +44 -41
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +24 -33
- package/templates/apps/web/app/[locale]/layout.tsx +10 -7
- package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
- package/templates/apps/web/app/api/site-status/route.ts +62 -0
- package/templates/apps/web/app/llms.txt/route.ts +3 -3
- package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
- package/templates/apps/web/app/openapi.json/route.ts +10 -9
- package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
- package/templates/apps/web/auth.ts +25 -1
- package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +245 -0
- package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +395 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +112 -0
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +280 -0
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
- package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +108 -11
- package/templates/apps/web/lib/license-key-store.ts +1 -1
- package/templates/apps/web/lib/mcp-oauth.ts +64 -0
- package/templates/apps/web/lib/mcp-served-tools.ts +231 -0
- package/templates/apps/web/lib/offerings-pricing.ts +30 -6
- package/templates/apps/web/lib/pricing-page.ts +142 -35
- package/templates/apps/web/lib/site-brand.tsx +1 -7
- package/templates/apps/web/lib/site-visibility.ts +45 -0
- package/templates/apps/web/messages/en.json +8 -0
- package/templates/apps/web/middleware.ts +16 -1
- package/templates/apps/web/src/lib/routes.ts +3 -3
- package/versions.json +51 -51
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
- package/templates/apps/web/lib/release-scope.ts +0 -47
|
@@ -815,3 +815,115 @@ describe("offeringsPricing — the route's wire shape (#8927 D3, AC-7)", () => {
|
|
|
815
815
|
).toBeNull();
|
|
816
816
|
});
|
|
817
817
|
});
|
|
818
|
+
|
|
819
|
+
describe("offeringsPricing — the seller's button label (#12103 D1, AC-1)", () => {
|
|
820
|
+
const monthly = (plan: string) => [price(plan, "monthly", 4900, "usd")];
|
|
821
|
+
function set(offerings: OfferingsProduct[]): WorkspaceShownSet {
|
|
822
|
+
return shownSet((s) => {
|
|
823
|
+
s.offerings = offerings;
|
|
824
|
+
s.productIds = offerings.map((o) => o.productId);
|
|
825
|
+
s.recommended = { plan: null, addon: null };
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
it("labels a card with its own ctaLabel and keeps the translated default on a card without one", () => {
|
|
830
|
+
const result = mapped(
|
|
831
|
+
set([
|
|
832
|
+
product("essentials", "plan", monthly("essentials"), { ctaLabel: "Start Essentials" }),
|
|
833
|
+
product("growth", "plan", monthly("growth")),
|
|
834
|
+
]),
|
|
835
|
+
);
|
|
836
|
+
expect(card(result, "essentials").cta).toEqual({
|
|
837
|
+
label: "Start Essentials",
|
|
838
|
+
href: "/api/offerings/checkout/essentials_monthly",
|
|
839
|
+
});
|
|
840
|
+
expect(card(result, "growth").cta?.label).toBe(LABELS.cta);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
it("labels an add-on tile and a bundle card with their own ctaLabel, the bundle href unchanged", () => {
|
|
844
|
+
const result = mapped(
|
|
845
|
+
set([
|
|
846
|
+
product("retainer", "plan", monthly("retainer")),
|
|
847
|
+
product("setup", "plan", [price("setup", "once", 50000, "usd")], {
|
|
848
|
+
requires: "retainer",
|
|
849
|
+
ctaLabel: "Start the bundle",
|
|
850
|
+
}),
|
|
851
|
+
product("seo", "addon", monthly("seo"), { ctaLabel: "Add it" }),
|
|
852
|
+
]),
|
|
853
|
+
);
|
|
854
|
+
expect(card(result, "setup").cta).toEqual({
|
|
855
|
+
label: "Start the bundle",
|
|
856
|
+
href: offeringsBundleHref("setup_once", "retainer_monthly"),
|
|
857
|
+
});
|
|
858
|
+
expect(tile(result, "seo").cta?.label).toBe("Add it");
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
it("removes a right-to-left override from the label and renders it as the button's text, linking the checkout path", () => {
|
|
862
|
+
const result = mapped(
|
|
863
|
+
set([product("essentials", "plan", monthly("essentials"), { ctaLabel: "Start now" })]),
|
|
864
|
+
);
|
|
865
|
+
expect(card(result, "essentials").cta?.label).toBe("Start now");
|
|
866
|
+
const { container } = render(
|
|
867
|
+
React.createElement(Pricing, { sectionName: "pricing", data: result.plans! }),
|
|
868
|
+
);
|
|
869
|
+
const anchor = Array.from(container.querySelectorAll("a")).find(
|
|
870
|
+
(a) => a.textContent?.includes("Start now"),
|
|
871
|
+
);
|
|
872
|
+
expect(anchor?.getAttribute("href")).toBe(hrefFor("essentials_monthly"));
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
describe("offeringsPricing — the add-on eyebrow and note (#12103 D5, AC-4)", () => {
|
|
877
|
+
const seo = (extra: Partial<OfferingsProduct>) =>
|
|
878
|
+
product("seo", "addon", [price("seo", "monthly", 900, "usd")], {
|
|
879
|
+
eyebrow: "No retainer",
|
|
880
|
+
note: "Per piece.",
|
|
881
|
+
unitLabel: "piece",
|
|
882
|
+
...extra,
|
|
883
|
+
});
|
|
884
|
+
function set(offerings: OfferingsProduct[]): WorkspaceShownSet {
|
|
885
|
+
return shownSet((s) => {
|
|
886
|
+
s.offerings = offerings;
|
|
887
|
+
s.productIds = offerings.map((o) => o.productId);
|
|
888
|
+
s.recommended = {
|
|
889
|
+
plan: null,
|
|
890
|
+
addon: offerings.find((o) => o.recommended)?.productId ?? null,
|
|
891
|
+
};
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
it("maps the eyebrow, the note and the unit label to their own tile fields", () => {
|
|
896
|
+
expect(tile(mapped(set([seo({})])), "seo")).toMatchObject({
|
|
897
|
+
eyebrow: "No retainer",
|
|
898
|
+
note: "Per piece.",
|
|
899
|
+
qualifier: "piece",
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
it("keeps the Recommended label as the recommended add-on's eyebrow, its note kept", () => {
|
|
904
|
+
expect(tile(mapped(set([seo({ recommended: true })])), "seo")).toMatchObject({
|
|
905
|
+
eyebrow: LABELS.recommended,
|
|
906
|
+
note: "Per piece.",
|
|
907
|
+
});
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
it("still maps a plan's note to its priceSubhead", () => {
|
|
911
|
+
const result = mapped();
|
|
912
|
+
expect(card(result, "growth").priceSubhead).toBe("Billed per active seat");
|
|
913
|
+
expect(card(result, "growth")).not.toHaveProperty("note");
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it("emits neither field on a tile whose product carries none", () => {
|
|
917
|
+
const t = tile(mapped(), "audit-pack");
|
|
918
|
+
expect(t).not.toHaveProperty("eyebrow");
|
|
919
|
+
expect(t).not.toHaveProperty("note");
|
|
920
|
+
});
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
describe("offeringsPricing — exclude (#12103 D2)", () => {
|
|
924
|
+
it("drops the excluded plans' cards and keeps every add-on tile", () => {
|
|
925
|
+
const result = offeringsPricing(shownSet(), { ...OPTIONS, exclude: ["growth"] })!;
|
|
926
|
+
expect(plansOf(result).map((c) => c.key)).toEqual(["starter", "basic"]);
|
|
927
|
+
expect(addonsOf(result).map((t) => t.key)).toEqual(["seo-audit", "audit-pack"]);
|
|
928
|
+
});
|
|
929
|
+
});
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The shared Pricing render (#10044 D5, AC-4): which offering pages `/pricing`
|
|
3
3
|
* lists, the card it lists each with, and `plans: []` reading no Stripe data.
|
|
4
|
+
* #12103: plan groups (AC-2), the default Recommended's pill (AC-3) and the
|
|
5
|
+
* authored card layout (AC-5), through the pure `offeringsFragments` and
|
|
6
|
+
* `withOfferings`.
|
|
4
7
|
*/
|
|
5
8
|
import {
|
|
6
9
|
PageSectionsSchema,
|
|
10
|
+
workspaceShownSetSchema,
|
|
11
|
+
type OfferingsPrice,
|
|
12
|
+
type OfferingsProduct,
|
|
7
13
|
type PageSection,
|
|
14
|
+
type WorkspaceShownSet,
|
|
8
15
|
} from "@working-theory/validation";
|
|
9
16
|
|
|
17
|
+
import {
|
|
18
|
+
offeringsPricing,
|
|
19
|
+
type OfferingsPricingLabels,
|
|
20
|
+
} from "../offerings-pricing";
|
|
10
21
|
import {
|
|
11
22
|
offeringPricingPages,
|
|
23
|
+
offeringsFragments,
|
|
12
24
|
pagePlans,
|
|
13
25
|
PRICING_HUB_SLUG,
|
|
14
26
|
pricingPageCard,
|
|
15
27
|
pricingSections,
|
|
28
|
+
withOfferings,
|
|
16
29
|
} from "../pricing-page";
|
|
17
30
|
import type { DetailPage } from "@working-theory/site-pages/lib/route-family";
|
|
18
31
|
|
|
@@ -140,3 +153,270 @@ describe("pricingSections (#10044 AC-4)", () => {
|
|
|
140
153
|
);
|
|
141
154
|
});
|
|
142
155
|
});
|
|
156
|
+
|
|
157
|
+
// ─── #12103 — plan groups, the default Recommended, the card layout ─────────
|
|
158
|
+
|
|
159
|
+
const LABELS: OfferingsPricingLabels = {
|
|
160
|
+
cta: "CTA⟪",
|
|
161
|
+
recommended: "REC⟪",
|
|
162
|
+
monthly: (amount) => "M⟪" + amount,
|
|
163
|
+
annual: (amount) => "Y⟪" + amount,
|
|
164
|
+
oneTime: (amount) => "O⟪" + amount,
|
|
165
|
+
withRequired: (plan, required) => "W⟪" + plan + "⟫" + required,
|
|
166
|
+
depositNote: (deposit) => "D⟪" + deposit,
|
|
167
|
+
};
|
|
168
|
+
const RECOMMENDED_LABEL = "FOR-YOU⟪";
|
|
169
|
+
const ADDONS_HEADLINE = "ADDONS⟪";
|
|
170
|
+
|
|
171
|
+
function stripePrice(
|
|
172
|
+
plan: string,
|
|
173
|
+
period: "monthly" | "yearly",
|
|
174
|
+
amount: number,
|
|
175
|
+
): OfferingsPrice {
|
|
176
|
+
return {
|
|
177
|
+
priceId: `price_${plan}${period}`,
|
|
178
|
+
lookupKey: `${plan}_${period}`,
|
|
179
|
+
plan,
|
|
180
|
+
period,
|
|
181
|
+
interval: period === "monthly" ? "month" : "year",
|
|
182
|
+
amount,
|
|
183
|
+
currency: "usd",
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function stripeProduct(
|
|
188
|
+
plan: string,
|
|
189
|
+
ailkGroup: "plan" | "addon",
|
|
190
|
+
prices: OfferingsPrice[],
|
|
191
|
+
extra: Partial<OfferingsProduct> = {},
|
|
192
|
+
): OfferingsProduct {
|
|
193
|
+
return {
|
|
194
|
+
productId: `prod_${plan}`,
|
|
195
|
+
plan,
|
|
196
|
+
name: plan,
|
|
197
|
+
description: null,
|
|
198
|
+
marketingFeatures: [],
|
|
199
|
+
unitLabel: null,
|
|
200
|
+
note: null,
|
|
201
|
+
termsNote: null,
|
|
202
|
+
ailkGroup,
|
|
203
|
+
ailkOrder: null,
|
|
204
|
+
prices,
|
|
205
|
+
recommended: false,
|
|
206
|
+
...extra,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** essentials, growth (plans, monthly only), writing (monthly + yearly), seo (add-on). */
|
|
211
|
+
function stripeSet(
|
|
212
|
+
recommended: { growth?: boolean } = {},
|
|
213
|
+
): WorkspaceShownSet {
|
|
214
|
+
const offerings = [
|
|
215
|
+
stripeProduct("essentials", "plan", [stripePrice("essentials", "monthly", 1000)]),
|
|
216
|
+
stripeProduct("growth", "plan", [stripePrice("growth", "monthly", 2000)], {
|
|
217
|
+
recommended: recommended.growth ?? false,
|
|
218
|
+
}),
|
|
219
|
+
stripeProduct("writing", "plan", [
|
|
220
|
+
stripePrice("writing", "monthly", 3000),
|
|
221
|
+
stripePrice("writing", "yearly", 30000),
|
|
222
|
+
]),
|
|
223
|
+
stripeProduct("seo", "addon", [stripePrice("seo", "monthly", 900)]),
|
|
224
|
+
];
|
|
225
|
+
return workspaceShownSetSchema.parse({
|
|
226
|
+
workspaceId: "wksp_01890a5d-ac96-774b-bcce-b302099a8057",
|
|
227
|
+
organizationId: "org_01890a5d-ac96-774b-bcce-b302099a8058",
|
|
228
|
+
productIds: offerings.map((o) => o.productId),
|
|
229
|
+
recommended: { plan: recommended.growth ? "prod_growth" : null, addon: null },
|
|
230
|
+
offerings,
|
|
231
|
+
state: "current",
|
|
232
|
+
snapshotAt: "2026-11-20T00:00:00.000Z",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
type Pricing = Extract<PageSection, { type: "pricing" }>;
|
|
237
|
+
|
|
238
|
+
function pricingSection(id: string, data: Record<string, unknown> = {}): Pricing {
|
|
239
|
+
return { id, type: "pricing", data: { plans: [], ...data } } as Pricing;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const HERO = {
|
|
243
|
+
id: "hero",
|
|
244
|
+
type: "hero",
|
|
245
|
+
data: { headline: "Pricing" },
|
|
246
|
+
} as PageSection;
|
|
247
|
+
const EXTRAS = pricingSection("extras", { variant: "addons", headline: "Extras" });
|
|
248
|
+
|
|
249
|
+
/** `offeringsFragments` then `withOfferings`, as `pricingSections` runs them. */
|
|
250
|
+
function render(
|
|
251
|
+
sections: PageSection[],
|
|
252
|
+
options: {
|
|
253
|
+
plans?: readonly string[];
|
|
254
|
+
plan?: string;
|
|
255
|
+
set?: WorkspaceShownSet;
|
|
256
|
+
} = {},
|
|
257
|
+
) {
|
|
258
|
+
const fragments = offeringsFragments(sections, options.set ?? stripeSet(), {
|
|
259
|
+
locale: "en-US",
|
|
260
|
+
labels: LABELS,
|
|
261
|
+
plans: options.plans,
|
|
262
|
+
});
|
|
263
|
+
const placed = withOfferings(
|
|
264
|
+
sections,
|
|
265
|
+
fragments.pricing!,
|
|
266
|
+
options.plan,
|
|
267
|
+
RECOMMENDED_LABEL,
|
|
268
|
+
ADDONS_HEADLINE,
|
|
269
|
+
fragments.groups,
|
|
270
|
+
);
|
|
271
|
+
return { placed, groups: fragments.groups };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function dataOf(placed: PageSection[], id: string) {
|
|
275
|
+
const found = placed.find((s) => s.id === id);
|
|
276
|
+
if (!found || found.type !== "pricing") throw new Error(`no pricing ${id}`);
|
|
277
|
+
return found.data as Pricing["data"] & { recommended?: string };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const keysOf = (placed: PageSection[], id: string) =>
|
|
281
|
+
dataOf(placed, id).plans.map((card) => card.key);
|
|
282
|
+
|
|
283
|
+
const allKeys = (placed: PageSection[]) =>
|
|
284
|
+
placed.flatMap((s) =>
|
|
285
|
+
s.type === "pricing" ? s.data.plans.map((card) => card.key) : [],
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
describe("plan groups — offeringPlans on a pricing section (#12103 D2, AC-2)", () => {
|
|
289
|
+
it("two listed groups each show their own plans, with their own toggle, and none is removed", () => {
|
|
290
|
+
const { placed } = render([
|
|
291
|
+
HERO,
|
|
292
|
+
pricingSection("retainers", { offeringPlans: ["essentials", "growth"] }),
|
|
293
|
+
pricingSection("writing-skills", { offeringPlans: ["writing"] }),
|
|
294
|
+
EXTRAS,
|
|
295
|
+
]);
|
|
296
|
+
expect(placed.map((s) => s.id)).toEqual(["hero", "retainers", "writing-skills", "extras"]);
|
|
297
|
+
expect(keysOf(placed, "retainers")).toEqual(["essentials", "growth"]);
|
|
298
|
+
expect(dataOf(placed, "retainers").billingToggle).toBe(false);
|
|
299
|
+
expect(keysOf(placed, "writing-skills")).toEqual(["writing"]);
|
|
300
|
+
expect(dataOf(placed, "writing-skills").billingToggle).toBe(true);
|
|
301
|
+
expect(dataOf(placed, "extras").addons?.map((t) => t.name)).toEqual(["seo"]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("an unlisted plans section shows the page's plans less the listed ones", () => {
|
|
305
|
+
const { placed } = render([
|
|
306
|
+
HERO,
|
|
307
|
+
pricingSection("retainers"),
|
|
308
|
+
pricingSection("writing-skills", { offeringPlans: ["writing"] }),
|
|
309
|
+
EXTRAS,
|
|
310
|
+
]);
|
|
311
|
+
expect(keysOf(placed, "retainers")).toEqual(["essentials", "growth"]);
|
|
312
|
+
expect(keysOf(placed, "writing-skills")).toEqual(["writing"]);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("removes a listed group with nothing shown, and its plan appears nowhere", () => {
|
|
316
|
+
const { placed } = render([
|
|
317
|
+
HERO,
|
|
318
|
+
pricingSection("retainers", { offeringPlans: ["essentials", "growth"] }),
|
|
319
|
+
pricingSection("writing-skills", { offeringPlans: ["absent"] }),
|
|
320
|
+
EXTRAS,
|
|
321
|
+
]);
|
|
322
|
+
expect(placed.map((s) => s.id)).toEqual(["hero", "retainers", "extras"]);
|
|
323
|
+
expect(allKeys(placed)).not.toContain("writing");
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("inserts no section for the leftover plans when every plans section is listed", () => {
|
|
327
|
+
const { placed } = render([
|
|
328
|
+
HERO,
|
|
329
|
+
pricingSection("retainers", { offeringPlans: ["essentials"] }),
|
|
330
|
+
pricingSection("writing-skills", { offeringPlans: ["writing"] }),
|
|
331
|
+
EXTRAS,
|
|
332
|
+
]);
|
|
333
|
+
expect(placed.map((s) => s.id)).toEqual(["hero", "retainers", "writing-skills", "extras"]);
|
|
334
|
+
expect(allKeys(placed)).not.toContain("growth");
|
|
335
|
+
expect(placed.some((s) => s.id === "offerings-plans")).toBe(false);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it("a page with no offeringPlans renders exactly as today (FR-3)", () => {
|
|
339
|
+
const a = pricingSection("a", { headline: "A", eyebrow: "Plans" });
|
|
340
|
+
const { placed, groups } = render([HERO, a, pricingSection("b"), EXTRAS]);
|
|
341
|
+
expect(placed.map((s) => s.id)).toEqual(["hero", "a", "extras"]);
|
|
342
|
+
expect(groups.size).toBe(0);
|
|
343
|
+
const cards = offeringsPricing(stripeSet(), { locale: "en-US", labels: LABELS })!.plans!.plans;
|
|
344
|
+
expect(dataOf(placed, "a")).toEqual({
|
|
345
|
+
headline: "A",
|
|
346
|
+
eyebrow: "Plans",
|
|
347
|
+
variant: "three-tiers-with-toggle",
|
|
348
|
+
cardLayout: "centered",
|
|
349
|
+
billingToggle: true,
|
|
350
|
+
plans: cards,
|
|
351
|
+
recommendedLabel: RECOMMENDED_LABEL,
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it("applies ?plan= in the group whose cards carry it; the other keeps its default", () => {
|
|
356
|
+
const { placed } = render(
|
|
357
|
+
[
|
|
358
|
+
pricingSection("retainers", { offeringPlans: ["essentials", "growth"] }),
|
|
359
|
+
pricingSection("writing-skills", { offeringPlans: ["writing"] }),
|
|
360
|
+
],
|
|
361
|
+
{ plan: "writing", set: stripeSet({ growth: true }) },
|
|
362
|
+
);
|
|
363
|
+
expect(dataOf(placed, "writing-skills").plans[0]).not.toHaveProperty("highlightLabel");
|
|
364
|
+
const growth = dataOf(placed, "retainers").plans.find((c) => c.key === "growth");
|
|
365
|
+
expect(growth?.highlightLabel).toBe(LABELS.recommended);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it("makes no shown-offerings read for page `plans: []`, whatever a section lists", async () => {
|
|
369
|
+
const declared = [pricingSection("writing-skills", { offeringPlans: ["writing"] })];
|
|
370
|
+
const sections = await pricingSections(declared, {
|
|
371
|
+
plans: [],
|
|
372
|
+
plan: undefined,
|
|
373
|
+
locale: "en",
|
|
374
|
+
});
|
|
375
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
376
|
+
expect(sections).toBe(declared);
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
describe("the default Recommended's pill (#12103 D3, AC-3)", () => {
|
|
381
|
+
it("shows the pill on the workspace's Recommended plan with no ?plan=", () => {
|
|
382
|
+
const { placed } = render([pricingSection("plans")], { set: stripeSet({ growth: true }) });
|
|
383
|
+
const growth = dataOf(placed, "plans").plans.find((c) => c.key === "growth");
|
|
384
|
+
expect(growth).toMatchObject({
|
|
385
|
+
highlighted: true,
|
|
386
|
+
highlightStyle: "pill",
|
|
387
|
+
highlightLabel: LABELS.recommended,
|
|
388
|
+
});
|
|
389
|
+
expect(dataOf(placed, "plans").recommended).toBeUndefined();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("lets ?plan= move it for that visit", () => {
|
|
393
|
+
const { placed } = render([pricingSection("plans")], {
|
|
394
|
+
set: stripeSet({ growth: true }),
|
|
395
|
+
plan: "essentials",
|
|
396
|
+
});
|
|
397
|
+
const data = dataOf(placed, "plans");
|
|
398
|
+
expect(data.plans.some((c) => c.highlightLabel !== undefined)).toBe(false);
|
|
399
|
+
expect(data.recommended).toBe("essentials");
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe("the authored card layout survives (#12103 D6, AC-5)", () => {
|
|
404
|
+
it("keeps a plans slot's cardLayout over the mapper's, and the mapper's when the slot sets none", () => {
|
|
405
|
+
expect(dataOf(render([pricingSection("plans", { cardLayout: "default" })]).placed, "plans").cardLayout).toBe("default");
|
|
406
|
+
expect(dataOf(render([pricingSection("plans")]).placed, "plans").cardLayout).toBe("centered");
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it("keeps a listed group's cardLayout", () => {
|
|
410
|
+
const { placed } = render([
|
|
411
|
+
pricingSection("writing-skills", { offeringPlans: ["writing"], cardLayout: "default" }),
|
|
412
|
+
]);
|
|
413
|
+
expect(dataOf(placed, "writing-skills").cardLayout).toBe("default");
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it("keeps the mapper's billingToggle over an authored one", () => {
|
|
417
|
+
const { placed } = render([
|
|
418
|
+
pricingSection("retainers", { offeringPlans: ["essentials", "growth"], billingToggle: true }),
|
|
419
|
+
]);
|
|
420
|
+
expect(dataOf(placed, "retainers").billingToggle).toBe(false);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
@@ -310,14 +310,13 @@ describe("resolveSiteBrand() (#11456 D4)", () => {
|
|
|
310
310
|
const hub = (identity: unknown, seo: unknown = null) =>
|
|
311
311
|
mockReadHubSite.mockResolvedValue({ identity, seo });
|
|
312
312
|
|
|
313
|
-
it("with no hub site, answers the module's constants
|
|
313
|
+
it("with no hub site, answers the module's constants", async () => {
|
|
314
314
|
mockReadHubSite.mockResolvedValue(undefined);
|
|
315
315
|
const brand = await loadSiteBrand();
|
|
316
316
|
await expect(brand.resolveSiteBrand()).resolves.toEqual({
|
|
317
317
|
siteName: brand.SITE_NAME,
|
|
318
318
|
description: brand.SITE_DESCRIPTION,
|
|
319
319
|
copyrightHolder: brand.COPYRIGHT_HOLDER,
|
|
320
|
-
indexable: true,
|
|
321
320
|
});
|
|
322
321
|
});
|
|
323
322
|
|
|
@@ -331,7 +330,6 @@ describe("resolveSiteBrand() (#11456 D4)", () => {
|
|
|
331
330
|
siteName: "Hub Co",
|
|
332
331
|
description: "Seo description.",
|
|
333
332
|
copyrightHolder: "Hub Co",
|
|
334
|
-
indexable: true,
|
|
335
333
|
});
|
|
336
334
|
});
|
|
337
335
|
|
|
@@ -358,12 +356,13 @@ describe("resolveSiteBrand() (#11456 D4)", () => {
|
|
|
358
356
|
await expect(resolveSiteBrand()).resolves.toMatchObject({ siteName: "Env Name" });
|
|
359
357
|
});
|
|
360
358
|
|
|
361
|
-
it("
|
|
359
|
+
it("a stored seo robots.index false gives a brand with no indexing field (#11978 D7)", async () => {
|
|
362
360
|
hub(null, { version: "1", robots: { index: false } });
|
|
363
361
|
const brand = await loadSiteBrand();
|
|
364
|
-
await expect(brand.resolveSiteBrand()).resolves.
|
|
362
|
+
await expect(brand.resolveSiteBrand()).resolves.toEqual({
|
|
365
363
|
siteName: brand.SITE_NAME,
|
|
366
|
-
|
|
364
|
+
description: brand.SITE_DESCRIPTION,
|
|
365
|
+
copyrightHolder: brand.COPYRIGHT_HOLDER,
|
|
367
366
|
});
|
|
368
367
|
});
|
|
369
368
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #11978 D2 — the site's one rule for Hidden (AC-2 (d), AC-3 (a)).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { StealthValueError } from "@working-theory/web-i18n/stealth";
|
|
6
|
+
|
|
7
|
+
const mockSiteDiscoverable = jest.fn();
|
|
8
|
+
jest.mock("@working-theory/api-client", () => ({
|
|
9
|
+
siteDiscoverable: () => mockSiteDiscoverable(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
import { HIDDEN_ROBOTS_HEADER, siteHidden, siteLock } from "../site-visibility";
|
|
13
|
+
|
|
14
|
+
const saved = process.env["STEALTH"];
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
mockSiteDiscoverable.mockReset().mockResolvedValue(true);
|
|
18
|
+
delete process.env["STEALTH"];
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterAll(() => {
|
|
22
|
+
if (saved === undefined) delete process.env["STEALTH"];
|
|
23
|
+
else process.env["STEALTH"] = saved;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("siteHidden() (#11978 D2)", () => {
|
|
27
|
+
it("is true under STEALTH, with no hub read", async () => {
|
|
28
|
+
process.env["STEALTH"] = "true";
|
|
29
|
+
await expect(siteHidden()).resolves.toBe(true);
|
|
30
|
+
expect(mockSiteDiscoverable).not.toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("is true with STEALTH unset and the switch off", async () => {
|
|
34
|
+
mockSiteDiscoverable.mockResolvedValue(false);
|
|
35
|
+
await expect(siteHidden()).resolves.toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("is false with both off", async () => {
|
|
39
|
+
process.env["STEALTH"] = "false";
|
|
40
|
+
await expect(siteHidden()).resolves.toBe(false);
|
|
41
|
+
expect(mockSiteDiscoverable).toHaveBeenCalledTimes(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("throws StealthValueError on a bogus STEALTH", async () => {
|
|
45
|
+
process.env["STEALTH"] = "maybe";
|
|
46
|
+
await expect(siteHidden()).rejects.toBeInstanceOf(StealthValueError);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("siteLock() (#11978 D2)", () => {
|
|
51
|
+
it.each([
|
|
52
|
+
["true", "hosting"],
|
|
53
|
+
["1", "hosting"],
|
|
54
|
+
["off", null],
|
|
55
|
+
[undefined, null],
|
|
56
|
+
])("STEALTH=%s → %s", (raw, lock) => {
|
|
57
|
+
if (raw !== undefined) process.env["STEALTH"] = raw;
|
|
58
|
+
expect(siteLock()).toBe(lock);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("is STEALTH's own header value", () => {
|
|
62
|
+
expect(HIDDEN_ROBOTS_HEADER).toBe("noindex, nofollow, noarchive");
|
|
63
|
+
});
|
|
64
|
+
});
|