create-ailk 0.46.5 → 0.47.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.
Files changed (30) hide show
  1. package/component-catalog.json +90 -7
  2. package/dist/lib/env-catalog.js +4 -0
  3. package/package.json +3 -3
  4. package/templates/apps/api/.env.example +18 -0
  5. package/templates/apps/api/CLAUDE.md +7 -2
  6. package/templates/apps/api/src/__tests__/vercel-handler.test.ts +176 -2
  7. package/templates/apps/api/src/lib/__mocks__/prisma.ts +31 -0
  8. package/templates/apps/api/src/vercel-handler.ts +32 -2
  9. package/templates/apps/mcp/.env.example +8 -0
  10. package/templates/apps/mcp/CLAUDE.md +2 -2
  11. package/templates/apps/web/CLAUDE.md +31 -3
  12. package/templates/apps/web/app/[locale]/layout.tsx +98 -37
  13. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +13 -3
  14. package/templates/apps/web/lib/__tests__/grid-read.test.ts +212 -0
  15. package/templates/apps/web/lib/__tests__/hub-read.test.ts +90 -0
  16. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +394 -10
  17. package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +194 -0
  18. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +210 -0
  19. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +19 -1
  20. package/templates/apps/web/lib/__tests__/site-navigation.test.ts +288 -0
  21. package/templates/apps/web/lib/grid-read.ts +115 -0
  22. package/templates/apps/web/lib/hub-read.ts +35 -0
  23. package/templates/apps/web/lib/hub-site-config.ts +154 -29
  24. package/templates/apps/web/lib/in-page-blocks.ts +11 -67
  25. package/templates/apps/web/lib/in-page-magnet.ts +5 -24
  26. package/templates/apps/web/lib/page-chrome.ts +70 -3
  27. package/templates/apps/web/lib/pricing-page.ts +33 -2
  28. package/templates/apps/web/lib/site-navigation.ts +208 -0
  29. package/templates/apps/web/next.config.mjs +19 -6
  30. package/versions.json +51 -51
@@ -0,0 +1,194 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ /**
6
+ * The hub navigation record's styles over `_site.mdx`'s (#12401, spec
7
+ * docs/specs/12401-a-site-renders-its-header-spec.md D4; AC-6).
8
+ *
9
+ * `withNavigationStyles` is pure; `resolveHomeChrome` reads the record
10
+ * through the hub read, so `@working-theory/api-client`'s `siteConfig.get`
11
+ * (the HTTP call to the hub) is doubled and `next/cache` runs the read
12
+ * uncached. `_site.mdx` is a scratch content root (`AILK_CONTENT_ROOT`).
13
+ */
14
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
15
+ import { tmpdir } from "node:os";
16
+ import { join } from "node:path";
17
+
18
+ const mockGet = jest.fn();
19
+ jest.mock("@working-theory/api-client", () => ({
20
+ ...jest.requireActual("@working-theory/api-client"),
21
+ siteConfig: { get: (...args: unknown[]) => mockGet(...args) },
22
+ }));
23
+ jest.mock("next/cache", () => ({
24
+ unstable_cache: (fn: () => Promise<unknown>) => fn,
25
+ }));
26
+ let mockPagePathThrows = false;
27
+ jest.mock("@working-theory/templates/routes", () => {
28
+ const actual = jest.requireActual("@working-theory/templates/routes");
29
+ return {
30
+ ...actual,
31
+ pagePath: (...args: Parameters<typeof actual.pagePath>) => {
32
+ if (mockPagePathThrows) throw new RangeError("forced");
33
+ return actual.pagePath(...args);
34
+ },
35
+ };
36
+ });
37
+
38
+ import { siteNavigationSchema } from "@working-theory/validation";
39
+
40
+ import { __resetHubSiteForTests } from "../hub-site-config";
41
+ import {
42
+ resolveHomeChrome,
43
+ resolvePageChrome,
44
+ withNavigationStyles,
45
+ type SiteChromeSettings,
46
+ } from "../page-chrome";
47
+
48
+ // #10704 — a fixture suite: its content is shaped for the mdx source.
49
+ process.env.CONTENT_ADAPTER = "mdx";
50
+
51
+ const FILE: SiteChromeSettings = {
52
+ headerStyle: "full",
53
+ footerStyle: "columns",
54
+ // A renamed family's `path` rides beside its styles at runtime (#11385).
55
+ families: { portfolio: { footer: "none", path: "/writing-samples" } } as SiteChromeSettings["families"],
56
+ };
57
+
58
+ const recordWith = (extra: { header?: object; families?: object }) =>
59
+ siteNavigationSchema.parse({
60
+ version: "1",
61
+ header: { items: [], ...extra.header },
62
+ footer: { columns: [] },
63
+ ...(extra.families ? { families: extra.families } : {}),
64
+ });
65
+
66
+ const STYLED = recordWith({ header: { style: "bare" }, families: { portfolio: { header: "none" } } });
67
+ const KNOBS = { home: "default" as const, footer: "columns" as const };
68
+
69
+ describe("withNavigationStyles (#12401 D4, AC-6)", () => {
70
+ it("lays the record's set styles over the file's, keeping the family's own path", () => {
71
+ const before = structuredClone(FILE);
72
+ expect(withNavigationStyles(FILE, STYLED)).toEqual({
73
+ headerStyle: "bare",
74
+ footerStyle: "columns",
75
+ families: { portfolio: { header: "none", footer: "none", path: "/writing-samples" } },
76
+ });
77
+ expect(FILE).toEqual(before);
78
+ });
79
+
80
+ it("a record setting no style answers the file settings unchanged", () => {
81
+ const before = structuredClone(FILE);
82
+ expect(withNavigationStyles(FILE, recordWith({}))).toEqual(FILE);
83
+ expect(FILE).toEqual(before);
84
+ });
85
+
86
+ it("a record style the file does not set is added; a style neither sets stays unset", () => {
87
+ const result = withNavigationStyles({ families: {} }, recordWith({ families: { blog: { footer: "closing" } } }));
88
+ expect(result).toEqual({ families: { blog: { footer: "closing" } } });
89
+ expect(result).not.toHaveProperty("headerStyle");
90
+ });
91
+
92
+ it("no record answers the file settings", () => {
93
+ expect(withNavigationStyles(FILE, null)).toEqual(FILE);
94
+ });
95
+ });
96
+
97
+ describe("resolveHomeChrome with a hub-connected read (#12401 D4, AC-6)", () => {
98
+ const ENV = ["AILK_SPOKE_KEY", "AILK_API_URL", "AILK_CONTENT_ROOT"] as const;
99
+ const saved = new Map(ENV.map((k) => [k, process.env[k]]));
100
+ let root: string;
101
+
102
+ beforeEach(() => {
103
+ __resetHubSiteForTests();
104
+ mockGet.mockReset();
105
+ mockPagePathThrows = false;
106
+ root = mkdtempSync(join(tmpdir(), "page-chrome-nav-"));
107
+ writeFileSync(
108
+ join(root, "_site.mdx"),
109
+ "---\nsiteName: Acme\nheader:\n style: full\nfooter:\n style: columns\nportfolio:\n footer: none\n path: /writing-samples\n---\n",
110
+ );
111
+ process.env.AILK_CONTENT_ROOT = root;
112
+ jest.spyOn(console, "warn").mockImplementation(() => undefined);
113
+ });
114
+
115
+ afterEach(() => {
116
+ jest.restoreAllMocks();
117
+ rmSync(root, { recursive: true, force: true });
118
+ for (const [k, v] of saved) {
119
+ if (v === undefined) delete process.env[k];
120
+ else process.env[k] = v;
121
+ }
122
+ });
123
+
124
+ it("resolves the home's header from the record, and a page's own frontmatter still wins", async () => {
125
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
126
+ process.env.AILK_API_URL = "https://hub.example";
127
+ mockGet.mockResolvedValue({
128
+ ok: true,
129
+ body: { identity: null, seo: null, navigation: { version: 2, record: STYLED } },
130
+ });
131
+
132
+ const home = await resolveHomeChrome("en", KNOBS);
133
+ expect(home.chrome.header).toBe("bare");
134
+ expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
135
+
136
+ const page = (header?: "full") =>
137
+ resolvePageChrome({
138
+ isHome: false,
139
+ homeIsDeck: false,
140
+ family: "portfolio",
141
+ page: header ? { header } : {},
142
+ site: home.site,
143
+ chrome: KNOBS,
144
+ closingListed: false,
145
+ });
146
+ expect(page("full").header).toBe("full");
147
+ expect(page().header).toBe("none");
148
+ expect(page().footer).toBe("none");
149
+ });
150
+
151
+ it("with no hub read, the home resolves from the file", async () => {
152
+ const home = await resolveHomeChrome("en", KNOBS);
153
+ expect(home.chrome.header).toBe("full");
154
+ expect(home.navigation).toBeNull();
155
+ expect(mockGet).not.toHaveBeenCalled();
156
+ });
157
+
158
+ it("answers the rendered record with its version and translation", async () => {
159
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
160
+ process.env.AILK_API_URL = "https://hub.example";
161
+ mockGet.mockResolvedValue({
162
+ ok: true,
163
+ body: { identity: null, seo: null, navigation: { version: 2, record: STYLED } },
164
+ });
165
+ const home = await resolveHomeChrome("en", KNOBS);
166
+ expect(home.navigation?.version).toBe(2);
167
+ expect(home.navigation?.chrome.navItems).toEqual([]);
168
+ });
169
+
170
+ it("a record the translator refuses lays no style: the home resolves from the file, with no navigation", async () => {
171
+ process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
172
+ process.env.AILK_API_URL = "https://hub.example";
173
+ // A record the schema takes cannot fail the translator, so the refusal is
174
+ // forced through `pagePath`, the one call inside it a mock can reach.
175
+ mockPagePathThrows = true;
176
+ const refused = siteNavigationSchema.parse({
177
+ version: "1",
178
+ header: {
179
+ style: "bare",
180
+ items: [{ kind: "link", label: { text: "Audit" }, target: { kind: "page", address: { type: "Service", slug: "audit" } } }],
181
+ },
182
+ footer: { columns: [] },
183
+ families: { portfolio: { header: "none" } },
184
+ });
185
+ mockGet.mockResolvedValue({
186
+ ok: true,
187
+ body: { identity: null, seo: null, navigation: { version: 2, record: refused } },
188
+ });
189
+ const home = await resolveHomeChrome("en", KNOBS);
190
+ expect(home.navigation).toBeNull();
191
+ expect(home.chrome.header).toBe("full");
192
+ expect(home.site.families.portfolio).toEqual({ footer: "none", path: "/writing-samples" });
193
+ });
194
+ });
@@ -1706,3 +1706,213 @@ describe("an authored card's images never reach the page (#12241 D8, security)",
1706
1706
  expect(JSON.stringify(placed!.data)).not.toContain("evil.example");
1707
1707
  });
1708
1708
  });
1709
+
1710
+ // ─── #12370 — a comparison table that reads its rows from an Offerings grid ──
1711
+
1712
+ describe("pricingSections — a grid-bound comparison table (#12370 D3, D4)", () => {
1713
+ // Past every other suite's clock, so no earlier shared read is reused.
1714
+ let now = Date.now() + 5 * 10 ** 12;
1715
+ let seq = 0;
1716
+ beforeEach(() => {
1717
+ now += 16_000;
1718
+ seq += 1;
1719
+ jest.spyOn(Date, "now").mockReturnValue(now);
1720
+ });
1721
+ afterEach(() => {
1722
+ jest.useRealTimers();
1723
+ jest.restoreAllMocks();
1724
+ });
1725
+
1726
+ /** `publicGrid`'s answer for a Capabilities grid of two levels, by feature. */
1727
+ const C = {
1728
+ kind: "capabilities",
1729
+ columns: [
1730
+ { key: "pro", ours: true, plan: "pro", name: "Pro" },
1731
+ { key: "pro-plus", ours: true, plan: "pro-plus", name: "Pro Plus" },
1732
+ ],
1733
+ groups: [
1734
+ {
1735
+ id: "site",
1736
+ name: "Site",
1737
+ rows: [
1738
+ // A Capabilities cell is what Stripe grants (`true` / `false`) or a typed value.
1739
+ { id: "pages", name: "Pages", cells: { pro: true, "pro-plus": true } },
1740
+ { id: "drafts", name: "Drafts", cells: { pro: false, "pro-plus": { value: "8" } } },
1741
+ ],
1742
+ summaries: {},
1743
+ },
1744
+ ],
1745
+ factsAsOf: null,
1746
+ };
1747
+ /** `publicGrid`'s answer for an Alternatives grid: ours, then one approved alternative. */
1748
+ const A = {
1749
+ kind: "alternatives",
1750
+ columns: [
1751
+ { key: "ours", ours: true, name: "Growth Hub" },
1752
+ { key: "wix", ours: false, name: "Wix", what: "A website builder", source: { url: "https://wix.com/pricing" }, checkedOn: "2026-11-01" },
1753
+ ],
1754
+ groups: [
1755
+ {
1756
+ id: "build",
1757
+ name: "Build",
1758
+ rows: [{ id: "r1", name: "Pages", cells: { ours: { verdict: "yes" }, wix: { verdict: "partial", words: "Blog only" } } }],
1759
+ summaries: {},
1760
+ },
1761
+ ],
1762
+ factsAsOf: "2026-11-01",
1763
+ };
1764
+
1765
+ const ok = (data: unknown) => ({ ok: true, status: 200, json: async () => ({ ok: true, data }) });
1766
+ /** The site's two reads: the shown set, and the public grid read. */
1767
+ function serve(grid: unknown | (() => Promise<unknown>), shown: unknown = { status: "unconnected" }): void {
1768
+ fetchMock.mockImplementation(async (url: unknown) => {
1769
+ if (!String(url).includes("/v1/content/grids/")) return ok(shown);
1770
+ return typeof grid === "function" ? (grid as () => Promise<unknown>)() : ok(grid);
1771
+ });
1772
+ }
1773
+ const gridCalls = () => fetchMock.mock.calls.map(([url]) => String(url)).filter((url) => url.includes("/v1/content/grids/"));
1774
+
1775
+ type Table = Extract<PageSection, { type: "comparison-table" }>;
1776
+ /** A grid-bound section as a page stores it, parsed as the site parses a page's sections. */
1777
+ const bound = (grid: Record<string, unknown>, own: Record<string, unknown> = {}): PageSection =>
1778
+ PageSectionsSchema.parse([{ id: "t", type: "comparison-table", data: { grid, ...own } }])[0]!;
1779
+ const capabilities = (extra: Record<string, unknown> = {}) => ({
1780
+ kind: "capabilities",
1781
+ products: [`growth-hub-${seq}`],
1782
+ show: "features",
1783
+ ...extra,
1784
+ });
1785
+ const alternatives = (extra: Record<string, unknown> = {}) => ({
1786
+ kind: "alternatives",
1787
+ category: `website-platform-${seq}`,
1788
+ show: "features",
1789
+ ...extra,
1790
+ });
1791
+ const tableOf = (sections: PageSection[]) => {
1792
+ const found = sections.find((s) => s.id === "t");
1793
+ if (!found || found.type !== "comparison-table") throw new Error("no table");
1794
+ return found.data as Table["data"] & { billingPeriod?: string };
1795
+ };
1796
+ const options = { plans: undefined, plan: undefined, locale: "en" };
1797
+
1798
+ it("AC-1: a capabilities grid draws its features under their capability, one column per named level", async () => {
1799
+ serve(C);
1800
+ const sections = await pricingSections([HERO, bound(capabilities({ levels: ["pro", "pro-plus"] }), { headline: "Compare" })], options);
1801
+ const table = tableOf(sections);
1802
+ expect(table.columns.map((c) => [c.key, c.plan, c.name])).toEqual([
1803
+ ["pro", "pro", "Pro"],
1804
+ ["pro-plus", "pro-plus", "Pro Plus"],
1805
+ ]);
1806
+ expect(table.groups.map((g) => [g.groupName, g.rows.map((r) => r.featureName)])).toEqual([["Site", ["Pages", "Drafts"]]]);
1807
+ expect(table.groups[0]!.rows.map((r) => r.values)).toEqual([
1808
+ { pro: true, "pro-plus": true },
1809
+ { pro: false, "pro-plus": "8" },
1810
+ ]);
1811
+ expect(table.headline).toBe("Compare");
1812
+ expect(table).not.toHaveProperty("grid");
1813
+ // One read, of the public grid route, naming the product, the levels and the page's locale.
1814
+ const [url] = gridCalls();
1815
+ expect(gridCalls()).toHaveLength(1);
1816
+ expect(url).toContain(`/v1/content/grids/capabilities/growth-hub-${seq}?`);
1817
+ expect(new URL(url!, "http://x").searchParams.get("levels")).toBe("pro pro-plus");
1818
+ expect(new URL(url!, "http://x").searchParams.get("locale")).toBe("en");
1819
+ });
1820
+
1821
+ it("AC-2: an alternatives grid draws ours first and highlighted, then the answer's alternatives, as answered", async () => {
1822
+ serve(A);
1823
+ const grid = alternatives({ ours: "growth-hub", columns: ["wix"], source: true });
1824
+ const table = tableOf(await pricingSections([HERO, bound(grid)], options));
1825
+ expect(table.columns).toEqual([
1826
+ { key: "ours", name: "Growth Hub", highlighted: true },
1827
+ { key: "wix", name: "Wix" },
1828
+ ]);
1829
+ expect(table.groups[0]!.rows[0]!.values).toEqual({ ours: { text: "", verdict: "yes" }, wix: { text: "Blog only", verdict: "partial" } });
1830
+ // The grid's own look and footnote show, since the section sets none.
1831
+ expect(table).toMatchObject({ variant: "detailed", yesMark: "ink" });
1832
+ expect(table.footnote).toContain("https://wix.com/pricing");
1833
+ const query = new URL(gridCalls()[0]!, "http://x").searchParams;
1834
+ expect([query.get("ours"), query.get("columns")]).toEqual(["growth-hub", "wix"]);
1835
+ });
1836
+
1837
+ it("the section's own fields win over the grid's, and the rest of its settings pass through", async () => {
1838
+ serve(A);
1839
+ const own = { eyebrow: "E", description: "D", footnote: "Mine", variant: "default", labelHeader: "Feature", yesMark: "muted", longCells: "clamp", checkStyle: "inverted" };
1840
+ const table = tableOf(await pricingSections([bound(alternatives(), own)], options));
1841
+ expect(table).toMatchObject(own);
1842
+ expect(table.columns).toHaveLength(2);
1843
+ });
1844
+
1845
+ it("AC-8: the section's planBar gives a grid's plan columns their price and button from the shown set", async () => {
1846
+ const both = (plan: string, monthly: number, yearly: number) => [stripePrice(plan, "monthly", monthly), stripePrice(plan, "yearly", yearly)];
1847
+ const offerings = [
1848
+ stripeProduct("pro", "plan", both("pro", 4900, 49000), { name: "Pro" }),
1849
+ stripeProduct("pro-plus", "plan", both("pro-plus", 9900, 99000), { name: "Pro Plus" }),
1850
+ ];
1851
+ const shownSet = workspaceShownSetSchema.parse({
1852
+ workspaceId: "wksp_01890a5d-ac96-774b-bcce-b302099a8057",
1853
+ organizationId: "org_01890a5d-ac96-774b-bcce-b302099a8058",
1854
+ productIds: offerings.map((o) => o.productId),
1855
+ recommended: { plan: null, addon: null },
1856
+ offerings,
1857
+ state: "current",
1858
+ snapshotAt: "2026-11-20T00:00:00.000Z",
1859
+ });
1860
+ serve(C, { status: "shown", shownSet });
1861
+ const planBar = { pickerLabel: "Plan", price: true, button: true };
1862
+ const cards = pricingSection("p", { source: "offerings", offeringPlans: ["pro", "pro-plus"] });
1863
+ const sections = await pricingSections([cards, bound(capabilities(), { planBar })], options);
1864
+ const table = tableOf(sections);
1865
+ expect(table.planBar).toEqual(planBar);
1866
+ const columns = table.columns as Array<Table["data"]["columns"][number] & { offering?: { cta: { href: string } } }>;
1867
+ expect(columns.map((c) => c.offering?.cta.href)).toEqual([
1868
+ `${OFFERINGS_CHECKOUT_PATH}/pro_monthly`,
1869
+ `${OFFERINGS_CHECKOUT_PATH}/pro-plus_monthly`,
1870
+ ]);
1871
+ // The table opens on the period the page's cards open on, as a typed table's plan columns do.
1872
+ expect(table.billingPeriod).toBe("annual");
1873
+ });
1874
+
1875
+ it.each<[string, unknown]>([
1876
+ ["a refused read", { ok: false, status: 404, json: async () => ({ ok: false, error: { code: "not_found", message: "No grid" } }) }],
1877
+ ["an answer that does not parse", ok({ kind: "capabilities", columns: "x" })],
1878
+ ["a grid with no row", ok({ ...C, groups: [] })],
1879
+ ["a grid with no column", ok({ ...C, columns: [] })],
1880
+ ])("AC-7: %s draws no table, and the page's other sections render", async (_label, response) => {
1881
+ serve(async () => response);
1882
+ const sections = await pricingSections([HERO, bound(capabilities()), EXTRAS], options);
1883
+ expect(sections.map((s) => s.id)).toEqual(["hero", "extras"]);
1884
+ });
1885
+
1886
+ it("AC-7: a read that throws draws no table, and one failed grid leaves another grid's table drawn", async () => {
1887
+ fetchMock.mockImplementation(async (url: unknown) => {
1888
+ if (String(url).includes("/grids/capabilities/")) throw new Error("hub down");
1889
+ return String(url).includes("/grids/alternatives/") ? ok(A) : ok({ status: "unconnected" });
1890
+ });
1891
+ const other = { ...bound(alternatives()), id: "alt" } as PageSection;
1892
+ const sections = await pricingSections([HERO, bound(capabilities()), other], options);
1893
+ expect(sections.map((s) => s.id)).toEqual(["hero", "alt"]);
1894
+ });
1895
+
1896
+ it("AC-7: a read that has not answered in 3,000 ms draws no table", async () => {
1897
+ jest.useFakeTimers({ doNotFake: ["Date"] });
1898
+ serve(() => new Promise(() => undefined));
1899
+ const pending = pricingSections([HERO, bound(capabilities())], options);
1900
+ await jest.advanceTimersByTimeAsync(2_999);
1901
+ let settled = false;
1902
+ void pending.then(() => (settled = true));
1903
+ await jest.advanceTimersByTimeAsync(0);
1904
+ expect(settled).toBe(false);
1905
+ await jest.advanceTimersByTimeAsync(1);
1906
+ expect((await pending).map((s) => s.id)).toEqual(["hero"]);
1907
+ });
1908
+
1909
+ it("AC-9: a typed table, and a page with no grid, makes no grid read and comes back unchanged", async () => {
1910
+ serve(C);
1911
+ const typed = PageSectionsSchema.parse([
1912
+ { id: "t", type: "comparison-table", data: { columns: [{ key: "us", name: "Us" }], groups: [{ groupName: "G", rows: [{ featureName: "F", values: { us: true } }] }] } },
1913
+ ])[0]!;
1914
+ const sections = await pricingSections([HERO, typed], options);
1915
+ expect(gridCalls()).toEqual([]);
1916
+ expect(sections[1]).toBe(typed);
1917
+ });
1918
+ });
@@ -320,12 +320,30 @@ describe("the featureList registration with no content directory (#10644 AC-2)",
320
320
  expect(mockSiteConfigGet).toHaveBeenCalledTimes(1);
321
321
  });
322
322
 
323
+ // #12390 D2 — a single-tenant site (its own API's address, no key) reads
324
+ // its one workspace's identity through the same reader.
325
+ it("keyless with an API address: registers a reader carrying the workspace identity on the file's baseUrl", async () => {
326
+ hubConnect();
327
+ delete process.env.AILK_SPOKE_KEY;
328
+ delete process.env.NEXT_PUBLIC_SITE_URL;
329
+ load();
330
+ expect(calls("setSiteIdentityReader")).toHaveLength(1);
331
+ const reader = calls("setSiteIdentityReader")[0]![0] as () => Promise<unknown>;
332
+ await expect(reader()).resolves.toEqual({
333
+ siteName: "Hub Co",
334
+ baseUrl: ORIGIN,
335
+ identity: HUB_IDENTITY,
336
+ });
337
+ expect(mockSiteConfigGet).toHaveBeenCalledTimes(1);
338
+ });
339
+
323
340
  it.each([
324
341
  ["CONTENT_ADAPTER unset", () => delete process.env.CONTENT_ADAPTER],
325
342
  ["CONTENT_ADAPTER=database", () => (process.env.CONTENT_ADAPTER = "database")],
326
- ])("not hub-connected (no AILK_SPOKE_KEY, %s): registers no reader, and setSiteIdentity receives the file registration", (_label, arrange) => {
343
+ ])("not hub-connected (no AILK_SPOKE_KEY, no API address, %s): registers no reader, and setSiteIdentity receives the file registration", (_label, arrange) => {
327
344
  hubConnect();
328
345
  delete process.env.AILK_SPOKE_KEY;
346
+ delete process.env.AILK_API_URL;
329
347
  arrange();
330
348
  load();
331
349
  expect(calls("setSiteIdentityReader")).toEqual([]);