create-ailk 0.40.0 → 0.40.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.
Files changed (72) hide show
  1. package/README.md +26 -4
  2. package/component-catalog.json +1 -1
  3. package/component-catalog.md +1 -1
  4. package/dist/add-module.d.ts +2 -1
  5. package/dist/add-module.js +17 -1
  6. package/dist/cutover.d.ts +7 -3
  7. package/dist/cutover.js +8 -3
  8. package/dist/lib/declared-env.d.ts +5 -1
  9. package/dist/lib/declared-env.js +6 -1
  10. package/dist/lib/env-catalog.d.ts +3 -2
  11. package/dist/lib/env-catalog.js +4 -8
  12. package/dist/module-architecture.js +0 -1
  13. package/dist/programmatic.js +18 -9
  14. package/dist/remove-module.js +1 -1
  15. package/dist/seam-refresh.d.ts +60 -0
  16. package/dist/seam-refresh.js +214 -0
  17. package/dist/spoke-checkout.d.ts +12 -3
  18. package/dist/spoke-checkout.js +14 -5
  19. package/dist/sync-routes.d.ts +10 -1
  20. package/dist/sync-routes.js +61 -6
  21. package/dist/template-record.d.ts +14 -2
  22. package/dist/template-record.js +60 -22
  23. package/dist/topology.js +3 -4
  24. package/dist/update.d.ts +13 -1
  25. package/dist/update.js +100 -8
  26. package/package.json +3 -3
  27. package/templates/.env.example +6 -0
  28. package/templates/.github/workflows/ci.yml +3 -0
  29. package/templates/apps/api/.env.example +12 -0
  30. package/templates/apps/api/CLAUDE.md +10 -7
  31. package/templates/apps/mcp/CLAUDE.md +25 -5
  32. package/templates/apps/web/.env.example +7 -1
  33. package/templates/apps/web/CLAUDE.md +40 -13
  34. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  35. package/templates/apps/web/app/[locale]/layout.tsx +41 -24
  36. package/templates/apps/web/app/api/revalidate/__tests__/route.test.ts +56 -1
  37. package/templates/apps/web/app/api/revalidate/route.ts +45 -4
  38. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +60 -0
  39. package/templates/apps/web/app/llms.txt/route.ts +17 -4
  40. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +15 -7
  41. package/templates/apps/web/auth.config.tsx +2 -0
  42. package/templates/apps/web/auth.ts +28 -4
  43. package/templates/apps/web/jest.config.cjs +1 -1
  44. package/templates/apps/web/lib/__tests__/auth-email.test.ts +21 -0
  45. package/templates/apps/web/lib/__tests__/docs-path.test.ts +20 -2
  46. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +246 -0
  47. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +58 -0
  48. package/templates/apps/web/lib/__tests__/relay.test.ts +127 -12
  49. package/templates/apps/web/lib/__tests__/served-pages.test.ts +163 -20
  50. package/templates/apps/web/lib/__tests__/server-api.test.ts +72 -7
  51. package/templates/apps/web/lib/__tests__/services-path.test.ts +22 -1
  52. package/templates/apps/web/lib/__tests__/site-brand.test.ts +77 -0
  53. package/templates/apps/web/lib/__tests__/site-contact-lines.test.ts +64 -0
  54. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +144 -4
  55. package/templates/apps/web/lib/auth-email.ts +19 -0
  56. package/templates/apps/web/lib/docs-path.ts +1 -1
  57. package/templates/apps/web/lib/hub-site-config.ts +154 -0
  58. package/templates/apps/web/lib/mcp-oauth.ts +123 -17
  59. package/templates/apps/web/lib/profile-back-link.ts +49 -12
  60. package/templates/apps/web/lib/relay.ts +48 -9
  61. package/templates/apps/web/lib/served-pages.ts +144 -39
  62. package/templates/apps/web/lib/server-api.ts +37 -4
  63. package/templates/apps/web/lib/services-path.ts +1 -1
  64. package/templates/apps/web/lib/site-brand.tsx +66 -0
  65. package/templates/apps/web/lib/site-contact-email.ts +24 -4
  66. package/templates/apps/web/lib/site-contact-lines.ts +20 -4
  67. package/templates/apps/web/lib/site-identity.ts +38 -2
  68. package/templates/apps/web/messages/en.json +13 -8
  69. package/templates/apps/web/middleware.ts +4 -2
  70. package/templates/apps/web/src/lib/routes.ts +13 -0
  71. package/templates/tools/declared-env.ts +6 -1
  72. package/versions.json +51 -51
@@ -1,16 +1,20 @@
1
1
  /**
2
2
  * Tests for the served-pages source the bare back arrow walks up through
3
3
  * (operator handoff 2026-11-09): listed content pages with their titles,
4
- * fixed code-rendered routes of the modules this site carries, and a
5
- * fail-safe when the adapter throws.
4
+ * the page routes the app builds (#11438) — its page files and Next's
5
+ * app-path routes manifest, dynamic segments included — and a fail-safe when
6
+ * a source cannot be read.
7
+ *
8
+ * Every case builds its own app tree in a temporary directory and points
9
+ * `process.cwd()` at it, so the suite asserts the same thing in this
10
+ * monorepo and in any scaffold, whatever pages either carries.
6
11
  */
7
12
 
8
- // A module, not a script: its helpers stay out of the global scope.
9
- export {};
10
- // Whether this site carries the scheduling module is the site's own generated
11
- // flag, so the suite asserts against it: the monorepo serves /meet, a
12
- // scaffold without scheduling does not (release-check matrix rows, 2026-11-10).
13
- import { SCHEDULING_PAGES } from "../modules.generated";
13
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
14
+ import { tmpdir } from "node:os";
15
+ import { dirname, join } from "node:path";
16
+
17
+ import { ancestorPaths, servedParent } from "../profile-back-link";
14
18
 
15
19
  const mockListPages = jest.fn();
16
20
  let mockAdapterThrows = false;
@@ -27,15 +31,44 @@ function page(type: string, slug: string, title: string) {
27
31
  return { type, slug, title };
28
32
  }
29
33
 
30
- async function loadServed(locale: string) {
31
- let servedPages!: typeof import("../served-pages").servedPages;
34
+ let root: string;
35
+
36
+ /** Writes empty files under the temporary site root, at their relative paths. */
37
+ function site(files: Record<string, string>): void {
38
+ for (const [path, body] of Object.entries(files)) {
39
+ const file = join(root, path);
40
+ mkdirSync(dirname(file), { recursive: true });
41
+ writeFileSync(file, body);
42
+ }
43
+ }
44
+
45
+ /** An app tree of empty page files, each given relative to `app/[locale]/`. */
46
+ function appPages(...routes: string[]): void {
47
+ site(Object.fromEntries(routes.map((route) => [join("app/[locale]", route, "page.tsx"), ""])));
48
+ }
49
+
50
+ function loadModule(): typeof import("../served-pages") {
51
+ let mod!: typeof import("../served-pages");
32
52
  jest.isolateModules(() => {
33
- ({ servedPages } = jest.requireActual("../served-pages"));
53
+ mod = jest.requireActual("../served-pages");
34
54
  });
35
- return servedPages(locale);
55
+ return mod;
56
+ }
57
+
58
+ function loadServed(locale: string, candidates?: readonly string[]) {
59
+ return loadModule().servedPages(locale, candidates);
60
+ }
61
+
62
+ /** The arrow's parent for `pathname`, as the locale layout asks it. */
63
+ async function arrowParent(pathname: string): Promise<string | null> {
64
+ const locales = ["en"];
65
+ const pages = await loadServed("en", ancestorPaths(pathname, locales));
66
+ return servedParent({ pathname, locales, served: (path) => pages.has(path) });
36
67
  }
37
68
 
38
69
  beforeEach(() => {
70
+ root = mkdtempSync(join(tmpdir(), "served-pages-"));
71
+ jest.spyOn(process, "cwd").mockReturnValue(root);
39
72
  mockAdapterThrows = false;
40
73
  mockListPages.mockReset();
41
74
  mockListPages.mockImplementation((type: string) => {
@@ -47,7 +80,12 @@ beforeEach(() => {
47
80
  });
48
81
  });
49
82
 
50
- describe("servedPages", () => {
83
+ afterEach(() => {
84
+ jest.restoreAllMocks();
85
+ rmSync(root, { recursive: true, force: true });
86
+ });
87
+
88
+ describe("servedPages — content pages", () => {
51
89
  it("lists a content page at its served path with its title", async () => {
52
90
  const pages = await loadServed("en");
53
91
  expect(pages.get("/about")).toBe("About us");
@@ -58,20 +96,125 @@ describe("servedPages", () => {
58
96
  expect([...pages.values()]).not.toContain("Thanks");
59
97
  });
60
98
 
61
- it("includes /meet, the scheduling module's code-rendered index, with no title", async () => {
62
- const pages = await loadServed("en");
63
- expect(pages.get("/meet")).toBe(SCHEDULING_PAGES ? "" : undefined);
64
- });
65
-
66
99
  it("reads the locale it is asked for", async () => {
67
100
  await loadServed("es");
68
101
  expect(mockListPages).toHaveBeenCalledWith("AboutPage", "es");
69
102
  });
70
103
 
71
- it("keeps the code-rendered routes when the adapter throws", async () => {
104
+ it("keeps a content page's title where the app also builds its route", async () => {
105
+ appPages("about");
106
+ const pages = await loadServed("en");
107
+ expect(pages.get("/about")).toBe("About us");
108
+ });
109
+ });
110
+
111
+ describe("servedPages — the page routes the app builds (#11438)", () => {
112
+ // The fixture site has no package.json and no generated module flag, so
113
+ // /meet is served by its page file alone (samhenry.org's own /meet pages).
114
+ it("serves /meet from the app's own page file, with no scheduling package and no title", async () => {
115
+ appPages("meet", "meet/[slug]");
116
+ const pages = await loadServed("en");
117
+ expect(pages.get("/meet")).toBe("");
118
+ await expect(arrowParent("/meet/intro")).resolves.toBe("/meet");
119
+ });
120
+
121
+ it.each([
122
+ ["/private/meet-up", "/private", ["private"]],
123
+ ["/diagnostic/start", "/diagnostic", ["diagnostic", "diagnostic/start"]],
124
+ ["/flows/audit/start", "/flows/audit", ["flows/[slug]", "flows/[slug]/start"]],
125
+ ["/es/flows/audit/start", "/flows/audit", ["flows/[slug]", "flows/[slug]/start"]],
126
+ ])("%s → %s, a page route the app builds", async (pathname, parent, routes) => {
127
+ appPages(...routes);
128
+ const locales = ["en", "es"];
129
+ const pages = await loadServed("en", ancestorPaths(pathname, locales));
130
+ expect(servedParent({ pathname, locales, served: (path) => pages.has(path) })).toBe(parent);
131
+ });
132
+
133
+ it("reads Next's app-path routes manifest where the page files are not deployed", async () => {
134
+ site({
135
+ ".next/app-path-routes-manifest.json": JSON.stringify({
136
+ "/[locale]/diagnostic/page": "/[locale]/diagnostic",
137
+ "/[locale]/flows/[slug]/page": "/[locale]/flows/[slug]",
138
+ "/[locale]/feed.xml/route": "/[locale]/feed.xml",
139
+ "/_not-found/page": "/_not-found",
140
+ }),
141
+ });
142
+ await expect(arrowParent("/diagnostic/start")).resolves.toBe("/diagnostic");
143
+ await expect(arrowParent("/flows/audit/start")).resolves.toBe("/flows/audit");
144
+ const pages = await loadServed("en");
145
+ expect(pages.has("/feed.xml")).toBe(false);
146
+ expect(pages.has("/_not-found")).toBe(false);
147
+ });
148
+
149
+ it("drops route groups and skips private folders", async () => {
150
+ appPages("(authed)/account", "_parts/hidden");
151
+ const pages = await loadServed("en");
152
+ expect(pages.get("/account")).toBe("");
153
+ expect(pages.has("/_parts/hidden")).toBe(false);
154
+ expect(pages.has("/hidden")).toBe(false);
155
+ });
156
+
157
+ it("serves an optional catch-all's own index, never a path under it", async () => {
158
+ appPages("blog/[[...slug]]");
159
+ const pages = await loadServed("en", ["/blog/series"]);
160
+ expect(pages.get("/blog")).toBe("");
161
+ expect(pages.has("/blog/series")).toBe(false);
162
+ });
163
+
164
+ it("adds a dynamic route's match only for the candidates asked about, never to the shared set", async () => {
165
+ appPages("flows/[slug]");
166
+ const mod = loadModule();
167
+ expect((await mod.servedPages("en", ["/flows/audit"])).has("/flows/audit")).toBe(true);
168
+ expect((await mod.servedPages("en")).has("/flows/audit")).toBe(false);
169
+ });
170
+
171
+ it("names no route in its own source", () => {
172
+ // The code alone: its doc comments name routes as examples.
173
+ const source = readFileSync(join(__dirname, "..", "served-pages.ts"), "utf8")
174
+ .replace(/\/\*[\s\S]*?\*\//g, "")
175
+ .replace(/^\s*\/\/.*$/gm, "");
176
+ for (const route of ["meet", "private", "diagnostic", "flows"]) {
177
+ expect(source).not.toMatch(new RegExp(`["'\`]/${route}\\b`));
178
+ }
179
+ });
180
+ });
181
+
182
+ describe("servedPages — what still falls through", () => {
183
+ it("walks past a parent with no built page route and no content page, then home", async () => {
184
+ appPages("meet");
185
+ await expect(arrowParent("/meet/nothing/deeper")).resolves.toBe("/meet");
186
+ await expect(arrowParent("/nowhere/at-all")).resolves.toBeNull();
187
+ });
188
+
189
+ it("never counts the site's all-dynamic content catch-all as a parent", async () => {
190
+ appPages("[slug]", "[slug]/[detail]");
191
+ await expect(arrowParent("/widgets/one/two")).resolves.toBeNull();
192
+ });
193
+
194
+ it("never counts a required catch-all as a parent", async () => {
195
+ appPages("files/[...path]");
196
+ await expect(arrowParent("/files/a/b")).resolves.toBeNull();
197
+ });
198
+
199
+ it("counts a built route with seed content only through its content page", async () => {
200
+ appPages("faq");
201
+ const pages = await loadServed("en");
202
+ expect(pages.has("/faq")).toBe(false);
203
+ });
204
+
205
+ it("keeps the built routes when the adapter throws", async () => {
206
+ appPages("meet");
72
207
  mockAdapterThrows = true;
73
208
  const pages = await loadServed("en");
74
- expect(pages.has("/meet")).toBe(SCHEDULING_PAGES);
209
+ expect(pages.has("/meet")).toBe(true);
75
210
  expect(pages.has("/about")).toBe(false);
76
211
  });
212
+
213
+ it("serves only content pages, and warns, when neither the page files nor the manifest can be read", async () => {
214
+ site({ ".next/app-path-routes-manifest.json": "not json" });
215
+ const warn = jest.spyOn(console, "warn").mockImplementation(() => {});
216
+ const pages = await loadServed("en", ["/flows/audit"]);
217
+ expect([...pages.keys()]).toEqual(["/about"]);
218
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining("[served-pages]"));
219
+ });
77
220
  });
@@ -2,13 +2,14 @@
2
2
  * Tests for `forwardedCookieInit` — the RSC cookie/origin-forwarding helper
3
3
  * (#5371 shepherd fix-up).
4
4
  *
5
- * Contract: the returned `init.headers` always carries the forwarded
6
- * `cookie`, and carries `origin` ONLY when the incoming request's `Origin`
7
- * header is present — never a fabricated value. This is what lets a Server
8
- * Action `PUT`/`PATCH` through `@working-theory/api-client`'s `workspace.*`
9
- * namespace pass `apps/api`'s same-origin CSRF check (`isOriginAllowed`),
10
- * which Node's server-side `fetch` cannot satisfy on its own since it never
11
- * sets `Origin`.
5
+ * Contract: the returned `init.headers` always carries `cookie` — exactly
6
+ * one Better Auth session-token pair, the `__Secure-` name first, or `""`
7
+ * when the jar holds neither (#8089) — and carries `origin` ONLY when the
8
+ * incoming request's `Origin` header is present — never a fabricated value.
9
+ * This is what lets a Server Action `PUT`/`PATCH` through
10
+ * `@working-theory/api-client`'s `workspace.*` namespace pass `apps/api`'s
11
+ * same-origin CSRF check (`isOriginAllowed`), which Node's server-side
12
+ * `fetch` cannot satisfy on its own since it never sets `Origin`.
12
13
  *
13
14
  * On a spoke that signs in through its hub (`SIGN_IN_PROVIDER === "hub"`) it
14
15
  * returns the hub credential instead. The provider is the seam's, mocked to
@@ -99,4 +100,68 @@ describe("forwardedCookieInit", () => {
99
100
  expect(mockCookies).not.toHaveBeenCalled();
100
101
  expect(mockHeaders).not.toHaveBeenCalled();
101
102
  });
103
+
104
+ describe("forwards only the Better Auth session cookie (#8089)", () => {
105
+ async function initFor(jar: string, origin?: string) {
106
+ mockCookies.mockResolvedValue({ toString: () => jar });
107
+ mockHeaders.mockResolvedValue(new Headers(origin ? { origin } : {}));
108
+ return forwardedCookieInit();
109
+ }
110
+
111
+ it("forwards the __Secure- session cookie first and nothing else", async () => {
112
+ const init = await initFor(
113
+ "theme=dark; better-auth.session_token=plain.sig; __Secure-better-auth.session_token=sec.sig%3D; ailk-vid=v1; __Host-ailk-hub-session=SEALED",
114
+ "https://app.example.com",
115
+ );
116
+
117
+ expect(init).toEqual({
118
+ headers: {
119
+ cookie: "__Secure-better-auth.session_token=sec.sig%3D",
120
+ origin: "https://app.example.com",
121
+ },
122
+ });
123
+ });
124
+
125
+ it("forwards the plain session cookie when it is the only one", async () => {
126
+ const init = await initFor(
127
+ "NEXT_LOCALE=en; better-auth.session_token=plain.sig; theme=dark",
128
+ );
129
+
130
+ expect(init).toEqual({
131
+ headers: { cookie: "better-auth.session_token=plain.sig" },
132
+ });
133
+ });
134
+
135
+ it("skips a session cookie with an empty value", async () => {
136
+ const init = await initFor(
137
+ "__Secure-better-auth.session_token=; better-auth.session_token=plain.sig",
138
+ );
139
+
140
+ expect(init.headers.cookie).toBe("better-auth.session_token=plain.sig");
141
+ });
142
+
143
+ it("skips a session cookie pair with no `=`", async () => {
144
+ const init = await initFor(
145
+ "__Secure-better-auth.session_token; better-auth.session_token=plain.sig",
146
+ );
147
+
148
+ expect(init.headers.cookie).toBe("better-auth.session_token=plain.sig");
149
+ });
150
+
151
+ it("forwards an empty cookie header when the jar holds no session cookie", async () => {
152
+ const init = await initFor(
153
+ "theme=dark; ailk-vid=v1; __Host-ailk-hub-session=SEALED; __Host-ailk-hub-flow=F",
154
+ );
155
+
156
+ expect(init).toEqual({ headers: { cookie: "" } });
157
+ });
158
+
159
+ it("never matches a look-alike cookie name", async () => {
160
+ const init = await initFor(
161
+ "Better-Auth.session_token=a; better-auth.session_token_x=b; xbetter-auth.session_token=c; __secure-better-auth.session_token=d",
162
+ );
163
+
164
+ expect(init.headers.cookie).toBe("");
165
+ });
166
+ });
102
167
  });
@@ -64,11 +64,32 @@ describe("services-path with services.path /capabilities", () => {
64
64
  const mapped = mod.withPublicServicesPaths(items);
65
65
  expect(mapped[0]?.path).toBe("/capabilities");
66
66
  expect(mapped[1]?.flyout?.features[0]?.path).toBe("/capabilities/x");
67
- expect(mapped[1]?.flyout?.actions[0]?.path).toBe("/capabilities");
67
+ expect(mapped[1]?.flyout?.actions?.[0]?.path).toBe("/capabilities");
68
68
  expect(mapped[2]?.path).toBe("/docs");
69
69
  expect(mapped[3]?.path).toBe("/servicesx");
70
70
  });
71
71
 
72
+ it("maps a flyout with no actions and adds none (#10047)", () => {
73
+ const items: NavItem[] = [
74
+ {
75
+ labelKey: "more",
76
+ flyout: {
77
+ features: [{ labelKey: "x", path: "/services/x" }],
78
+ groups: [
79
+ {
80
+ headingKey: "h",
81
+ items: [{ labelKey: "x", path: "/services/x" }],
82
+ },
83
+ ],
84
+ },
85
+ },
86
+ ];
87
+ const flyout = mod.withPublicServicesPaths(items)[0]?.flyout;
88
+ expect(flyout?.features[0]?.path).toBe("/capabilities/x");
89
+ expect(flyout?.groups?.[0]?.items[0]?.path).toBe("/capabilities/x");
90
+ expect(flyout).not.toHaveProperty("actions");
91
+ });
92
+
72
93
  it("maps a footer item", () => {
73
94
  const columns = [
74
95
  {
@@ -290,3 +290,80 @@ describe("siteLogo() — brand.logomark (#6820)", () => {
290
290
  expect(() => siteLogo()).toThrow(/alt/);
291
291
  });
292
292
  });
293
+
294
+ // #11456 D4 — the async brand. The hub read is doubled at its own module
295
+ // (`readHubSite`, whose HTTP and cache edges `hub-site-config.test.ts` pins).
296
+ describe("resolveSiteBrand() (#11456 D4)", () => {
297
+ const mockReadHubSite = jest.fn();
298
+ beforeEach(() => {
299
+ process.env.AILK_CONTENT_ROOT = tmpRoot;
300
+ delete process.env.NEXT_PUBLIC_SITE_NAME;
301
+ writeSiteMdx(tmpRoot, { siteName: "File Site", baseUrl: "https://file.example" });
302
+ mockReadHubSite.mockReset();
303
+ // The hub read is the HTTP boundary; its own suite pins it.
304
+ jest.doMock("../hub-site-config", () => ({ readHubSite: () => mockReadHubSite() }));
305
+ });
306
+ afterEach(() => {
307
+ jest.dontMock("../hub-site-config");
308
+ });
309
+
310
+ const hub = (identity: unknown, seo: unknown = null) =>
311
+ mockReadHubSite.mockResolvedValue({ identity, seo });
312
+
313
+ it("with no hub site, answers the module's constants and indexable", async () => {
314
+ mockReadHubSite.mockResolvedValue(undefined);
315
+ const brand = await loadSiteBrand();
316
+ await expect(brand.resolveSiteBrand()).resolves.toEqual({
317
+ siteName: brand.SITE_NAME,
318
+ description: brand.SITE_DESCRIPTION,
319
+ copyrightHolder: brand.COPYRIGHT_HOLDER,
320
+ indexable: true,
321
+ });
322
+ });
323
+
324
+ it("a hub identity with no description takes the seo row's, never the file's", async () => {
325
+ hub(
326
+ { kind: "Organization", name: "Hub Co", url: "https://hub.example" },
327
+ { version: "1", description: "Seo description." },
328
+ );
329
+ const { resolveSiteBrand } = await loadSiteBrand();
330
+ await expect(resolveSiteBrand()).resolves.toEqual({
331
+ siteName: "Hub Co",
332
+ description: "Seo description.",
333
+ copyrightHolder: "Hub Co",
334
+ indexable: true,
335
+ });
336
+ });
337
+
338
+ it("collapses control and line-separator runs in hub values to one space", async () => {
339
+ hub({
340
+ kind: "Organization",
341
+ name: "A\n\u2028\u202eB\u200b",
342
+ legalName: "Legal\r\nCo",
343
+ description: "Line\tone\u2029two",
344
+ url: "https://hub.example",
345
+ });
346
+ const { resolveSiteBrand } = await loadSiteBrand();
347
+ await expect(resolveSiteBrand()).resolves.toMatchObject({
348
+ siteName: "A B",
349
+ copyrightHolder: "Legal Co",
350
+ description: "Line one two",
351
+ });
352
+ });
353
+
354
+ it("NEXT_PUBLIC_SITE_NAME still wins the hub name", async () => {
355
+ process.env.NEXT_PUBLIC_SITE_NAME = "Env Name";
356
+ hub({ kind: "Organization", name: "Hub Co", url: "https://hub.example" });
357
+ const { resolveSiteBrand } = await loadSiteBrand();
358
+ await expect(resolveSiteBrand()).resolves.toMatchObject({ siteName: "Env Name" });
359
+ });
360
+
361
+ it("indexable reads the seo row even with no identity row", async () => {
362
+ hub(null, { version: "1", robots: { index: false } });
363
+ const brand = await loadSiteBrand();
364
+ await expect(brand.resolveSiteBrand()).resolves.toMatchObject({
365
+ siteName: brand.SITE_NAME,
366
+ indexable: false,
367
+ });
368
+ });
369
+ });
@@ -8,6 +8,12 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { tmpdir } from "node:os";
9
9
  import { join } from "node:path";
10
10
 
11
+ // #11456 D4 — the held hub value, `undefined` (no hub connection) unless a
12
+ // case sets one; the hub read itself is pinned in `hub-site-config.test.ts`.
13
+ const mockHeldHubSite = jest.fn((): unknown => undefined);
14
+ // eslint-disable-next-line no-restricted-syntax -- the held hub value stands in for the hub read, an HTTP boundary
15
+ jest.mock("../hub-site-config", () => ({ heldHubSite: () => mockHeldHubSite() }));
16
+
11
17
  import { readSiteContactLines } from "../site-contact-lines";
12
18
 
13
19
  let root: string;
@@ -210,3 +216,61 @@ describe("readSiteContactLines(locality) — the site's own locality line (#1055
210
216
  ]);
211
217
  });
212
218
  });
219
+
220
+ describe("readSiteContactLines on a hub-connected site (#11456 D4)", () => {
221
+ afterEach(() => mockHeldHubSite.mockReset().mockReturnValue(undefined));
222
+
223
+ it("takes the locality and email from the held hub identity, never the file's", () => {
224
+ writeSite(
225
+ [
226
+ "siteName: Acme",
227
+ "contactEmail: file@acme.test",
228
+ "siteIdentity:",
229
+ " kind: LocalBusiness",
230
+ " name: Acme",
231
+ " url: https://acme.test",
232
+ " telephone: '+14155550100'",
233
+ ...addressYaml(" ", "San Francisco", "CA"),
234
+ ].join("\n"),
235
+ );
236
+ mockHeldHubSite.mockReturnValue({
237
+ identity: {
238
+ kind: "Person",
239
+ name: "Hub Person",
240
+ url: "https://hub.example",
241
+ email: "hub@hub.example",
242
+ address: {
243
+ streetAddress: "1 Hub St",
244
+ addressLocality: "Hubton",
245
+ addressRegion: "HB",
246
+ postalCode: "00001",
247
+ addressCountry: "US",
248
+ },
249
+ },
250
+ seo: null,
251
+ });
252
+ expect(readSiteContactLines()).toEqual([
253
+ { label: "Hubton, HB" },
254
+ { label: "hub@hub.example", href: "mailto:hub@hub.example" },
255
+ ]);
256
+ });
257
+
258
+ it("a hub Organization identity has no locality line, whatever the file declares", () => {
259
+ writeSite(
260
+ [
261
+ "siteName: Acme",
262
+ "siteIdentity:",
263
+ " kind: LocalBusiness",
264
+ " name: Acme",
265
+ " url: https://acme.test",
266
+ " telephone: '+14155550100'",
267
+ ...addressYaml(" ", "San Francisco", "CA"),
268
+ ].join("\n"),
269
+ );
270
+ mockHeldHubSite.mockReturnValue({
271
+ identity: { kind: "Organization", name: "Hub Co", url: "https://hub.example" },
272
+ seo: null,
273
+ });
274
+ expect(readSiteContactLines()).toEqual([]);
275
+ });
276
+ });