create-ailk 0.46.1 → 0.46.3
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/component-catalog.json +389 -4
- package/component-catalog.md +9 -7
- package/dist/surfaces.js +1 -1
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +156 -2
- package/templates/apps/web/app/globals.css +12 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +4 -0
- package/templates/apps/web/app/llms.txt/route.ts +22 -0
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +4 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +43 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +170 -1
- package/templates/apps/web/lib/__tests__/magnet-addresses.test.ts +406 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +822 -4
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +383 -0
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +44 -0
- package/templates/apps/web/lib/in-page-magnet.ts +86 -9
- package/templates/apps/web/lib/magnet-addresses.ts +317 -0
- package/templates/apps/web/lib/offerings-pricing.ts +477 -40
- package/templates/apps/web/lib/paid-section-contracts.ts +41 -1
- package/templates/apps/web/lib/pricing-page.ts +248 -13
- package/templates/apps/web/lib/served-pages.ts +38 -1
- package/templates/apps/web/messages/en.json +2 -1
- package/templates/apps/web/site-pages.config.tsx +9 -0
- package/versions.json +50 -50
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tests for the site's magnet-address resolver (#12204, spec
|
|
7
|
+
* docs/specs/12204-an-owner-chosen-address-a-spec.md D2, D5, D6, D9):
|
|
8
|
+
*
|
|
9
|
+
* - AC-1 — an address the hub lists and nothing on the site claims serves its
|
|
10
|
+
* cover, walk, verify and results through the package's dispatcher, and the
|
|
11
|
+
* walk at an address is chrome-free while its cover is not;
|
|
12
|
+
* - AC-2 — a shadowed address is not served (so the forward, the sitemap and
|
|
13
|
+
* llms.txt never name it);
|
|
14
|
+
* - AC-4 — a keyless site reads nothing, an older hub's 404 is no address;
|
|
15
|
+
* - AC-5 — the table is the hub's, read again after 15 seconds with no
|
|
16
|
+
* rebuild, shared by concurrent reads, held on a failed read;
|
|
17
|
+
* - D2's drift test — every built-in route's first segment is reserved.
|
|
18
|
+
*
|
|
19
|
+
* Each case loads the module fresh (`jest.isolateModules`), so its 15-second
|
|
20
|
+
* table starts empty.
|
|
21
|
+
*/
|
|
22
|
+
import { readdirSync } from "node:fs";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
|
|
25
|
+
import { ROUTES } from "@working-theory/templates/routes";
|
|
26
|
+
import { MAGNET_ADDRESS_RESERVED_SEGMENTS } from "@working-theory/validation";
|
|
27
|
+
|
|
28
|
+
import { isMagnetWalkPath } from "../magnet-routes";
|
|
29
|
+
|
|
30
|
+
const mockAddresses = jest.fn();
|
|
31
|
+
const mockRedirect = jest.fn();
|
|
32
|
+
jest.mock("@working-theory/api-client", () => ({
|
|
33
|
+
flows: { addresses: (...args: unknown[]) => mockAddresses(...args) },
|
|
34
|
+
pages: { redirect: (...args: unknown[]) => mockRedirect(...args) },
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
const mockGetMdxSource = jest.fn();
|
|
38
|
+
jest.mock("@working-theory/page-renderer", () => ({
|
|
39
|
+
getMdxSource: (...args: unknown[]) => mockGetMdxSource(...args),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
let mockAdapterKind = "mdx";
|
|
43
|
+
jest.mock("@working-theory/content-adapters", () => ({
|
|
44
|
+
resolvedAdapterKind: () => mockAdapterKind,
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
jest.mock("@working-theory/web-i18n", () => ({
|
|
48
|
+
readLocales: () => ["en", "es"],
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
let mockStatics: string[] = [];
|
|
52
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: the route tree's reader, tested over real trees in served-pages.test.ts; pinned here so each case names its static segments
|
|
53
|
+
jest.mock("../served-pages", () => ({
|
|
54
|
+
staticFirstSegments: () => mockStatics,
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
const mockRenderMagnetAt = jest.fn(async (input: unknown) => ({
|
|
58
|
+
rendered: input,
|
|
59
|
+
}));
|
|
60
|
+
const mockMagnetMetadataAt = jest.fn(async (input: unknown) => ({
|
|
61
|
+
metadata: input,
|
|
62
|
+
}));
|
|
63
|
+
let mockPackage: object | null = {};
|
|
64
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated file (create-ailk writes it); this suite pins whether the package is carried
|
|
65
|
+
jest.mock("../paid-sections.generated", () => ({
|
|
66
|
+
loadUiSignalCollectors: async () => mockPackage,
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
type Mod = typeof import("../magnet-addresses");
|
|
70
|
+
|
|
71
|
+
function load(): Mod {
|
|
72
|
+
let mod!: Mod;
|
|
73
|
+
jest.isolateModules(() => {
|
|
74
|
+
mod = jest.requireActual<Mod>("../magnet-addresses");
|
|
75
|
+
});
|
|
76
|
+
return mod;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const AG = {
|
|
80
|
+
slug: "agency-application",
|
|
81
|
+
path: "/agencies/apply",
|
|
82
|
+
listed: true,
|
|
83
|
+
title: "Agency application",
|
|
84
|
+
purpose: "Answer a few questions to get a scored assessment.",
|
|
85
|
+
updatedAt: "2026-11-20T10:00:00.000Z",
|
|
86
|
+
};
|
|
87
|
+
const ONE = { ...AG, slug: "apply-now", path: "/apply", title: "Apply now" };
|
|
88
|
+
|
|
89
|
+
function table(...items: unknown[]) {
|
|
90
|
+
return { ok: true, body: { addresses: items } };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
mockAddresses.mockReset();
|
|
95
|
+
mockAddresses.mockResolvedValue(table(AG, ONE));
|
|
96
|
+
mockRedirect.mockReset();
|
|
97
|
+
mockRedirect.mockResolvedValue({ ok: false, status: 404, body: null });
|
|
98
|
+
mockGetMdxSource.mockReset();
|
|
99
|
+
mockGetMdxSource.mockResolvedValue(null);
|
|
100
|
+
mockRenderMagnetAt.mockClear();
|
|
101
|
+
mockMagnetMetadataAt.mockClear();
|
|
102
|
+
mockAdapterKind = "mdx";
|
|
103
|
+
mockStatics = ["about", "flows", "pricing"];
|
|
104
|
+
mockPackage = {
|
|
105
|
+
renderMagnetAt: mockRenderMagnetAt,
|
|
106
|
+
magnetMetadataAt: mockMagnetMetadataAt,
|
|
107
|
+
};
|
|
108
|
+
delete process.env.NEXT_PUBLIC_AILK_DOCS_PATH;
|
|
109
|
+
delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
110
|
+
process.env.NEXT_PUBLIC_DEFAULT_LOCALE = "en";
|
|
111
|
+
process.env.NEXT_PUBLIC_BASE_URL = "https://site.example";
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
afterEach(() => {
|
|
115
|
+
jest.useRealTimers();
|
|
116
|
+
delete process.env.NEXT_PUBLIC_DEFAULT_LOCALE;
|
|
117
|
+
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("magnetPageAt — AC-1 (D5, D6)", () => {
|
|
121
|
+
it.each([
|
|
122
|
+
[
|
|
123
|
+
["agencies", "apply"],
|
|
124
|
+
{},
|
|
125
|
+
{ slug: "agency-application", base: "/agencies/apply", rest: [] },
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
["agencies", "apply", "start"],
|
|
129
|
+
{},
|
|
130
|
+
{ slug: "agency-application", base: "/agencies/apply", rest: ["start"] },
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
["agencies", "apply", "verify"],
|
|
134
|
+
{ lead: "x", verify: "y" },
|
|
135
|
+
{ slug: "agency-application", base: "/agencies/apply", rest: ["verify"] },
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
["agencies", "apply", "results", "p1"],
|
|
139
|
+
{},
|
|
140
|
+
{
|
|
141
|
+
slug: "agency-application",
|
|
142
|
+
base: "/agencies/apply",
|
|
143
|
+
rest: ["results", "p1"],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
[["apply"], {}, { slug: "apply-now", base: "/apply", rest: [] }],
|
|
147
|
+
[
|
|
148
|
+
["apply", "start"],
|
|
149
|
+
{},
|
|
150
|
+
{ slug: "apply-now", base: "/apply", rest: ["start"] },
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
["apply", "results", "p1"],
|
|
154
|
+
{},
|
|
155
|
+
{ slug: "apply-now", base: "/apply", rest: ["results", "p1"] },
|
|
156
|
+
],
|
|
157
|
+
])(
|
|
158
|
+
"%j dispatches to the package",
|
|
159
|
+
async (segments, searchParams, expected) => {
|
|
160
|
+
const element = await load().magnetPageAt(segments, "en", searchParams);
|
|
161
|
+
expect(mockRenderMagnetAt).toHaveBeenCalledWith({
|
|
162
|
+
...expected,
|
|
163
|
+
locale: "en",
|
|
164
|
+
searchParams,
|
|
165
|
+
});
|
|
166
|
+
expect(element).toEqual({
|
|
167
|
+
rendered: { ...expected, locale: "en", searchParams },
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
it.each([
|
|
173
|
+
[["agencies", "apply", "other"]],
|
|
174
|
+
[["agencies"]],
|
|
175
|
+
[["agencies", "apply", "results"]],
|
|
176
|
+
[["agencies", "apply", "start", "x"]],
|
|
177
|
+
[["apply", "results", "p1", "x"]],
|
|
178
|
+
[["unknown"]],
|
|
179
|
+
])("%j is no magnet page", async (segments) => {
|
|
180
|
+
await expect(load().magnetPageAt(segments, "en", {})).resolves.toBeNull();
|
|
181
|
+
expect(mockRenderMagnetAt).not.toHaveBeenCalled();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("names the address as the cover's canonical, with the sitemap's locale prefix (D8, D9)", async () => {
|
|
185
|
+
const mod = load();
|
|
186
|
+
await mod.magnetMetadataAt(["agencies", "apply"], "en");
|
|
187
|
+
expect(mockMagnetMetadataAt).toHaveBeenLastCalledWith({
|
|
188
|
+
slug: "agency-application",
|
|
189
|
+
base: "/agencies/apply",
|
|
190
|
+
rest: [],
|
|
191
|
+
locale: "en",
|
|
192
|
+
canonical: "https://site.example/agencies/apply",
|
|
193
|
+
});
|
|
194
|
+
await mod.magnetMetadataAt(["agencies", "apply"], "es");
|
|
195
|
+
expect(mockMagnetMetadataAt).toHaveBeenLastCalledWith(
|
|
196
|
+
expect.objectContaining({
|
|
197
|
+
locale: "es",
|
|
198
|
+
canonical: "https://site.example/es/agencies/apply",
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
await expect(mod.magnetMetadataAt(["agencies"], "en")).resolves.toBeNull();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("serves no item the hub's contract refuses (NFR-4)", async () => {
|
|
205
|
+
mockAddresses.mockResolvedValue(
|
|
206
|
+
table(
|
|
207
|
+
{ ...AG, path: "//evil.example" },
|
|
208
|
+
{ ...ONE, path: "/Apply" },
|
|
209
|
+
{ ...ONE, slug: "x", extra: 1 },
|
|
210
|
+
),
|
|
211
|
+
);
|
|
212
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([]);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("keeps the walk at an address chrome-free and its cover in the chrome", () => {
|
|
216
|
+
expect(isMagnetWalkPath("/agencies/apply/start", ["en"])).toBe(true);
|
|
217
|
+
expect(isMagnetWalkPath("/apply/start", ["en"])).toBe(true);
|
|
218
|
+
expect(isMagnetWalkPath("/agencies/apply", ["en"])).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("answers the forward's address for a served magnet, null for any other (D7)", async () => {
|
|
222
|
+
const mod = load();
|
|
223
|
+
await expect(mod.servedAddressOf("agency-application", "en")).resolves.toBe(
|
|
224
|
+
"/agencies/apply",
|
|
225
|
+
);
|
|
226
|
+
await expect(mod.servedAddressOf("contact", "en")).resolves.toBeNull();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("servedAddresses — the shadow rule (D5 a–d, AC-2)", () => {
|
|
231
|
+
it("leaves out an address under a static route", async () => {
|
|
232
|
+
mockStatics = ["agencies"];
|
|
233
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([ONE]);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("leaves out an address under the docs base", async () => {
|
|
237
|
+
process.env.NEXT_PUBLIC_AILK_DOCS_PATH = "/agencies/docs";
|
|
238
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([ONE]);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("leaves out an address on a renamed family's segment", async () => {
|
|
242
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = JSON.stringify({
|
|
243
|
+
portfolio: "apply",
|
|
244
|
+
});
|
|
245
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([AG]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("leaves out an address whose first segment is a content page in that locale", async () => {
|
|
249
|
+
mockGetMdxSource.mockImplementation(
|
|
250
|
+
async (type: string, slug: string, locale: string) =>
|
|
251
|
+
type === "BlogList" && slug === "apply" && locale === "es"
|
|
252
|
+
? { frontmatter: {} }
|
|
253
|
+
: null,
|
|
254
|
+
);
|
|
255
|
+
const mod = load();
|
|
256
|
+
await expect(mod.servedAddresses("es")).resolves.toEqual([AG]);
|
|
257
|
+
await expect(mod.servedAddresses("en")).resolves.toEqual([AG, ONE]);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("leaves out a moved page's old address under the database adapter only", async () => {
|
|
261
|
+
mockRedirect.mockImplementation(async (path: string) =>
|
|
262
|
+
path === "/apply"
|
|
263
|
+
? { ok: true, body: { to: "/new" } }
|
|
264
|
+
: { ok: false, status: 404, body: null },
|
|
265
|
+
);
|
|
266
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([AG, ONE]);
|
|
267
|
+
expect(mockRedirect).not.toHaveBeenCalled();
|
|
268
|
+
mockAdapterKind = "database";
|
|
269
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([AG]);
|
|
270
|
+
expect(mockRedirect).toHaveBeenCalledWith("/apply", { locale: "en" });
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("probes only the table's first segments, once per window, never the requested path (SEC-12204-6)", async () => {
|
|
274
|
+
const mod = load();
|
|
275
|
+
await mod.magnetPageAt(["random", "path"], "en", {});
|
|
276
|
+
await mod.magnetPageAt(["agencies", "apply"], "en", {});
|
|
277
|
+
await mod.servedAddresses("en");
|
|
278
|
+
const probed = mockGetMdxSource.mock.calls.map(([, slug]) => slug);
|
|
279
|
+
expect(new Set(probed)).toEqual(new Set(["agencies", "apply"]));
|
|
280
|
+
expect(mockGetMdxSource).toHaveBeenCalledTimes(4);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe("readAddressTable — AC-4 (D14)", () => {
|
|
285
|
+
it("makes no read on a site without the signal-collectors package", async () => {
|
|
286
|
+
mockPackage = null;
|
|
287
|
+
const mod = load();
|
|
288
|
+
await expect(mod.servedAddresses("en")).resolves.toEqual([]);
|
|
289
|
+
await expect(
|
|
290
|
+
mod.magnetPageAt(["agencies", "apply"], "en", {}),
|
|
291
|
+
).resolves.toBeNull();
|
|
292
|
+
expect(mockAddresses).not.toHaveBeenCalled();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("reads an older hub's 404 as no address", async () => {
|
|
296
|
+
mockAddresses.mockResolvedValue({ ok: false, status: 404, body: null });
|
|
297
|
+
const mod = load();
|
|
298
|
+
await expect(mod.servedAddresses("en")).resolves.toEqual([]);
|
|
299
|
+
await expect(
|
|
300
|
+
mod.servedAddressOf("agency-application", "en"),
|
|
301
|
+
).resolves.toBeNull();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("never rejects when the client throws", async () => {
|
|
305
|
+
mockAddresses.mockRejectedValue(new Error("refused"));
|
|
306
|
+
await expect(load().servedAddresses("en")).resolves.toEqual([]);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it("a locale the site does not enable keys no computation and costs no hub read", async () => {
|
|
310
|
+
mockAddresses.mockResolvedValue(table(AG));
|
|
311
|
+
const mod = load();
|
|
312
|
+
await expect(mod.servedAddresses("x.1")).resolves.toEqual([]);
|
|
313
|
+
await expect(mod.servedAddressOf("agency-application", "x.2")).resolves.toBeNull();
|
|
314
|
+
await expect(mod.magnetPageAt(["agencies", "apply"], "x.3", {})).resolves.toBeNull();
|
|
315
|
+
expect(mockAddresses).not.toHaveBeenCalled();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe("readAddressTable — AC-5 (shared, refreshed, held)", () => {
|
|
320
|
+
it("reads the hub again after the window with no rebuild, and keeps the last good table on a failure", async () => {
|
|
321
|
+
jest.useFakeTimers();
|
|
322
|
+
const mod = load();
|
|
323
|
+
mockAddresses.mockResolvedValueOnce(table(AG));
|
|
324
|
+
await expect(mod.readAddressTable()).resolves.toEqual([AG]);
|
|
325
|
+
|
|
326
|
+
jest.advanceTimersByTime(16_000);
|
|
327
|
+
mockAddresses.mockResolvedValueOnce(table(ONE));
|
|
328
|
+
await expect(mod.readAddressTable()).resolves.toEqual([ONE]);
|
|
329
|
+
await expect(mod.servedAddresses("en")).resolves.toEqual([ONE]);
|
|
330
|
+
|
|
331
|
+
jest.advanceTimersByTime(16_000);
|
|
332
|
+
mockAddresses.mockResolvedValueOnce({ ok: false, status: 500, body: null });
|
|
333
|
+
await expect(mod.readAddressTable()).resolves.toEqual([ONE]);
|
|
334
|
+
|
|
335
|
+
jest.advanceTimersByTime(16_000);
|
|
336
|
+
mockAddresses.mockRejectedValueOnce(new Error("refused"));
|
|
337
|
+
await expect(mod.readAddressTable()).resolves.toEqual([ONE]);
|
|
338
|
+
expect(mockAddresses).toHaveBeenCalledTimes(4);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("shares one read across concurrent callers", async () => {
|
|
342
|
+
const mod = load();
|
|
343
|
+
await Promise.all([
|
|
344
|
+
mod.readAddressTable(),
|
|
345
|
+
mod.servedAddresses("en"),
|
|
346
|
+
mod.servedAddressOf("apply-now", "en"),
|
|
347
|
+
]);
|
|
348
|
+
expect(mockAddresses).toHaveBeenCalledTimes(1);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("holds a failed read for its window rather than retrying", async () => {
|
|
352
|
+
jest.useFakeTimers();
|
|
353
|
+
mockAddresses.mockResolvedValue({ ok: false, status: 503, body: null });
|
|
354
|
+
const mod = load();
|
|
355
|
+
await mod.readAddressTable();
|
|
356
|
+
jest.advanceTimersByTime(10_000);
|
|
357
|
+
await mod.readAddressTable();
|
|
358
|
+
expect(mockAddresses).toHaveBeenCalledTimes(1);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("counts a read with no answer within 5 seconds as failed", async () => {
|
|
362
|
+
jest.useFakeTimers();
|
|
363
|
+
mockAddresses.mockReturnValue(new Promise(() => {}));
|
|
364
|
+
const mod = load();
|
|
365
|
+
const read = mod.readAddressTable();
|
|
366
|
+
await jest.advanceTimersByTimeAsync(2_000);
|
|
367
|
+
await expect(read).resolves.toEqual([]);
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
describe("MAGNET_ADDRESS_RESERVED_SEGMENTS — the D2 drift test", () => {
|
|
372
|
+
const reserved = new Set(MAGNET_ADDRESS_RESERVED_SEGMENTS);
|
|
373
|
+
|
|
374
|
+
it("reserves every ROUTES first segment", () => {
|
|
375
|
+
const firsts = new Set(
|
|
376
|
+
ROUTES.map((row) => row.route.split("/")[1] ?? "").filter(
|
|
377
|
+
(segment) => segment !== "" && !segment.startsWith(":"),
|
|
378
|
+
),
|
|
379
|
+
);
|
|
380
|
+
expect([...firsts].filter((segment) => !reserved.has(segment))).toEqual([]);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("reserves every legacyRoutes source's first segment, which the site redirects", () => {
|
|
384
|
+
const firsts = new Set(
|
|
385
|
+
ROUTES.flatMap((row) => row.legacyRoutes ?? []).map((route) => route.split("/")[1] ?? ""),
|
|
386
|
+
);
|
|
387
|
+
expect(firsts.size).toBeGreaterThan(0);
|
|
388
|
+
expect([...firsts].filter((segment) => !reserved.has(segment))).toEqual([]);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it("reserves every static top-level route directory of the site, route groups opened", () => {
|
|
392
|
+
const localeDir = join(__dirname, "..", "..", "app", "[locale]");
|
|
393
|
+
const dirs = (dir: string): string[] =>
|
|
394
|
+
readdirSync(dir, { withFileTypes: true })
|
|
395
|
+
.filter((entry) => entry.isDirectory())
|
|
396
|
+
.flatMap((entry) =>
|
|
397
|
+
/^\(.*\)$/.test(entry.name)
|
|
398
|
+
? dirs(join(dir, entry.name))
|
|
399
|
+
: [entry.name],
|
|
400
|
+
)
|
|
401
|
+
.filter((name) => !/^[[_@]/.test(name));
|
|
402
|
+
const segments = dirs(localeDir);
|
|
403
|
+
expect(segments.length).toBeGreaterThan(10);
|
|
404
|
+
expect(segments.filter((segment) => !reserved.has(segment))).toEqual([]);
|
|
405
|
+
});
|
|
406
|
+
});
|