174 lines
10 KiB
JavaScript
174 lines
10 KiB
JavaScript
// Rôle : vérifie les invariants statiques du shell, du routing et des overlays.
|
|
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 appDataHook = await readFile("website/src/hooks/useAppData.js", "utf8");
|
|
const gameFiltersHook = await readFile("website/src/hooks/useGameFilters.js", "utf8");
|
|
const shell = await readFile("website/src/components/Shell.jsx", "utf8");
|
|
const overlays = await readFile("website/src/components/AppOverlays.jsx", "utf8");
|
|
const modals = await readFile("website/src/components/ToolboxModals.jsx", "utf8");
|
|
const imageViewer = await readFile("website/src/components/ImageViewer.jsx", "utf8");
|
|
const richText = await readFile("website/src/components/RichText.jsx", "utf8");
|
|
const homePage = await readFile("website/src/pages/HomePage.jsx", "utf8");
|
|
const homeOnboarding = await readFile("website/src/pages/HomeOnboardingSection.jsx", "utf8");
|
|
const aboutPage = await readFile("website/src/pages/AboutPage.jsx", "utf8");
|
|
const libraryPage = await readFile("website/src/pages/LibraryPage.jsx", "utf8");
|
|
const moduleRegistry = await readFile("website/src/features/toolboxes/toolboxModuleRegistry.js", "utf8");
|
|
const hashRouter = await readFile("website/src/router/hashRouter.js", "utf8");
|
|
const routeContent = await readFile("website/src/router/RouteContent.jsx", "utf8");
|
|
const bodyScrollLock = await readFile("website/src/utils/bodyScrollLock.js", "utf8");
|
|
|
|
assert.match(html, /<div id="app"><\/div>/);
|
|
assert.match(html, /\/favicon\.ico/);
|
|
assert.match(html, /\/src\/main\.jsx/);
|
|
assert.match(source, /styles\/main\.scss/);
|
|
assert.match(source, /components\/Shell\.jsx/);
|
|
assert.match(source, /components\/AppOverlays\.jsx/);
|
|
assert.match(source, /router\/RouteContent\.jsx/);
|
|
assert.match(source, /hooks\/useAppData\.js/);
|
|
assert.match(source, /hooks\/useGameFilters\.js/);
|
|
assert.doesNotMatch(source, /DEFAULT_SITE_CONTENT/);
|
|
assert.match(appDataHook, /export function useAppData/);
|
|
assert.match(appDataHook, /\/data\/site\.json/);
|
|
assert.match(appDataHook, /setSiteContentError/);
|
|
assert.match(gameFiltersHook, /export function useGameFilters/);
|
|
assert.match(hashRouter, /export function useHashRoute/);
|
|
assert.match(hashRouter, /export function navigate/);
|
|
assert.match(routeContent, /export function RouteContent/);
|
|
assert.match(routeContent, /pages\/HomePage\.jsx/);
|
|
assert.match(routeContent, /pages\/AboutPage\.jsx/);
|
|
assert.match(routeContent, /pages\/LibraryPage\.jsx/);
|
|
assert.match(routeContent, /route === "\/library"/);
|
|
assert.match(routeContent, /features\/games\/GameRoute\.jsx/);
|
|
assert.match(shell, /export function Shell/);
|
|
assert.doesNotMatch(shell, /content\.navigation\.library/);
|
|
assert.match(shell, /sidebar-about-link/);
|
|
assert.match(shell, /dragon-sidebar\.png/);
|
|
assert.match(shell, /ImportButton/);
|
|
assert.match(overlays, /export function AppOverlays/);
|
|
assert.match(overlays, /\.\/ToolboxModals\.jsx/);
|
|
assert.match(overlays, /\.\/ImageViewer\.jsx/);
|
|
assert.match(overlays, /uid\("marker"\)/);
|
|
assert.match(modals, /export function ConfirmModal/);
|
|
assert.match(modals, /export function CreateToolboxModal/);
|
|
assert.match(modals, /export function LinkToolboxModal/);
|
|
assert.match(modals, /export function NotificationToast/);
|
|
assert.match(modals, /durationMs = 120000/);
|
|
assert.match(modals, /setTimeout\(\(\) => onClose\(id\), durationMs\)/);
|
|
assert.match(source, /SHORT_NOTIFICATION_DURATION_MS = 5000/);
|
|
assert.match(source, /getNotificationDuration/);
|
|
assert.match(modals, /useModalScrollLock/);
|
|
assert.match(imageViewer, /export function ImageViewer/);
|
|
assert.match(imageViewer, /function openImageInNewTab/);
|
|
assert.match(richText, /value\.split\("\\n"\)/);
|
|
assert.match(richText, /<br key=/);
|
|
assert.match(homePage, /export function HomePage/);
|
|
assert.match(homePage, /HomeOnboardingSection/);
|
|
assert.match(homePage, /import\.meta\.env\.DEV \|\| toolboxes\.length === 0/);
|
|
assert.match(homePage, /setCreateModal\(\{ tutorial: true \}\)/);
|
|
assert.match(homePage, /dragon-home\.png/);
|
|
assert.match(homeOnboarding, /export function HomeOnboardingSection/);
|
|
assert.match(homeOnboarding, /prefers-reduced-motion: reduce/);
|
|
assert.match(homeOnboarding, /onCreateToolbox/);
|
|
assert.match(homeOnboarding, /content\.primaryAction/);
|
|
assert.match(homeOnboarding, /content\.sliderTitle/);
|
|
assert.match(homeOnboarding, /home-onboarding-dots/);
|
|
assert.match(aboutPage, /export function AboutPage/);
|
|
assert.match(aboutPage, /HomeOnboardingSection/);
|
|
assert.match(aboutPage, /siteContent\.home\.onboarding/);
|
|
assert.match(aboutPage, /module-icon-\$\{group\.icon \|\| "notepad"\}/);
|
|
assert.match(aboutPage, /about-tool-examples/);
|
|
assert.match(libraryPage, /export function LibraryPage/);
|
|
assert.match(libraryPage, /LIBRARY_TOOLBOX_ID/);
|
|
assert.match(libraryPage, /TOOLBOX_MODULE_LOADERS/);
|
|
assert.match(libraryPage, /Object\.entries\(TOOLBOX_MODULE_LOADERS\)/);
|
|
assert.match(moduleRegistry, /export const TOOLBOX_MODULE_LOADERS/);
|
|
assert.match(moduleRegistry, /taskPlanner: \(\) => import\("\.\/modules\/TaskPlannerModule\.jsx"\)/);
|
|
assert.match(moduleRegistry, /equipmentPlanner: \(\) => import\("\.\/modules\/EquipmentPlannerModule\.jsx"\)/);
|
|
assert.match(libraryPage, /normalizeEquipmentPlannerData/);
|
|
assert.match(libraryPage, /summarizeEquipmentPlannerData/);
|
|
assert.match(bodyScrollLock, /modalLocks/);
|
|
assert.match(bodyScrollLock, /is-modal-open/);
|
|
});
|
|
|
|
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, /function loadEnvFile/);
|
|
assert.match(server, /process\.env\.PORT/);
|
|
assert.match(viteConfig, /function loadEnvFile/);
|
|
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.png");
|
|
await readFile("website/public/static/img/dragon-sidebar.png");
|
|
await readFile("website/public/static/img/dragon-dual-monitor.png");
|
|
await readFile("website/public/static/img/dragon-session-tools.png");
|
|
await readFile("website/public/static/img/dragon-game-guides.png");
|
|
await readFile("website/public/static/img/dragon-local-data.png");
|
|
await readFile("website/public/static/img/dragon-contribution-data.png");
|
|
await readFile("website/public/static/img/dragon-gameguide.png");
|
|
await readFile("website/public/static/img/dragon-toolbox.png");
|
|
await readFile("website/public/static/img/onboarding/toolbox-overview.png");
|
|
await readFile("website/public/static/img/onboarding/toolbox-tools.png");
|
|
await readFile("website/public/static/img/onboarding/toolbox-save.png");
|
|
await readFile("website/public/static/img/onboarding/toolbox-game-link.png");
|
|
await readFile("website/public/static/img/toolbox-icons/toolbox.png");
|
|
await readFile("website/public/static/img/toolbox-icons/sword.png");
|
|
await readFile("website/public/static/img/toolbox-icons/puzzle.png");
|
|
});
|