Files
FWS-DiscordBot/tests/docs.test.js
T
BlackAngelTV 9bbe9cb0b4 docs(readme): translate the documentation and document the contribution workflow
The organisation asks every repository for both languages, for the issue and
pull request templates, and for the commit, branch and release rules; the
README now states them, README.en.md mirrors it, and a test keeps the two in
sync so a change on one side cannot be forgotten on the other.

The readme also documents what shipped since it was last written: several voice
triggers, the guaranteed cleanup of empty channels, the editable bot statuses,
the message tone and the variables they add.
2026-09-15 16:15:00 +02:00

51 lines
2.3 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, it } from 'node:test';
const read = (file) => readFileSync(new URL(`../${file}`, import.meta.url), 'utf8');
const headingCount = (text, level) => (text.match(new RegExp(`^${'#'.repeat(level)} `, 'gm')) ?? []).length;
const commandNames = (text) => new Set([...text.matchAll(/`\/([a-z]+)/g)].map((match) => match[1]));
const envTokens = (text) => new Set(text.match(/\b[A-Z][A-Z0-9]*_[A-Z0-9_]+\b/g) ?? []);
/** The organisation requires both READMEs, kept in sync (`.profile/README.md`). */
describe('bilingual documentation', () => {
it('keeps README.md and README.en.md structurally in sync', () => {
const fr = read('README.md');
const en = read('README.en.md');
assert.equal(headingCount(en, 2), headingCount(fr, 2), 'a section is missing on one side');
assert.equal(headingCount(en, 3), headingCount(fr, 3), 'a subsection is missing on one side');
});
it('documents the same commands and environment variables in both languages', () => {
const fr = read('README.md');
const en = read('README.en.md');
assert.deepEqual([...commandNames(en)].sort(), [...commandNames(fr)].sort(), 'command list differs');
assert.deepEqual([...envTokens(en)].sort(), [...envTokens(fr)].sort(), 'environment list differs');
});
it('links the two versions to each other', () => {
assert.match(read('README.md'), /README\.en\.md/, 'the French README does not link the English one');
assert.match(read('README.en.md'), /README\.md/, 'the English README does not link the French one');
});
it('ships the organisation files', () => {
assert.match(read('CHANGELOG.md'), /^# Changelog/, 'the generated changelog is missing');
assert.match(read('AGENTS.md'), /Instructions pour les agents/, 'the agent instructions are missing');
assert.match(
read('.gitea/PULL_REQUEST_TEMPLATE.md'),
/Conventional Commits/,
'the pull request template is missing',
);
assert.match(
read('.gitea/ISSUE_TEMPLATE/bug.md'),
/Étapes de reproduction/,
'the bug report template is missing',
);
assert.match(read('.gitignore'), /^\.env$/m, 'the environment files are not ignored');
assert.match(read('.gitignore'), /^\.freebuff\/$/m, 'the assistant data is not ignored');
});
});