sokko-g/tests/toolbox-compactors.test.mjs
Shinuwa ae739b08ad Check in the tests that central files keep their full headers and that every tool has a compactor
tests/file-headers.test.mjs now fails when a source file over 300 lines lacks
"Utilisé par :" and @see, when a listed central file lacks "Utilisé par :", or
when a file adding methods through Object.assign does not say so. The eleven
files below the bar are completed, so no waiting list is needed.
tests/toolbox-compactors.test.mjs makes sure every tool type has a storage
compactor, the gap found while documenting the toolboxes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 11:22:50 +01:00

21 lines
1.2 KiB
JavaScript

/**
* @file Vérifie que chaque type d'outil du registre a son compacteur, et que le registre des compacteurs ne cite
* aucun type inconnu.
*
* Attention : sans compacteur, `compactModuleDataForStorage` écrit les données d'un outil telles quelles, sans
* erreur ; ce test est la seule protection contre cet oubli.
* @see website/src/features/toolboxes/README.md
*/
import assert from "node:assert/strict";
import { test } from "node:test";
import { TOOLBOX_MODULE_DEFINITIONS } from "../website/src/features/toolboxes/toolboxModuleRegistry.js";
import { MODULE_DATA_COMPACTORS } from "../website/src/features/toolboxes/storage/modules/index.js";
test("every toolbox tool type has a storage compactor", () => {
const types = Object.keys(TOOLBOX_MODULE_DEFINITIONS).sort();
const compacted = Object.keys(MODULE_DATA_COMPACTORS).sort();
assert.deepEqual(types.filter((type) => !compacted.includes(type)), [], "Add a compactor in storage/modules/index.js for these tool types");
assert.deepEqual(compacted.filter((type) => !types.includes(type)), [], "These compactors name tool types missing from toolboxModuleRegistry.js");
for (const type of compacted) assert.equal(typeof MODULE_DATA_COMPACTORS[type], "function", type);
});