create-ailk 0.47.0 → 0.48.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.
- package/README.md +192 -43
- package/component-catalog.json +223 -285
- package/component-catalog.md +1 -1
- package/dist/apply-design.d.ts +26 -68
- package/dist/apply-design.js +150 -322
- package/dist/cli.js +152 -17
- package/dist/compare-chrome.d.ts +108 -0
- package/dist/compare-chrome.js +481 -0
- package/dist/compare-look.d.ts +94 -0
- package/dist/compare-look.js +378 -0
- package/dist/copy.js +1 -1
- package/dist/design-compile.d.ts +17 -21
- package/dist/design-compile.js +32 -56
- package/dist/design-files.d.ts +93 -0
- package/dist/design-files.js +312 -0
- package/dist/design-home.d.ts +4 -2
- package/dist/design-home.js +88 -6
- package/dist/design-names.d.ts +13 -0
- package/dist/design-names.js +76 -0
- package/dist/design-package.d.ts +46 -56
- package/dist/design-package.js +285 -288
- package/dist/design-presets.d.ts +41 -0
- package/dist/design-presets.js +83 -4
- package/dist/design-scaffold.d.ts +12 -2
- package/dist/design-scaffold.js +72 -34
- package/dist/generated/design-settings.d.ts +56 -0
- package/dist/generated/design-settings.js +237 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/inventory.d.ts +3 -2
- package/dist/inventory.js +10 -4
- package/dist/lib/design-checks.d.ts +46 -0
- package/dist/lib/design-checks.js +79 -1
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/module-license-gate.d.ts +1 -1
- package/dist/lib/module-license-gate.js +1 -1
- package/dist/lib/render-verdict.d.ts +13 -1
- package/dist/lib/render-verdict.js +41 -1
- package/dist/look-hub.d.ts +44 -0
- package/dist/look-hub.js +130 -0
- package/dist/look-record.d.ts +35 -0
- package/dist/look-record.js +85 -0
- package/dist/look-samples.d.ts +66 -0
- package/dist/look-samples.js +456 -0
- package/dist/look-settings.d.ts +53 -0
- package/dist/look-settings.js +807 -0
- package/dist/module-architecture.js +12 -0
- package/dist/parse-args.d.ts +10 -6
- package/dist/parse-args.js +26 -13
- package/dist/programmatic.d.ts +1 -19
- package/dist/programmatic.js +65 -103
- package/dist/retired-design-bodies.d.ts +29 -0
- package/dist/retired-design-bodies.js +51 -0
- package/dist/seed-flows.d.ts +1 -1
- package/dist/seed-flows.js +12 -14
- package/dist/seed-workspace.d.ts +4 -1
- package/dist/seed-workspace.js +139 -17
- package/dist/site-chrome.d.ts +42 -41
- package/dist/site-chrome.js +51 -70
- package/dist/site-fonts.d.ts +14 -14
- package/dist/site-fonts.js +9 -4
- package/dist/starter-grid.d.ts +2 -2
- package/dist/strip-look-copies.d.ts +67 -0
- package/dist/strip-look-copies.js +591 -0
- package/dist/template-manifest.d.ts +6 -14
- package/dist/template-manifest.js +0 -9
- package/dist/template-record.d.ts +3 -1
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +15 -0
- package/dist/topology.js +60 -0
- package/dist/update.d.ts +57 -1
- package/dist/update.js +742 -13
- package/package.json +3 -4
- package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/designs/minimalism/DESIGN.md +163 -297
- package/site-templates/designs/minimalism/LOOK.md +42 -0
- package/site-templates/designs/minimalism/design.yaml +167 -0
- package/site-templates/designs/standard/DESIGN.md +145 -149
- package/site-templates/designs/standard/LOOK.md +42 -0
- package/site-templates/designs/standard/design.yaml +72 -0
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/content/_site.mdx +0 -26
- package/templates/.claude/rules/extending.md +3 -2
- package/templates/.env.example +11 -4
- package/templates/CLAUDE.md +1 -1
- package/templates/DESIGN.md +145 -149
- package/templates/README.md +15 -16
- package/templates/apps/api/.env.example +11 -4
- package/templates/apps/api/CLAUDE.md +6 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -5
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +10 -3
- package/templates/apps/web/CLAUDE.md +14 -3
- package/templates/apps/web/app/[locale]/layout.tsx +53 -50
- package/templates/apps/web/app/not-found.tsx +11 -11
- package/templates/apps/web/auth.ts +48 -35
- package/templates/apps/web/jest.config.cjs +5 -0
- package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +179 -31
- package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
- package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +71 -32
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
- package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
- package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
- package/templates/apps/web/lib/deck-page.ts +3 -10
- package/templates/apps/web/lib/deploy-fonts.ts +12 -0
- package/templates/apps/web/lib/hub-site-config.ts +97 -14
- package/templates/apps/web/lib/library-fonts.ts +41 -0
- package/templates/apps/web/lib/mcp-oauth.ts +11 -4
- package/templates/apps/web/lib/page-chrome.ts +52 -34
- package/templates/apps/web/lib/section-look.ts +28 -0
- package/templates/apps/web/lib/site-design.ts +205 -0
- package/templates/apps/web/lib/site-theme-head.ts +98 -13
- package/templates/apps/web/lib/site-theme.ts +40 -62
- package/templates/apps/web/messages/en.json +0 -6
- package/templates/apps/web/next.config.mjs +195 -6
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +4 -2
- package/templates/content/_site.mdx +0 -26
- package/templates/design.yaml +75 -0
- package/templates/project.yaml +14 -0
- package/versions.json +52 -51
- package/site-templates/marketing-site/DESIGN.md +0 -259
- package/site-templates/marketing-site-free/DESIGN.md +0 -259
- package/site-templates/saas-product/DESIGN.md +0 -259
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
- package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
- package/templates/apps/web/lib/site-chrome.ts +0 -46
- package/templates/apps/web/lib/site-fonts.ts +0 -15
|
@@ -74,6 +74,11 @@ module.exports = {
|
|
|
74
74
|
// Map all *.css to an empty stub — layout.tsx imports ./globals.css (#4090 item 1)
|
|
75
75
|
// and CSS is not parseable by ts-jest's CommonJS transform (apps-paid/marketing-web precedent, #1531).
|
|
76
76
|
"\\.css$": "<rootDir>/__tests__/__mocks__/style-mock.js",
|
|
77
|
+
// next/font is compiled by Next's SWC transform; outside it the loaders
|
|
78
|
+
// are not functions. Next's own jest stub answers `{ className, variable,
|
|
79
|
+
// style }` for any call — `lib/library-fonts.ts` (#12473 D6) and a
|
|
80
|
+
// generated `lib/site-fonts.ts` that sources a face both load through it.
|
|
81
|
+
"^next/font/(.*)$": "next/dist/build/jest/__mocks__/nextFontMock.js",
|
|
77
82
|
"^@working-theory/page-renderer/testing$":
|
|
78
83
|
"<rootDir>/node_modules/@working-theory/page-renderer/dist/testing.js",
|
|
79
84
|
"^@working-theory/page-renderer$":
|
|
@@ -193,7 +193,7 @@ describe("readHubSite (#11456 D3, AC-3)", () => {
|
|
|
193
193
|
it("with a spoke key and CONTENT_ADAPTER unset reads the hub (#11515)", async () => {
|
|
194
194
|
hubConnect();
|
|
195
195
|
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO }));
|
|
196
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
196
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
197
197
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
198
198
|
});
|
|
199
199
|
|
|
@@ -201,7 +201,7 @@ describe("readHubSite (#11456 D3, AC-3)", () => {
|
|
|
201
201
|
hubConnect();
|
|
202
202
|
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO }));
|
|
203
203
|
|
|
204
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
204
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
205
205
|
|
|
206
206
|
expect(mockUnstableCache).toHaveBeenCalledTimes(1);
|
|
207
207
|
const [, keyParts, options] = mockUnstableCache.mock.calls[0]!;
|
|
@@ -228,7 +228,7 @@ describe("readHubSite (#11456 D3, AC-3)", () => {
|
|
|
228
228
|
mockGet.mockResolvedValue(
|
|
229
229
|
ok({ identity: { kind: "Organization", name: "" }, seo: { version: "1", robots: { index: "no" } } }),
|
|
230
230
|
);
|
|
231
|
-
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null });
|
|
231
|
+
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null, design: null });
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
it.each([
|
|
@@ -272,7 +272,7 @@ describe("readHubSite — a spoke's read is unchanged (#12390 AC-5)", () => {
|
|
|
272
272
|
mockCacheStore.clear(); // a purged tag: the next read misses
|
|
273
273
|
mockGet.mockReset().mockResolvedValue({ ok: false, status: 401, body: {} });
|
|
274
274
|
|
|
275
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
275
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
276
276
|
expect(mockCacheStore.size).toBe(0);
|
|
277
277
|
expect(refusalWarns()).toHaveLength(0);
|
|
278
278
|
|
|
@@ -289,7 +289,7 @@ describe("readHubSite — a spoke's read is unchanged (#12390 AC-5)", () => {
|
|
|
289
289
|
"ailk-hub-site-config",
|
|
290
290
|
"default",
|
|
291
291
|
createHash("sha256").update(KEY, "utf8").digest("hex").slice(0, 16),
|
|
292
|
-
"
|
|
292
|
+
"design1",
|
|
293
293
|
]);
|
|
294
294
|
});
|
|
295
295
|
});
|
|
@@ -300,20 +300,20 @@ describe("readHubSite — a keyless single-tenant site (#12390 D2, D3, AC-5)", (
|
|
|
300
300
|
mockGet.mockResolvedValue(
|
|
301
301
|
ok({ identity: HUB_IDENTITY, seo: { version: "1", robots: { index: "no" } } }),
|
|
302
302
|
);
|
|
303
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null });
|
|
303
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null, design: null });
|
|
304
304
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
305
|
-
expect(heldHubSite()).toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null });
|
|
305
|
+
expect(heldHubSite()).toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null, design: null });
|
|
306
306
|
});
|
|
307
307
|
|
|
308
308
|
it("a 401 resolves no rows from inside the cached callback, so a later request makes no second call; one warn", async () => {
|
|
309
309
|
keylessConnect();
|
|
310
310
|
mockGet.mockResolvedValue({ ok: false, status: 401, body: {} });
|
|
311
311
|
|
|
312
|
-
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null });
|
|
312
|
+
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null, design: null });
|
|
313
313
|
expect(mockCacheStore.size).toBe(1);
|
|
314
|
-
expect([...mockCacheStore.values()]).toEqual([{ identity: null, seo: null, navigation: null }]);
|
|
314
|
+
expect([...mockCacheStore.values()]).toEqual([{ identity: null, seo: null, navigation: null, design: null }]);
|
|
315
315
|
|
|
316
|
-
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null });
|
|
316
|
+
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null, design: null });
|
|
317
317
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
318
318
|
expect(refusalWarns()).toHaveLength(1);
|
|
319
319
|
expect(String(refusalWarns()[0]![0])).toContain("_site.mdx");
|
|
@@ -350,7 +350,7 @@ describe("readHubSite — a keyless single-tenant site (#12390 D2, D3, AC-5)", (
|
|
|
350
350
|
|
|
351
351
|
jest.advanceTimersByTime(1);
|
|
352
352
|
mockGet.mockReset().mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO }));
|
|
353
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
353
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
354
354
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
355
355
|
});
|
|
356
356
|
|
|
@@ -365,8 +365,8 @@ describe("readHubSite — a keyless single-tenant site (#12390 D2, D3, AC-5)", (
|
|
|
365
365
|
mockGet.mockReset();
|
|
366
366
|
fail();
|
|
367
367
|
|
|
368
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
369
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
368
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
369
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
370
370
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
371
371
|
expect(mockCacheStore.size).toBe(0);
|
|
372
372
|
});
|
|
@@ -394,7 +394,7 @@ describe("readHubSite — a keyless single-tenant site (#12390 D2, D3, AC-5)", (
|
|
|
394
394
|
keylessConnect();
|
|
395
395
|
process.env.AILK_SPOKE_KEY = "has a space";
|
|
396
396
|
mockGet.mockResolvedValue({ ok: false, status: 401, body: {} });
|
|
397
|
-
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null });
|
|
397
|
+
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null, design: null });
|
|
398
398
|
const [, keyParts] = mockUnstableCache.mock.calls[0]!;
|
|
399
399
|
expect(keyParts[2]).toMatch(/^keyless:/);
|
|
400
400
|
expect(keyParts[2]).not.toContain(
|
|
@@ -408,7 +408,7 @@ describe("readHubSite — a keyless single-tenant site (#12390 D2, D3, AC-5)", (
|
|
|
408
408
|
await readHubSite();
|
|
409
409
|
hubConnect();
|
|
410
410
|
mockGet.mockReset().mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO }));
|
|
411
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
411
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
412
412
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
413
413
|
});
|
|
414
414
|
});
|
|
@@ -492,18 +492,18 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
492
492
|
["a safe API address and no key", () => keylessConnect()],
|
|
493
493
|
])("with %s, a valid navigation resolves its version and record beside identity and seo", async (_label, connect) => {
|
|
494
494
|
connect();
|
|
495
|
-
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: NAV }));
|
|
496
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: NAV });
|
|
495
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: NAV, design: null }));
|
|
496
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: NAV, design: null });
|
|
497
497
|
expect(navWarns()).toHaveLength(0);
|
|
498
498
|
});
|
|
499
499
|
|
|
500
500
|
it.each([
|
|
501
501
|
["no navigation key (a hub older than #12400)", { identity: HUB_IDENTITY, seo: HUB_SEO }],
|
|
502
|
-
["navigation: null", { identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null }],
|
|
502
|
+
["navigation: null", { identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null }],
|
|
503
503
|
])("%s resolves navigation null with identity and seo as given, and no warning", async (_label, body) => {
|
|
504
504
|
hubConnect();
|
|
505
505
|
mockGet.mockResolvedValue(ok(body));
|
|
506
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
506
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
507
507
|
expect(navWarns()).toHaveLength(0);
|
|
508
508
|
});
|
|
509
509
|
|
|
@@ -514,7 +514,7 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
514
514
|
])("%s resolves navigation null with identity and seo kept, and one warning with no value in it", async (_label, navigation, field) => {
|
|
515
515
|
hubConnect();
|
|
516
516
|
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation }));
|
|
517
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null });
|
|
517
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
518
518
|
expect(navWarns()).toHaveLength(1);
|
|
519
519
|
const line = String(navWarns()[0]![0]);
|
|
520
520
|
expect(line).toBe(`[hub-site-config] navigation unreadable at ${field}; rendering the site's own navigation`);
|
|
@@ -532,7 +532,7 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
532
532
|
])("%s is refused: navigation null, identity kept, a warning naming the field's path", async (_label, target, field) => {
|
|
533
533
|
hubConnect();
|
|
534
534
|
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: { version: 2, record: withTarget(target) } }));
|
|
535
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null });
|
|
535
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: null, design: null });
|
|
536
536
|
expect(navWarns().map((call) => String(call[0]))).toEqual([
|
|
537
537
|
`[hub-site-config] navigation unreadable at ${field}; rendering the site's own navigation`,
|
|
538
538
|
]);
|
|
@@ -545,7 +545,7 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
545
545
|
header: { items: [{ kind: "link", label: { text: "Plans", byLocale: { secretvalue: "x" } }, target: { kind: "path", path: "/plans" } }] },
|
|
546
546
|
};
|
|
547
547
|
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: { version: 2, record } }));
|
|
548
|
-
await expect(readHubSite()).resolves.toMatchObject({ identity: HUB_IDENTITY, navigation: null });
|
|
548
|
+
await expect(readHubSite()).resolves.toMatchObject({ identity: HUB_IDENTITY, navigation: null, design: null });
|
|
549
549
|
const lines = navWarns().map((call) => String(call[0]));
|
|
550
550
|
expect(lines).toHaveLength(1);
|
|
551
551
|
expect(lines[0]).toContain("header.items.0.label.byLocale.*");
|
|
@@ -581,16 +581,16 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
581
581
|
|
|
582
582
|
it("after a good read, a rejected siteConfig.get resolves the earlier record", async () => {
|
|
583
583
|
hubConnect();
|
|
584
|
-
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV }));
|
|
584
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null }));
|
|
585
585
|
await readHubSite();
|
|
586
586
|
mockCacheStore.clear(); // a purged tag: the next read misses
|
|
587
587
|
mockGet.mockReset().mockRejectedValue(new TypeError("fetch failed"));
|
|
588
|
-
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: NAV });
|
|
588
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null });
|
|
589
589
|
});
|
|
590
590
|
|
|
591
591
|
it("after the purge, a new body's record is what resolves", async () => {
|
|
592
592
|
hubConnect();
|
|
593
|
-
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV }));
|
|
593
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null }));
|
|
594
594
|
await readHubSite();
|
|
595
595
|
const renamed = {
|
|
596
596
|
version: 4,
|
|
@@ -598,13 +598,13 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
598
598
|
};
|
|
599
599
|
mockGet.mockReset().mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: renamed }));
|
|
600
600
|
// The entry stands until the tag is purged.
|
|
601
|
-
await expect(readHubSite()).resolves.toMatchObject({ navigation: NAV });
|
|
601
|
+
await expect(readHubSite()).resolves.toMatchObject({ navigation: NAV, design: null });
|
|
602
602
|
mockCacheStore.clear();
|
|
603
603
|
await expect(readHubSite()).resolves.toMatchObject({ navigation: renamed });
|
|
604
604
|
});
|
|
605
605
|
|
|
606
606
|
it("with neither a key nor an address, siteConfig.get is never called", async () => {
|
|
607
|
-
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV }));
|
|
607
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null }));
|
|
608
608
|
await expect(readHubSite()).resolves.toBeUndefined();
|
|
609
609
|
expect(mockGet).not.toHaveBeenCalled();
|
|
610
610
|
});
|
|
@@ -612,10 +612,10 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
612
612
|
it("a keyless 401 resolves navigation null beside the other rows", async () => {
|
|
613
613
|
keylessConnect();
|
|
614
614
|
mockGet.mockResolvedValue({ ok: false, status: 401, body: {} });
|
|
615
|
-
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null });
|
|
615
|
+
await expect(readHubSite()).resolves.toEqual({ identity: null, seo: null, navigation: null, design: null });
|
|
616
616
|
});
|
|
617
617
|
|
|
618
|
-
it("an entry of
|
|
618
|
+
it("an entry of an old shape, under the key without the design1 part, is never served", async () => {
|
|
619
619
|
hubConnect();
|
|
620
620
|
const oldKey = [
|
|
621
621
|
"ailk-hub-site-config",
|
|
@@ -623,8 +623,156 @@ describe("readHubSite — the navigation record (#12401 D1, AC-1)", () => {
|
|
|
623
623
|
createHash("sha256").update(KEY, "utf8").digest("hex").slice(0, 16),
|
|
624
624
|
].join("|");
|
|
625
625
|
mockCacheStore.set(oldKey, { identity: HUB_IDENTITY, seo: null });
|
|
626
|
-
|
|
627
|
-
|
|
626
|
+
// #12470 — and the navigation-only shape, under its `nav1` part.
|
|
627
|
+
mockCacheStore.set(`${oldKey}|nav1`, { identity: HUB_IDENTITY, seo: null, navigation: null });
|
|
628
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null }));
|
|
629
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: null, navigation: NAV, design: null });
|
|
628
630
|
expect(mockGet).toHaveBeenCalledTimes(1);
|
|
629
631
|
});
|
|
630
632
|
});
|
|
633
|
+
|
|
634
|
+
// #12470 D7 — an older hub's navigation record may still carry the style keys.
|
|
635
|
+
describe("readHubSite — a navigation record from an older hub, with style keys (#12470 D7, AC-7)", () => {
|
|
636
|
+
it("renders its links: the three style keys are dropped before the parse, with no warning", async () => {
|
|
637
|
+
hubConnect();
|
|
638
|
+
const links = { version: "1", header: { items: [] }, footer: { columns: [] } };
|
|
639
|
+
const legacy = {
|
|
640
|
+
version: "1",
|
|
641
|
+
header: { items: [], style: "bare" },
|
|
642
|
+
footer: { columns: [], style: "closing" },
|
|
643
|
+
families: { blog: { header: "none" } },
|
|
644
|
+
};
|
|
645
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: null, navigation: { version: 5, record: legacy } }));
|
|
646
|
+
await expect(readHubSite()).resolves.toEqual({
|
|
647
|
+
identity: HUB_IDENTITY,
|
|
648
|
+
seo: null,
|
|
649
|
+
navigation: { version: 5, record: links },
|
|
650
|
+
design: null,
|
|
651
|
+
});
|
|
652
|
+
expect(jest.mocked(console.warn).mock.calls.some((call) => String(call[0]).includes("unreadable"))).toBe(false);
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// #12470 D7, D8, AC-7, AC-8 — the workspace's design record rides the same read.
|
|
657
|
+
describe("readHubSite — the design record (#12470 D7, D8, AC-7, AC-8)", () => {
|
|
658
|
+
const SETTINGS = {
|
|
659
|
+
name: "Standard",
|
|
660
|
+
version: 1,
|
|
661
|
+
description: "The standard design.",
|
|
662
|
+
colors: {
|
|
663
|
+
bg: "#ffffff",
|
|
664
|
+
fg: "#000000",
|
|
665
|
+
surface: "#ffffff",
|
|
666
|
+
"surface-secondary": "#ffffff",
|
|
667
|
+
border: "#000000",
|
|
668
|
+
"text-muted": "#333333",
|
|
669
|
+
brand: "#000000",
|
|
670
|
+
"fg-on-brand": "#ffffff",
|
|
671
|
+
accent: "#000000",
|
|
672
|
+
"bg-dark": "#000000",
|
|
673
|
+
"fg-dark": "#ffffff",
|
|
674
|
+
"surface-dark": "#000000",
|
|
675
|
+
"surface-secondary-dark": "#000000",
|
|
676
|
+
"border-dark": "#ffffff",
|
|
677
|
+
"text-muted-dark": "#cccccc",
|
|
678
|
+
"brand-dark": "#ffffff",
|
|
679
|
+
"fg-on-brand-dark": "#000000",
|
|
680
|
+
"accent-dark": "#ffffff",
|
|
681
|
+
},
|
|
682
|
+
layout: { nav: "full", footer: "columns", announcementBanner: false, home: "default" },
|
|
683
|
+
typography: { body: { fontSize: "1.125rem", fontWeight: 400, lineHeight: 1.5 } },
|
|
684
|
+
rounded: { button: "0.5rem" },
|
|
685
|
+
spacing: { section: "7rem" },
|
|
686
|
+
};
|
|
687
|
+
const DESIGN = {
|
|
688
|
+
version: "1",
|
|
689
|
+
from: { look: "standard", version: "1" },
|
|
690
|
+
changes: { colors: { bg: "#111111" } },
|
|
691
|
+
chrome: { header: "bare", footer: "closing", families: { blog: { header: "full" } } },
|
|
692
|
+
brand: { colors: { primary: "#112233" }, fonts: { primary: "Georgia, serif" } },
|
|
693
|
+
};
|
|
694
|
+
const LOOK = { name: "standard", version: "1", latest: "2", behind: true };
|
|
695
|
+
const WORKED_OUT = { ...SETTINGS, colors: { ...SETTINGS.colors, bg: "#111111" } };
|
|
696
|
+
const designWarns = () =>
|
|
697
|
+
jest.mocked(console.warn).mock.calls.filter((call) => String(call[0]).includes("design unreadable"));
|
|
698
|
+
const answer = (design: unknown) => ok({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design });
|
|
699
|
+
|
|
700
|
+
it("parses a valid design into { version, record, settings, look } beside the other rows", async () => {
|
|
701
|
+
hubConnect();
|
|
702
|
+
mockGet.mockResolvedValue(answer({ version: 2, record: DESIGN, settings: WORKED_OUT, look: LOOK }));
|
|
703
|
+
await expect(readHubSite()).resolves.toEqual({
|
|
704
|
+
identity: HUB_IDENTITY,
|
|
705
|
+
seo: HUB_SEO,
|
|
706
|
+
navigation: null,
|
|
707
|
+
design: { version: 2, record: DESIGN, settings: WORKED_OUT, look: LOOK },
|
|
708
|
+
});
|
|
709
|
+
expect(designWarns()).toHaveLength(0);
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
it("a record with no library look reads settings and look null, and a hub that sends neither key reads them null", async () => {
|
|
713
|
+
hubConnect();
|
|
714
|
+
const own = { version: "1", from: null, chrome: { footer: "centered" } };
|
|
715
|
+
mockGet.mockResolvedValue(answer({ version: 1, record: own }));
|
|
716
|
+
await expect(readHubSite()).resolves.toMatchObject({ design: { version: 1, record: own, settings: null, look: null } });
|
|
717
|
+
expect(designWarns()).toHaveLength(0);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
it.each([
|
|
721
|
+
["no design key (a hub older than #12470)", {}],
|
|
722
|
+
["design: null", { design: null }],
|
|
723
|
+
])("%s resolves design null, with no warning", async (_label, extra) => {
|
|
724
|
+
hubConnect();
|
|
725
|
+
mockGet.mockResolvedValue(ok({ identity: HUB_IDENTITY, seo: HUB_SEO, ...extra }));
|
|
726
|
+
await expect(readHubSite()).resolves.toMatchObject({ identity: HUB_IDENTITY, design: null });
|
|
727
|
+
expect(designWarns()).toHaveLength(0);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
it("a record carrying a top-level member the site does not render (as #12503 will add) still reads, without it", async () => {
|
|
731
|
+
hubConnect();
|
|
732
|
+
mockGet.mockResolvedValue(
|
|
733
|
+
answer({ version: 2, record: { ...DESIGN, direction: { mood: "calm" } }, settings: WORKED_OUT, look: LOOK }),
|
|
734
|
+
);
|
|
735
|
+
const read = await readHubSite();
|
|
736
|
+
expect(read?.design).toEqual({ version: 2, record: DESIGN, settings: WORKED_OUT, look: LOOK });
|
|
737
|
+
expect(read?.design?.record).not.toHaveProperty("direction");
|
|
738
|
+
expect(designWarns()).toHaveLength(0);
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
it.each([
|
|
742
|
+
["chrome", { record: { ...DESIGN, chrome: { ...DESIGN.chrome, sticky: true } }, settings: WORKED_OUT, look: LOOK }],
|
|
743
|
+
["brand", { record: { ...DESIGN, brand: { ...DESIGN.brand, palette: {} } }, settings: WORKED_OUT, look: LOOK }],
|
|
744
|
+
["settings", { record: DESIGN, settings: { ...WORKED_OUT, motion: "fast" }, look: LOOK }],
|
|
745
|
+
["look", { record: DESIGN, settings: WORKED_OUT, look: { ...LOOK, pinned: true } }],
|
|
746
|
+
])("an extra key inside %s makes design null with one masked-path warning; identity and seo read as before", async (_label, design) => {
|
|
747
|
+
hubConnect();
|
|
748
|
+
mockGet.mockResolvedValue(answer({ version: 2, ...design }));
|
|
749
|
+
await expect(readHubSite()).resolves.toEqual({ identity: HUB_IDENTITY, seo: HUB_SEO, navigation: null, design: null });
|
|
750
|
+
expect(designWarns()).toHaveLength(1);
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it("a record the schema refuses — a colour that could leave its declaration — resolves design null, warning once with no value", async () => {
|
|
754
|
+
hubConnect();
|
|
755
|
+
const bad = { ...DESIGN, brand: { colors: { primary: "red;}</style><script>" } } };
|
|
756
|
+
mockGet.mockResolvedValue(answer({ version: 2, record: bad, settings: null, look: null }));
|
|
757
|
+
await expect(readHubSite()).resolves.toMatchObject({ identity: HUB_IDENTITY, seo: HUB_SEO, design: null });
|
|
758
|
+
expect(designWarns()).toHaveLength(1);
|
|
759
|
+
expect(String(designWarns()[0]![0])).toContain("record.brand.colors.primary");
|
|
760
|
+
expect(String(designWarns()[0]![0])).not.toContain("script");
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
it("worked-out settings the schema refuses resolve design null, warning once with no value", async () => {
|
|
764
|
+
hubConnect();
|
|
765
|
+
const bad = { ...WORKED_OUT, colors: { ...WORKED_OUT.colors, bg: "#fff; } body {" } };
|
|
766
|
+
mockGet.mockResolvedValue(answer({ version: 2, record: DESIGN, settings: bad, look: LOOK }));
|
|
767
|
+
await expect(readHubSite()).resolves.toMatchObject({ design: null });
|
|
768
|
+
expect(designWarns()).toHaveLength(1);
|
|
769
|
+
expect(String(designWarns()[0]![0])).not.toContain("body {");
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
it("a version of 0 resolves design null with one warning", async () => {
|
|
773
|
+
hubConnect();
|
|
774
|
+
mockGet.mockResolvedValue(answer({ version: 0, record: DESIGN, settings: null, look: null }));
|
|
775
|
+
await expect(readHubSite()).resolves.toMatchObject({ design: null });
|
|
776
|
+
expect(designWarns()).toHaveLength(1);
|
|
777
|
+
});
|
|
778
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site's built library faces match the library's list (#12473 D6,
|
|
3
|
+
* AC-6): a family `LIBRARY_FONTS` names but no `next/font/local` call builds
|
|
4
|
+
* would read as `live` and render its fallback.
|
|
5
|
+
*
|
|
6
|
+
* `next/font/local` runs only under Next's compiler, so it is stubbed here
|
|
7
|
+
* with the class name next/font answers for each call's variable.
|
|
8
|
+
*/
|
|
9
|
+
import { LIBRARY_FONTS } from "@working-theory/theme";
|
|
10
|
+
|
|
11
|
+
jest.mock("next/font/local", () => ({
|
|
12
|
+
__esModule: true,
|
|
13
|
+
default: (options: { variable: string; preload?: boolean; display?: string }) => ({
|
|
14
|
+
className: `cls${options.variable}`,
|
|
15
|
+
variable: `var${options.variable}`,
|
|
16
|
+
style: { fontFamily: options.variable },
|
|
17
|
+
}),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
import { LIBRARY_FACES } from "../library-fonts";
|
|
21
|
+
|
|
22
|
+
describe("LIBRARY_FACES (#12473 AC-6)", () => {
|
|
23
|
+
it("builds exactly the library's families", () => {
|
|
24
|
+
expect([...LIBRARY_FACES.keys()]).toEqual(LIBRARY_FONTS.map((font) => font.family));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("reads each face through --font-lib-<slug>, its class the one next/font declares it on", () => {
|
|
28
|
+
for (const { family, slug } of LIBRARY_FONTS) {
|
|
29
|
+
expect(LIBRARY_FACES.get(family)).toEqual({
|
|
30
|
+
variable: `--font-lib-${slug}`,
|
|
31
|
+
className: `var--font-lib-${slug}`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The hub
|
|
7
|
-
*
|
|
6
|
+
* The hub design record's `chrome` over `_site.mdx`'s styles (#12470 D7,
|
|
7
|
+
* AC-7; after #12401 D4, AC-6): style is the design record's, and applies
|
|
8
|
+
* whenever the hub read carries one, whether or not a navigation record
|
|
9
|
+
* renders.
|
|
8
10
|
*
|
|
9
|
-
* `
|
|
11
|
+
* `withDesignChrome` is pure; `resolveHomeChrome` reads the records
|
|
10
12
|
* through the hub read, so `@working-theory/api-client`'s `siteConfig.get`
|
|
11
13
|
* (the HTTP call to the hub) is doubled and `next/cache` runs the read
|
|
12
14
|
* uncached. `_site.mdx` is a scratch content root (`AILK_CONTENT_ROOT`).
|
|
@@ -35,13 +37,13 @@ jest.mock("@working-theory/templates/routes", () => {
|
|
|
35
37
|
};
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
import { siteNavigationSchema } from "@working-theory/validation";
|
|
40
|
+
import { siteDesignSchema, siteNavigationSchema } from "@working-theory/validation";
|
|
39
41
|
|
|
40
42
|
import { __resetHubSiteForTests } from "../hub-site-config";
|
|
41
43
|
import {
|
|
42
44
|
resolveHomeChrome,
|
|
43
45
|
resolvePageChrome,
|
|
44
|
-
|
|
46
|
+
withDesignChrome,
|
|
45
47
|
type SiteChromeSettings,
|
|
46
48
|
} from "../page-chrome";
|
|
47
49
|
|
|
@@ -55,21 +57,16 @@ const FILE: SiteChromeSettings = {
|
|
|
55
57
|
families: { portfolio: { footer: "none", path: "/writing-samples" } } as SiteChromeSettings["families"],
|
|
56
58
|
};
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 };
|
|
60
|
+
/** A design record of its chrome alone. */
|
|
61
|
+
const designWith = (chrome: object) => siteDesignSchema.parse({ version: "1", from: null, chrome });
|
|
62
|
+
const STYLED = designWith({ header: "bare", families: { portfolio: { header: "none" } } });
|
|
63
|
+
const NAVIGATION = siteNavigationSchema.parse({ version: "1", header: { items: [] }, footer: { columns: [] } });
|
|
64
|
+
const KNOBS = { nav: "full" as const, home: "default" as const, footer: "columns" as const };
|
|
68
65
|
|
|
69
|
-
describe("
|
|
66
|
+
describe("withDesignChrome (#12470 D7, AC-7)", () => {
|
|
70
67
|
it("lays the record's set styles over the file's, keeping the family's own path", () => {
|
|
71
68
|
const before = structuredClone(FILE);
|
|
72
|
-
expect(
|
|
69
|
+
expect(withDesignChrome(FILE, STYLED.chrome)).toEqual({
|
|
73
70
|
headerStyle: "bare",
|
|
74
71
|
footerStyle: "columns",
|
|
75
72
|
families: { portfolio: { header: "none", footer: "none", path: "/writing-samples" } },
|
|
@@ -77,24 +74,28 @@ describe("withNavigationStyles (#12401 D4, AC-6)", () => {
|
|
|
77
74
|
expect(FILE).toEqual(before);
|
|
78
75
|
});
|
|
79
76
|
|
|
80
|
-
it("a
|
|
77
|
+
it("a chrome setting no style answers the file settings unchanged", () => {
|
|
81
78
|
const before = structuredClone(FILE);
|
|
82
|
-
expect(
|
|
79
|
+
expect(withDesignChrome(FILE, {})).toEqual(FILE);
|
|
83
80
|
expect(FILE).toEqual(before);
|
|
84
81
|
});
|
|
85
82
|
|
|
86
83
|
it("a record style the file does not set is added; a style neither sets stays unset", () => {
|
|
87
|
-
const result =
|
|
84
|
+
const result = withDesignChrome({ families: {} }, designWith({ families: { blog: { footer: "closing" } } }).chrome);
|
|
88
85
|
expect(result).toEqual({ families: { blog: { footer: "closing" } } });
|
|
89
86
|
expect(result).not.toHaveProperty("headerStyle");
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
it("
|
|
93
|
-
expect(
|
|
89
|
+
it("the footer style alone is laid over the file's", () => {
|
|
90
|
+
expect(withDesignChrome(FILE, { footer: "closing" })).toEqual({ ...FILE, footerStyle: "closing" });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("chrome absent answers the file settings", () => {
|
|
94
|
+
expect(withDesignChrome(FILE, undefined)).toEqual(FILE);
|
|
94
95
|
});
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
describe("resolveHomeChrome with a hub-connected read (#
|
|
98
|
+
describe("resolveHomeChrome with a hub-connected read (#12470 D7, AC-7)", () => {
|
|
98
99
|
const ENV = ["AILK_SPOKE_KEY", "AILK_API_URL", "AILK_CONTENT_ROOT"] as const;
|
|
99
100
|
const saved = new Map(ENV.map((k) => [k, process.env[k]]));
|
|
100
101
|
let root: string;
|
|
@@ -121,12 +122,12 @@ describe("resolveHomeChrome with a hub-connected read (#12401 D4, AC-6)", () =>
|
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
124
|
|
|
124
|
-
it("resolves the home's header from the record, and a page's own frontmatter still wins", async () => {
|
|
125
|
+
it("resolves the home's header from the design record, and a page's own frontmatter still wins", async () => {
|
|
125
126
|
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
126
127
|
process.env.AILK_API_URL = "https://hub.example";
|
|
127
128
|
mockGet.mockResolvedValue({
|
|
128
129
|
ok: true,
|
|
129
|
-
body: { identity: null, seo: null, navigation: { version: 2, record: STYLED } },
|
|
130
|
+
body: { identity: null, seo: null, navigation: { version: 2, record: NAVIGATION }, design: { version: 1, record: STYLED, settings: null, look: null } },
|
|
130
131
|
});
|
|
131
132
|
|
|
132
133
|
const home = await resolveHomeChrome("en", KNOBS);
|
|
@@ -155,19 +156,59 @@ describe("resolveHomeChrome with a hub-connected read (#12401 D4, AC-6)", () =>
|
|
|
155
156
|
expect(mockGet).not.toHaveBeenCalled();
|
|
156
157
|
});
|
|
157
158
|
|
|
159
|
+
it("applies the design record's styles when the hub read carries a design record and no navigation record", async () => {
|
|
160
|
+
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
161
|
+
process.env.AILK_API_URL = "https://hub.example";
|
|
162
|
+
mockGet.mockResolvedValue({
|
|
163
|
+
ok: true,
|
|
164
|
+
body: { identity: null, seo: null, navigation: null, design: { version: 1, record: STYLED, settings: null, look: null } },
|
|
165
|
+
});
|
|
166
|
+
const home = await resolveHomeChrome("en", KNOBS);
|
|
167
|
+
expect(home.navigation).toBeNull();
|
|
168
|
+
expect(home.chrome.header).toBe("bare");
|
|
169
|
+
expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("a design record's mark-only header resolves the home's header mark-only (AC-14)", async () => {
|
|
173
|
+
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
174
|
+
process.env.AILK_API_URL = "https://hub.example";
|
|
175
|
+
mockGet.mockResolvedValue({
|
|
176
|
+
ok: true,
|
|
177
|
+
body: {
|
|
178
|
+
identity: null,
|
|
179
|
+
seo: null,
|
|
180
|
+
navigation: null,
|
|
181
|
+
design: { version: 1, record: designWith({ header: "mark-only" }), settings: null, look: null },
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
const home = await resolveHomeChrome("en", KNOBS);
|
|
185
|
+
expect(home.chrome.header).toBe("mark-only");
|
|
186
|
+
expect(home.site.headerStyle).toBe("mark-only");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("an older hub's navigation still carrying styles lays none: style is the design record's", async () => {
|
|
190
|
+
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
191
|
+
process.env.AILK_API_URL = "https://hub.example";
|
|
192
|
+
const legacy = { version: "1", header: { items: [], style: "bare" }, footer: { columns: [], style: "none" } };
|
|
193
|
+
mockGet.mockResolvedValue({ ok: true, body: { identity: null, seo: null, navigation: { version: 2, record: legacy } } });
|
|
194
|
+
const home = await resolveHomeChrome("en", KNOBS);
|
|
195
|
+
expect(home.navigation?.version).toBe(2);
|
|
196
|
+
expect(home.chrome.header).toBe("full");
|
|
197
|
+
});
|
|
198
|
+
|
|
158
199
|
it("answers the rendered record with its version and translation", async () => {
|
|
159
200
|
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
160
201
|
process.env.AILK_API_URL = "https://hub.example";
|
|
161
202
|
mockGet.mockResolvedValue({
|
|
162
203
|
ok: true,
|
|
163
|
-
body: { identity: null, seo: null, navigation: { version: 2, record:
|
|
204
|
+
body: { identity: null, seo: null, navigation: { version: 2, record: NAVIGATION } },
|
|
164
205
|
});
|
|
165
206
|
const home = await resolveHomeChrome("en", KNOBS);
|
|
166
207
|
expect(home.navigation?.version).toBe(2);
|
|
167
208
|
expect(home.navigation?.chrome.navItems).toEqual([]);
|
|
168
209
|
});
|
|
169
210
|
|
|
170
|
-
it("a record the translator refuses
|
|
211
|
+
it("a navigation record the translator refuses renders the files' links, and the design record's styles still apply", async () => {
|
|
171
212
|
process.env.AILK_SPOKE_KEY = "ailk_spk_TESTKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
172
213
|
process.env.AILK_API_URL = "https://hub.example";
|
|
173
214
|
// A record the schema takes cannot fail the translator, so the refusal is
|
|
@@ -176,19 +217,17 @@ describe("resolveHomeChrome with a hub-connected read (#12401 D4, AC-6)", () =>
|
|
|
176
217
|
const refused = siteNavigationSchema.parse({
|
|
177
218
|
version: "1",
|
|
178
219
|
header: {
|
|
179
|
-
style: "bare",
|
|
180
220
|
items: [{ kind: "link", label: { text: "Audit" }, target: { kind: "page", address: { type: "Service", slug: "audit" } } }],
|
|
181
221
|
},
|
|
182
222
|
footer: { columns: [] },
|
|
183
|
-
families: { portfolio: { header: "none" } },
|
|
184
223
|
});
|
|
185
224
|
mockGet.mockResolvedValue({
|
|
186
225
|
ok: true,
|
|
187
|
-
body: { identity: null, seo: null, navigation: { version: 2, record: refused } },
|
|
226
|
+
body: { identity: null, seo: null, navigation: { version: 2, record: refused }, design: { version: 1, record: STYLED, settings: null, look: null } },
|
|
188
227
|
});
|
|
189
228
|
const home = await resolveHomeChrome("en", KNOBS);
|
|
190
229
|
expect(home.navigation).toBeNull();
|
|
191
|
-
expect(home.chrome.header).toBe("
|
|
192
|
-
expect(home.site.families.portfolio).toEqual({ footer: "none", path: "/writing-samples" });
|
|
230
|
+
expect(home.chrome.header).toBe("bare");
|
|
231
|
+
expect(home.site.families.portfolio).toEqual({ header: "none", footer: "none", path: "/writing-samples" });
|
|
193
232
|
});
|
|
194
233
|
});
|