sokko-g/tests/static-app.test.mjs
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:42:13 +01:00

134 lines
7.4 KiB
JavaScript

/**
* @file Conserve les conventions éditoriales et les assets du shell non couverts par les parcours navigateur.
*/
import { readFile } from "node:fs/promises";
import { test } from "node:test";
import assert from "node:assert/strict";
test("vite entrypoint and app shell are wired", async () => {
const html = await readFile("website/index.html", "utf8");
const source = await readFile("website/src/main.jsx", "utf8");
const gameFiltersHook = await readFile("website/src/hooks/useGameFilters.js", "utf8");
const shell = await readFile("website/src/components/Shell.jsx", "utf8");
const toolboxPages = await readFile("website/src/features/toolboxes/ToolboxPages.jsx", "utf8");
const importButton = await readFile("website/src/components/ImportButton.jsx", "utf8");
const overlays = await readFile("website/src/components/AppOverlays.jsx", "utf8");
const imageViewer = await readFile("website/src/components/ImageViewer.jsx", "utf8");
const homePage = await readFile("website/src/pages/HomePage.jsx", "utf8");
const aboutPage = await readFile("website/src/pages/AboutPage.jsx", "utf8");
const routeContent = await readFile("website/src/router/RouteContent.jsx", "utf8");
assert.match(html, /<div id="app"><\/div>/);
assert.match(html, /\/favicon\.ico/);
assert.match(html, /\/src\/main\.jsx/);
assert.match(html, /_asset-recovery/);
assert.match(html, /vite:preloadError/);
assert.match(html, /HTMLScriptElement/);
assert.match(source, /styles\/main\.scss/);
assert.match(source, /searchParams\.has\("_asset-recovery"\)/);
assert.match(source, /searchParams\.delete\("_asset-recovery"\)/);
assert.match(source, /hooks\/useGameFilters\.js/);
assert.doesNotMatch(source, /DEFAULT_SITE_CONTENT/);
assert.match(gameFiltersHook, /export function useGameFilters/);
assert.match(routeContent, /features\/games\/GameRoute\.jsx/);
assert.doesNotMatch(shell, /content\.navigation\.library/);
assert.match(shell, /sidebar-about-link/);
assert.match(shell, /dragon-sidebar\.webp/);
assert.match(shell, /ImportButton/);
assert.match(shell, /compactSidebar/);
assert.match(shell, /reducedSidebar/);
assert.match(shell, /compact-game-view-switch/);
assert.doesNotMatch(shell, /mobile-nav/);
assert.doesNotMatch(shell, /import\.meta\.env\.DEV \|\| Boolean\(drawerGameId\)/);
assert.match(shell, /data-variant=\{compactSidebar \? "compact"/);
assert.match(shell, /toolbox-drawer-open/);
assert.match(shell, /position="right"/);
assert.match(importButton, /tooltipPosition/);
assert.match(toolboxPages, /DRAWER_INITIAL_WIDTH = 700/);
assert.doesNotMatch(toolboxPages, /drawerWidth|dbGetSetting|dbSetSetting/);
assert.match(overlays, /\.\/ImageViewer\.jsx/);
assert.match(overlays, /uid\("marker"\)/);
assert.match(imageViewer, /export function ImageViewer/);
assert.match(imageViewer, /function openImageInNewTab/);
assert.match(homePage, /dragon-home\.webp/);
assert.match(aboutPage, /module-icon-\$\{group\.icon \|\| "notepad"\}/);
});
test("project documentation tracks storage and feature updates", async () => {
const storageSchema = await readFile("docs/STORAGE_SCHEMA.md", "utf8");
const featureChecklist = await readFile("docs/FEATURE_CHECKLIST.md", "utf8");
assert.match(storageSchema, /IndexedDB/);
assert.match(storageSchema, /Outil Checklist/);
assert.match(storageSchema, /Outil Images/);
assert.match(storageSchema, /Outil Annotation d'images/);
assert.match(storageSchema, /Outil Calculateur/);
assert.match(storageSchema, /Outil Randomizer/);
assert.match(featureChecklist, /Mettre à jour `docs\/STORAGE_SCHEMA\.md`/);
assert.match(featureChecklist, /npm run check/);
});
test("server and vite support local env configuration", async () => {
const server = await readFile("server.mjs", "utf8");
const viteConfig = await readFile("vite.config.js", "utf8");
const envExample = await readFile(".env.example", "utf8");
assert.match(server, /load-project-env\.mjs/);
assert.match(server, /process\.env\.PORT/);
assert.match(viteConfig, /load-project-env\.mjs/);
assert.match(viteConfig, /process\.env\.PORT/);
assert.match(envExample, /PORT=5173/);
});
test("legacy icons and primary images are available", async () => {
const manifest = JSON.parse(await readFile("website/public/data/toolbox-icons.json", "utf8"));
assert.ok(manifest.icons.length >= 4);
await readFile("website/public/static/icons/home.svg", "utf8");
await readFile("website/public/static/icons/add.svg", "utf8");
await readFile("website/public/static/icons/checklist.svg", "utf8");
await readFile("website/public/static/icons/close.svg", "utf8");
await readFile("website/public/static/icons/columns.svg", "utf8");
await readFile("website/public/static/icons/copy.svg", "utf8");
await readFile("website/public/static/icons/abacus.svg", "utf8");
await readFile("website/public/static/icons/calculator.svg", "utf8");
await readFile("website/public/static/icons/diagram.svg", "utf8");
await readFile("website/public/static/icons/map.svg", "utf8");
await readFile("website/public/static/icons/enter.svg", "utf8");
await readFile("website/public/static/icons/export.svg", "utf8");
await readFile("website/public/static/icons/hide.svg", "utf8");
await readFile("website/public/static/icons/chevron-down.svg", "utf8");
await readFile("website/public/static/icons/chevron-up.svg", "utf8");
await readFile("website/public/static/icons/scrollable.svg", "utf8");
await readFile("website/public/static/icons/notepad.svg", "utf8");
await readFile("website/public/static/icons/picture.svg", "utf8");
await readFile("website/public/static/icons/rows.svg", "utf8");
await readFile("website/public/static/icons/rubber.svg", "utf8");
await readFile("website/public/static/icons/trashcan.svg", "utf8");
await readFile("website/public/static/icons/zoom.svg", "utf8");
await readFile("website/public/static/icons/warning.svg", "utf8");
await readFile("website/public/static/icons/axe.svg", "utf8");
await readFile("website/public/static/icons/cube.svg", "utf8");
await readFile("website/public/static/icons/dice.svg", "utf8");
await readFile("website/public/static/icons/fire.svg", "utf8");
await readFile("website/public/static/icons/shield.svg", "utf8");
await readFile("website/public/static/icons/wing.svg", "utf8");
await readFile("website/public/favicon.ico");
await readFile("website/public/static/img/dragon-home.webp");
await readFile("website/public/static/img/dragon-sidebar.webp");
await readFile("website/public/static/img/dragon-dual-monitor.webp");
await readFile("website/public/static/img/dragon-session-tools.webp");
await readFile("website/public/static/img/dragon-game-guides.webp");
await readFile("website/public/static/img/dragon-local-data.webp");
await readFile("website/public/static/img/dragon-contribution-data.webp");
await readFile("website/public/static/img/dragon-gameguide.webp");
await readFile("website/public/static/img/dragon-toolbox.webp");
await readFile("website/public/static/img/onboarding/toolbox-overview.webp");
await readFile("website/public/static/img/onboarding/toolbox-tools.webp");
await readFile("website/public/static/img/onboarding/toolbox-save.webp");
await readFile("website/public/static/img/onboarding/toolbox-game-link.webp");
await readFile("website/public/static/img/toolbox-icons/toolbox.webp");
await readFile("website/public/static/img/toolbox-icons/sword.webp");
await readFile("website/public/static/img/toolbox-icons/puzzle.webp");
});