Migrate to React/Vite & Sass
Some checks failed
Deploy Sokko G / deploy (push) Failing after 4s

This commit is contained in:
Shinuwa 2026-07-21 10:09:25 +02:00
parent db4b99aee3
commit 1dee8b528f
30 changed files with 3491 additions and 2444 deletions

View file

@ -2,59 +2,85 @@ import { readFile } from "node:fs/promises";
import { test } from "node:test";
import assert from "node:assert/strict";
test("static entrypoint loads the application assets", async () => {
const html = await readFile("website/public/index.html", "utf8");
test("vite entrypoint loads the react application", async () => {
const html = await readFile("website/index.html", "utf8");
assert.match(html, /<div id="app"><\/div>/);
assert.match(html, /\/favicon\.ico/);
assert.match(html, /\/src\/app\.js/);
assert.match(html, /\/src\/styles\.css/);
assert.match(html, /\/src\/main\.jsx/);
});
test("application defines the expected local toolbox primitives", async () => {
const source = await readFile("website/src/app.js", "utf8");
test("react application defines the expected local toolbox primitives", async () => {
const source = await readFile("website/src/main.jsx", "utf8");
const styles = await readFile("website/src/styles/main.scss", "utf8");
const styleTokens = await readFile("website/src/styles/_tokens.scss", "utf8");
const iconComponent = await readFile("website/src/components/Icon.jsx", "utf8");
const gamesPage = await readFile("website/src/features/games/GamesPage.jsx", "utf8");
const gameRoute = await readFile("website/src/features/games/GameRoute.jsx", "utf8");
const mhwildsPage = await readFile("website/src/features/games/mhwilds/MhwildsPage.jsx", "utf8");
const mhwildsListing = await readFile("website/src/features/games/mhwilds/MhwildsListing.jsx", "utf8");
const mhwildsFilters = await readFile("website/src/features/games/mhwilds/MhwildsFilters.jsx", "utf8");
const monsterCard = await readFile("website/src/features/games/mhwilds/cards/MonsterCard.jsx", "utf8");
const endemicCard = await readFile("website/src/features/games/mhwilds/cards/EndemicCard.jsx", "utf8");
const damageTable = await readFile("website/src/features/games/mhwilds/cards/DamageTable.jsx", "utf8");
const moduleRegistry = await readFile("website/src/features/toolboxes/modules/index.jsx", "utf8");
const notepadModule = await readFile("website/src/features/toolboxes/modules/NotepadModule.jsx", "utf8");
const checklistModule = await readFile("website/src/features/toolboxes/modules/ChecklistModule.jsx", "utf8");
const screenshotsModule = await readFile("website/src/features/toolboxes/modules/ScreenshotsModule.jsx", "utf8");
assert.match(source, /sokkog:toolboxes/);
assert.match(source, /sokkog:game-toolbox-links/);
assert.match(source, /styles\/main\.scss/);
assert.match(styles, /@use "tokens"/);
assert.match(styleTokens, /--gradient-brand/);
assert.match(source, /features\/toolboxes\/modules\/index\.jsx/);
assert.match(source, /features\/games\/GamesPage\.jsx/);
assert.match(source, /features\/games\/GameRoute\.jsx/);
assert.match(iconComponent, /export function Icon/);
assert.match(gamesPage, /export function GamesPage/);
assert.match(gameRoute, /export function GameRoute/);
assert.match(gameRoute, /MhwildsPage/);
assert.match(mhwildsPage, /export function MhwildsPage/);
assert.match(mhwildsListing, /export function MhwildsListing/);
assert.match(mhwildsFilters, /export function MhwildsFilters/);
assert.match(monsterCard, /export function MonsterCard/);
assert.match(endemicCard, /export function EndemicCard/);
assert.match(damageTable, /rowIndex/);
assert.match(moduleRegistry, /export const TOOLBOX_MODULES/);
assert.match(moduleRegistry, /export function ToolboxModules/);
assert.match(moduleRegistry, /MODULE_COMPONENTS/);
assert.match(moduleRegistry, /notepad:/);
assert.match(moduleRegistry, /checklist:/);
assert.match(moduleRegistry, /screenshots:/);
assert.match(notepadModule, /export function NotepadModule/);
assert.match(checklistModule, /export function ChecklistModule/);
assert.match(screenshotsModule, /export function ScreenshotsModule/);
assert.match(source, /DEFAULT_SITE_CONTENT/);
assert.match(source, /function loadSiteContent/);
assert.match(source, /\/data\/site\.json/);
assert.match(source, /APP_STORAGE_LIMIT_BYTES/);
assert.match(source, /function renderStorageQuota/);
assert.match(source, /function StorageQuota/);
assert.match(source, /function writeStorageValue/);
assert.match(source, /role="progressbar"/);
assert.match(source, /export-all-toolboxes/);
assert.match(source, /import-all-toolboxes/);
assert.match(source, /function createGlobalExportPayload/);
assert.match(source, /function importAllToolboxes/);
assert.match(source, /open-link-toolbox-modal/);
assert.match(source, /function showToolboxLinkModal/);
assert.match(source, /data-game-id/);
assert.match(source, /notepad/);
assert.match(source, /checklist/);
assert.match(source, /screenshots/);
assert.match(source, /async function importAllToolboxes/);
assert.match(source, /function LinkToolboxModal/);
assert.doesNotMatch(source, /description: _description/);
assert.match(source, /function showToolboxCreateModal/);
assert.match(source, /data-action="toolbox-create-form"/);
assert.match(source, /function getToolboxGameId/);
assert.match(source, /function CreateToolboxModal/);
assert.match(source, /const getToolboxGameId/);
assert.match(source, /dragon\.png/);
assert.match(source, /const game = getToolboxGame\(toolbox\)/);
assert.match(source, /getToolboxGame\(toolbox\)/);
assert.match(source, /moduleColumns/);
assert.match(source, /data-action="set-module-layout"/);
assert.match(source, /data-action="edit-toolbox-title"/);
assert.match(source, /function renderToolboxModules/);
assert.match(source, /function moveToolboxModule/);
assert.match(source, /dragstart/);
assert.match(source, /function ToolboxView/);
assert.match(moduleRegistry, /onDragStart/);
assert.match(source, /qtyTarget/);
assert.match(source, /qtyCurrent/);
assert.match(source, /adjust-check-qty/);
assert.match(source, /paste-screenshot/);
assert.match(source, /clipboardData/);
assert.match(source, /function addScreenshotFiles/);
assert.match(source, /view-screenshot/);
assert.match(source, /function showScreenshotViewer/);
assert.match(source, /drop-screenshot/);
assert.match(source, /dataTransfer\.files/);
assert.match(checklistModule, /ChecklistItem/);
assert.match(screenshotsModule, /clipboardData/);
assert.match(source, /async function addScreenshotFiles/);
assert.match(source, /function ScreenshotViewer/);
assert.match(source, /function openImageInNewTab/);
assert.match(source, /<Icon name="zoom"/);
assert.match(screenshotsModule, /dataTransfer\.files/);
});
test("mhwilds data and assets are available", async () => {
@ -63,7 +89,7 @@ test("mhwilds data and assets are available", async () => {
const monsters = JSON.parse(await readFile("website/public/data/mhwilds/monsters.json", "utf8"));
const endemicLife = JSON.parse(await readFile("website/public/data/mhwilds/endemic_life.json", "utf8"));
const translations = JSON.parse(await readFile("website/public/data/mhwilds/i18n/fr.json", "utf8"));
const appSource = await readFile("website/src/app.js", "utf8");
const listingSource = await readFile("website/src/features/games/mhwilds/MhwildsListing.jsx", "utf8");
assert.equal(site.brand.name, "Sokko G");
assert.equal(site.home.hero.title, "Sokko G");
@ -74,17 +100,21 @@ test("mhwilds data and assets are available", async () => {
assert.ok(monsters.monsters.length > 0);
assert.ok(endemicLife.endemicLife.length > 0);
assert.equal(translations.monsters, "monstres");
assert.match(appSource, /renderMhwildsListing/);
assert.match(appSource, /flip-monster-card/);
assert.match(listingSource, /function MhwildsListing/);
const monsterCardSource = await readFile("website/src/features/games/mhwilds/cards/MonsterCard.jsx", "utf8");
assert.match(monsterCardSource, /monster-card/);
await readFile("website/public/static/img/mhwilds/chatacabra.png");
});
test("server supports local env configuration", async () => {
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/);
});
@ -102,6 +132,7 @@ test("legacy svg icons are available for reuse", async () => {
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/favicon.ico");
await readFile("website/public/static/img/dragon.png");
await readFile("website/public/static/img/toolbox-icons/controller.svg", "utf8");