diff --git a/.agents/repo.md b/.agents/repo.md index 068b6d4ef4..4d99448901 100644 --- a/.agents/repo.md +++ b/.agents/repo.md @@ -111,27 +111,31 @@ declared inputs — test file ordering, wall-clock, a shared browser page — is cacheable, and the fix is the determinism, not the cache. Turbo's default source inputs cover a task's own workspace. A task that reads a file outside -it lists the file as a `$TURBO_ROOT$/…` input in its workspace's `turbo.json`; otherwise an -edit to that file alone replays the cached verdict. Keep `$TURBO_DEFAULT$` and any inherited -inputs (`$TURBO_EXTENDS$`) in that list: +it lists the file in its workspace's `turbo.json` `inputs`; otherwise an edit to that file +alone replays the cached verdict. Open the list with `$TURBO_EXTENDS$` (keeps the root task's +inputs, which a workspace list otherwise replaces) and `$TURBO_DEFAULT$` (keeps the workspace's +own files), then list the outside files as `$TURBO_ROOT$/`: - [`services/platform/turbo.json`](../services/platform/turbo.json) gives `@tale/platform`'s tests the catalogs under `configs/platform/`, compose files, tale-db init scripts, knowledge-db migrations and other outside files. Its guard is `services/platform/tests/guards/turbo-inputs.guard.test.ts`. - [`services/docs/turbo.json`](../services/docs/turbo.json) gives `@tale/docs` the root `docs/` - tree (test, build), its JSON maps (typecheck, lint) and the root `README*.md` (test). - Its guard is `services/docs/tests/turbo-inputs.test.ts`. + tree (test, build), its JSON maps (typecheck, lint), and the root `README*.md` plus `@tale/ui`'s + i18n catalogs and test framework (test). Its guard is `services/docs/tests/turbo-inputs.test.ts`. - [`tools/cli/turbo.json`](../tools/cli/turbo.json) gives `@tale/cli`'s tests the CLI install pages. Its guard is `tools/cli/src/lib/config/platform-docs.test.ts`. -These guards ask `turbo --dry=json` whether the files are hashed. A suite that starts reading -another outside file adds it to both the task's inputs and its guard. +These guards ask `turbo --dry=json` whether the files are hashed; the docs and CLI guards also +hold the two-entry prefix. A suite that starts reading another outside file adds it to both +the task's inputs and its guard. -Workspace-package sources remain a separate gap. An edit under `packages/` leaves every dependent workspace's `test`, -`typecheck` and `lint` hash unchanged, because none of those tasks depends on `^…` — the -services' i18n tests that read the `packages/ui` catalogs included. A package change is judged -only by that package's own tasks until the consumer's own files change. +Beyond such a declared file, an edit under `packages/` leaves every dependent workspace's +`test`, `typecheck` and `lint` hash unchanged, because none of those tasks depends on `^…`: a +package change is judged only by that package's own tasks until the consumer's own files +change. The i18n suites of `services/platform`, `services/web`, `services/ui-docs`, +`services/ai-gateway` and `packages/marketing-ui` are still in that gap: they run `@tale/ui`'s +i18n test framework (the first three also read the package catalogs) unhashed. ## Skills index diff --git a/services/docs/tests/AGENTS.md b/services/docs/tests/AGENTS.md index 466e3e59fa..8ba78bb07c 100644 --- a/services/docs/tests/AGENTS.md +++ b/services/docs/tests/AGENTS.md @@ -15,8 +15,9 @@ Run it after renaming, moving, or deleting a page; after editing [`docs/nav.json`](../../../docs/nav.json); after adding a page in one locale; after editing any heading (heading text → slug); after translating or rewriting a page; and before opening any PR that touches `docs/` or `services/docs/` (CI runs the same suite via `bunx turbo run test`; -[`../turbo.json`](../turbo.json) hashes `docs/` and the root READMEs, so a docs-only change -re-runs it instead of replaying the cached verdict). +[`../turbo.json`](../turbo.json) hashes `docs/`, the root READMEs and `@tale/ui`'s i18n catalogs +and test framework, so a change to any of them re-runs it instead of replaying the cached +verdict). ## Run it @@ -46,7 +47,7 @@ and asserts the list is empty — the failure prints each file once with offendi | Check (`*.test.ts`) | Catches → fix | | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `walk` | Harness sanity: walker finds pages, base locales `en`/`de`/`fr` present → if it trips the harness itself is broken (check `lib/paths.ts`, the tree). | -| `turbo-inputs` | A `@tale/docs` task (test, build, typecheck, lint) that reads a file outside `services/docs/` turbo does not hash, so a docs-only change would replay its cached result → add the `$TURBO_ROOT$/…` glob to [`../turbo.json`](../turbo.json), keeping `$TURBO_DEFAULT$`. | +| `turbo-inputs` | A `@tale/docs` task (test, build, typecheck, lint) that reads a file outside `services/docs/` turbo does not hash, so a docs-only change would replay its cached result → add the `$TURBO_ROOT$/…` glob to [`../turbo.json`](../turbo.json) after `$TURBO_EXTENDS$` and `$TURBO_DEFAULT$`, which open every list. | | `navigation` | A `docs/nav.json` slug with no `.md`/`.mdx` under a locale (renamed page, untranslated page, typo) → create the file or fix/remove the nav entry. | | `locale-tree` | An `en/` page with no DE/FR mirror, or a DE/FR orphan with no `en/` source → create the mirror or delete the orphan. | | `locale-outline` | DE/FR drifting from the EN page's heading-depth sequence or fenced-code-block count → restructure the locale page to match EN's outline. | diff --git a/services/docs/tests/manual/reference/automation.md b/services/docs/tests/manual/reference/automation.md index 4947b886b2..67b54418ea 100644 --- a/services/docs/tests/manual/reference/automation.md +++ b/services/docs/tests/manual/reference/automation.md @@ -26,7 +26,7 @@ Legend: ✅ fully automated · 🔶 partially automated · ⛔ manual-only (no s | [accessibility](../suites/accessibility.md) | `A11Y-A12` (one page title) | ✅ automated | `page-header.spec.ts` (one `h1`, in the article; the trail leaf is a plain current marker) + `tests/prerender/seo.test.ts` | | [accessibility](../suites/accessibility.md) | Full-page audits (`A11Y-A1`–`A11Y-A11`) | ⛔ manual-only | — this guide (the shared `ImageZoom`/`Video` components carry `vitest-axe` in `@tale/ui`) | | [content](../suites/content.md) | `CONT-F1` (source shape) | ✅ automated | vitest `structure-code.test.ts` (every fence declares a language), `structure-headings.test.ts`, `links.test.ts` | -| [content](../suites/content.md) | A docs-only change re-runs the structural suite and the docs build in CI instead of replaying a cached result | ✅ automated | vitest `turbo-inputs.test.ts` (asks `turbo --dry=json` that every page, `nav.json`, `redirects.json` and root README these tasks read is hashed) | +| [content](../suites/content.md) | A docs-only change re-runs the structural suite and the docs build in CI instead of replaying a cached result | ✅ automated | vitest `turbo-inputs.test.ts` (asks `turbo --dry=json` that every page, `nav.json`, `redirects.json`, root README and `@tale/ui` i18n catalog and framework file these tasks read is hashed) | | [content](../suites/content.md) | Local preview keeps the article body after a content edit or regenerated frontmatter | 🔶 unit | `lib/content/reload-content.test.ts` checks client full reload and module invalidation for content paths; editing a visible page in the dev server remains manual | | [content](../suites/content.md) | `CONT-F15`–`CONT-F16` (image sources) | 🔶 partial | vitest `images.test.ts` (paths resolve, alt text, size) + `image-manifest.test.ts` (manifest entry, page reference, DPR-2 dimensions) — rendered behaviour manual | | [content](../suites/content.md) | Frame captions and keyboard image zoom | ✅ automated | `@tale/ui` `frame.test.tsx` preserves captions, child images and following content through the real Markdown parser; `markdown.spec.ts` checks visible captions, zoom and Escape/focus restoration in EN/DE/FR. | diff --git a/services/docs/tests/turbo-inputs.test.ts b/services/docs/tests/turbo-inputs.test.ts index 4968f24efd..b4a3f80053 100644 --- a/services/docs/tests/turbo-inputs.test.ts +++ b/services/docs/tests/turbo-inputs.test.ts @@ -9,12 +9,13 @@ import { walkDocs } from './lib/walk'; /** * Turbo keys a task's cache on the files of its own workspace, and neither the - * content tree (`docs/`) nor the root READMEs belong to one — so a task that - * reads them replays its last verdict when only they change, and a broken - * page passes CI (a docs-only edit replayed `@tale/docs:test` from the cache). - * `services/docs/turbo.json` declares them as `$TURBO_ROOT$` inputs; this asks - * turbo itself (`--dry=json`) which files each task hashes, so an input list - * that misses a file the task reads fails here instead of replaying green. + * content tree (`docs/`), the root READMEs nor `@tale/ui`'s i18n framework + * belong to this one — so a task that reads them replays its last verdict when + * only they change, and a broken page passes CI (a docs-only edit replayed + * `@tale/docs:test` from the cache). `services/docs/turbo.json` declares them + * as `$TURBO_ROOT$` inputs; this asks turbo itself (`--dry=json`) which files + * each task hashes, so an input list that misses a file the task reads fails + * here instead of replaying green. * * A task that starts reading another file outside `services/docs/` lists it * in `turbo.json` and here. (`@tale/cli`'s tests read the CLI install pages; @@ -23,6 +24,34 @@ import { walkDocs } from './lib/walk'; const DATA_FILES = ['docs/nav.json', 'docs/redirects.json']; +/** `@tale/ui`'s i18n folder, repo-relative. */ +const UI_I18N = 'packages/ui/src/i18n'; + +/** Every file under a repo-relative directory, repo-relative and `/`-separated. */ +function filesUnder(dir: string): string[] { + const root = path.join(REPO_ROOT, dir); + return fs + .readdirSync(root, { recursive: true, encoding: 'utf8' }) + .filter((entry) => fs.statSync(path.join(root, entry)).isFile()) + .map((entry) => toPosix(path.join(dir, entry))); +} + +/** + * What the i18n suites load from `@tale/ui`: `lib/i18n/messages.test.ts` + * resolves the service's `docs.*` keys against the package catalogs + * (`packageCatalogs`), and it and `docs.test.ts` run the shared framework + * (`@tale/ui/i18n/tests` — its checks, per-locale rule data and glossary). + */ +function uiI18nFiles(): string[] { + const catalogs = filesUnder(`${UI_I18N}/messages`).filter((file) => + file.endsWith('.yml'), + ); + const framework = filesUnder(`${UI_I18N}/tests`).filter( + (file) => !/\.test\.tsx?$/.test(file), + ); + return [...catalogs, ...framework]; +} + /** Every page the structural suite walks, plus the nav and redirect maps. */ function contentFiles(): string[] { return [ @@ -39,8 +68,8 @@ function rootReadmes(): string[] { const READERS: { task: string; why: string; reads: () => string[] }[] = [ { task: 'test', - why: 'the structural suite, the i18n docs scan and the README parity check', - reads: () => [...contentFiles(), ...rootReadmes()], + why: 'the structural suite, the i18n suites and the README parity check', + reads: () => [...contentFiles(), ...rootReadmes(), ...uiI18nFiles()], }, { task: 'build', @@ -83,10 +112,19 @@ function hashedByTask(): Map> { ], { cwd: REPO_ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }, ); + if (run.error) { + throw new Error(`turbo --dry=json did not run: ${run.error.message}`, { + cause: run.error, + }); + } if (run.status !== 0) { throw new Error(`turbo --dry=json exited ${run.status}: ${run.stderr}`); } - const { tasks } = JSON.parse(run.stdout.slice(run.stdout.indexOf('{'))) as { + const start = run.stdout.indexOf('{'); + if (start === -1) { + throw new Error(`turbo --dry=json printed no JSON: ${run.stdout}`); + } + const { tasks } = JSON.parse(run.stdout.slice(start)) as { tasks: DryRunTask[]; }; return new Map( @@ -110,6 +148,23 @@ describe('turbo inputs', () => { hashed = hashedByTask(); }, 60_000); + it('every input list keeps the root task inputs and the workspace sources', () => { + // A workspace `inputs` list replaces the root task's instead of adding to + // it; `$TURBO_EXTENDS$` keeps the root's, `$TURBO_DEFAULT$` the workspace's + // own files. + const { tasks } = JSON.parse( + fs.readFileSync(path.join(REPO_ROOT, 'services/docs/turbo.json'), 'utf8'), + ) as { tasks: Record }; + const lists = Object.entries(tasks).filter(([, { inputs }]) => inputs); + expect(lists.length).toBeGreaterThan(0); + for (const [task, { inputs }] of lists) { + expect(inputs?.slice(0, 2), `services/docs/turbo.json ${task}`).toEqual([ + '$TURBO_EXTENDS$', + '$TURBO_DEFAULT$', + ]); + } + }); + for (const { task, why, reads } of READERS) { it(`@tale/docs#${task} hashes every file it reads outside the workspace`, () => { const inputs = hashed.get(`@tale/docs#${task}`) ?? new Set(); diff --git a/services/docs/turbo.json b/services/docs/turbo.json index c37f95d364..9b9f6f15f5 100644 --- a/services/docs/turbo.json +++ b/services/docs/turbo.json @@ -4,19 +4,30 @@ "tasks": { "test": { "inputs": [ + "$TURBO_EXTENDS$", "$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/**", - "$TURBO_ROOT$/README*.md" + "$TURBO_ROOT$/README*.md", + "$TURBO_ROOT$/packages/ui/src/i18n/messages/*.yml", + "$TURBO_ROOT$/packages/ui/src/i18n/tests/**" ] }, "build": { - "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/**"] + "inputs": ["$TURBO_EXTENDS$", "$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/**"] }, "typecheck": { - "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/*.json"] + "inputs": [ + "$TURBO_EXTENDS$", + "$TURBO_DEFAULT$", + "$TURBO_ROOT$/docs/*.json" + ] }, "lint": { - "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/*.json"] + "inputs": [ + "$TURBO_EXTENDS$", + "$TURBO_DEFAULT$", + "$TURBO_ROOT$/docs/*.json" + ] } } } diff --git a/tools/cli/src/lib/config/platform-docs.test.ts b/tools/cli/src/lib/config/platform-docs.test.ts index a4e0c6a0dc..b0d085f3d9 100644 --- a/tools/cli/src/lib/config/platform-docs.test.ts +++ b/tools/cli/src/lib/config/platform-docs.test.ts @@ -94,9 +94,11 @@ test('turbo re-runs this suite when an install page changes', () => { ); } const stdout = run.stdout.toString(); - const { tasks } = dryRunSchema.parse( - JSON.parse(stdout.slice(stdout.indexOf('{'))), - ); + const start = stdout.indexOf('{'); + if (start === -1) { + throw new Error(`turbo --dry=json printed no JSON: ${stdout}`); + } + const { tasks } = dryRunSchema.parse(JSON.parse(stdout.slice(start))); const inputs = new Set( Object.keys( tasks.find((task) => task.taskId === '@tale/cli#test')?.inputs ?? {}, @@ -110,3 +112,20 @@ test('turbo re-runs this suite when an install page changes', () => { ).filter((page) => !inputs.has(page)); expect(unhashed).toEqual([]); }); + +/** A workspace `inputs` list replaces the root task's instead of adding to it; + * `$TURBO_EXTENDS$` keeps the root's, `$TURBO_DEFAULT$` the workspace's own. */ +test('the test input list keeps the root inputs and the workspace sources', () => { + const { tasks } = z + .object({ + tasks: z.record( + z.string(), + z.object({ inputs: z.array(z.string()).optional() }), + ), + }) + .parse(JSON.parse(readFileSync(resolve(CLI_ROOT, 'turbo.json'), 'utf8'))); + expect(tasks.test?.inputs?.slice(0, 2)).toEqual([ + '$TURBO_EXTENDS$', + '$TURBO_DEFAULT$', + ]); +}); diff --git a/tools/cli/turbo.json b/tools/cli/turbo.json index 66539aebb4..73b6eba74c 100644 --- a/tools/cli/turbo.json +++ b/tools/cli/turbo.json @@ -4,6 +4,7 @@ "tasks": { "test": { "inputs": [ + "$TURBO_EXTENDS$", "$TURBO_DEFAULT$", "$TURBO_ROOT$/docs/*/self-hosted/install/cli-install.md" ]