From 4f18d1eb87b745c3e617445293089b207e143f8b Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Dat Date: Tue, 25 Aug 2026 18:04:38 +0700 Subject: [PATCH] test(locale-agents): fail on a locale doc whose agent no longer exists Review feedback on #2879: a locale file with no counterpart in `agents/` was skipped, so every other case here silently passed over it. Retiring an agent would leave its seven translations behind with nothing to compare against and nothing to report it. Collect those files while building the list and assert the collection is empty. Zero today across 199 locale docs, so this changes no current result; planting one orphan takes the file to `Passed: 6, Failed: 1` and exit 1. --- tests/ci/locale-agent-frontmatter.test.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/ci/locale-agent-frontmatter.test.js b/tests/ci/locale-agent-frontmatter.test.js index b2b888577..26dc92228 100644 --- a/tests/ci/locale-agent-frontmatter.test.js +++ b/tests/ci/locale-agent-frontmatter.test.js @@ -82,23 +82,34 @@ function main() { if (fields) canonical.set(file, fields); } + const rel = filePath => path.relative(REPO_ROOT, filePath).split(path.sep).join('/'); + const localeFiles = []; + const orphans = []; for (const dir of localeAgentDirs()) { for (const file of fs.readdirSync(dir).filter(f => f.endsWith('.md'))) { - if (canonical.has(file)) { - localeFiles.push({ file, filePath: path.join(dir, file) }); - } + const filePath = path.join(dir, file); + if (canonical.has(file)) localeFiles.push({ file, filePath }); + else orphans.push(rel(filePath)); } } - const rel = filePath => path.relative(REPO_ROOT, filePath).split(path.sep).join('/'); - const tests = [ ['there are locale agent docs to check', () => { assert.ok(canonical.size > 0, 'no canonical agents found'); assert.ok(localeFiles.length > 0, 'no locale agent docs found'); }], + ['no locale agent doc outlives the agent it documents', () => { + // Without this, retiring an agent leaves its translations behind and every + // other case here silently skips them — they have nothing to compare to. + assert.deepStrictEqual( + orphans, + [], + `locale docs with no agent in agents/:\n ${orphans.join('\n ')}` + ); + }], + ['every locale agent doc has parseable frontmatter', () => { const bad = localeFiles .filter(({ filePath }) => frontmatter(filePath) === null)