sokko-g/tests/static-games.test.mjs
Shinuwa 962816bbb9
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
Add checklist creation for filtered game results
2026-09-29 23:27:10 +02:00

126 lines
8 KiB
JavaScript

// Rôle : vérifie les invariants statiques des pages et données de jeux.
import { readFile } from "node:fs/promises";
import { test } from "node:test";
import assert from "node:assert/strict";
test("generic game routes and shared game components are wired", async () => {
const routeContent = await readFile("website/src/router/RouteContent.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 gameLoaders = await readFile("website/src/features/games/loaders.js", "utf8");
const gameFiltersPanel = await readFile("website/src/features/games/GameFiltersPanel.jsx", "utf8");
const gameFilterDropdown = await readFile("website/src/features/games/GameFilterDropdown.jsx", "utf8");
const activeFilterBadges = await readFile("website/src/features/games/ActiveFilterBadges.jsx", "utf8");
const checklistCopyButton = await readFile("website/src/features/games/CopyChecklistItemsButton.jsx", "utf8");
const gameListsPage = await readFile("website/src/features/games/GameListsPage.jsx", "utf8");
assert.match(routeContent, /features\/games\/GamesPage\.jsx/);
assert.match(routeContent, /features\/games\/GameRoute\.jsx/);
assert.match(gamesPage, /export function GamesPage/);
assert.match(gamesPage, /siteContent\.gamesPage/);
assert.match(gamesPage, /game-card-cover-link/);
assert.match(gamesPage, /game-card-placeholder/);
assert.match(gameRoute, /export function GameRoute/);
assert.match(gameRoute, /MhwildsPage/);
assert.match(gameRoute, /Diablo4Page/);
assert.match(gameLoaders, /export async function loadMhwildsData/);
assert.match(gameLoaders, /\/data\/mhwilds\/lists\/index\.json/);
assert.match(gameLoaders, /loadGameLists/);
assert.match(gameLoaders, /normalizeGameListFile/);
assert.match(gameLoaders, /export async function loadDiablo4Data/);
assert.match(gameLoaders, /\/data\/diablo4\/affixes_types\.json/);
assert.match(gameLoaders, /filterOptionKeys/);
assert.match(gameFiltersPanel, /export function GameFiltersPanel/);
assert.match(gameFiltersPanel, /filter-reset-button/);
assert.match(gameFiltersPanel, /horizontal-compact/);
assert.match(gameFiltersPanel, /horizontal-menu/);
assert.match(gameFiltersPanel, /Tooltip/);
assert.match(gameFiltersPanel, /aria-pressed/);
assert.match(gameFilterDropdown, /CompactDropdown/);
assert.match(gameFilterDropdown, /aria-expanded/);
assert.match(gameFilterDropdown, /nds-filter-count/);
assert.match(gameFilterDropdown, /data-columns/);
assert.match(activeFilterBadges, /export function ActiveFilterBadges/);
assert.match(activeFilterBadges, /Retirer le filtre/);
assert.match(gameFiltersPanel, /ActiveFilterBadges/);
assert.match(checklistCopyButton, /formatChecklistImportItems/);
assert.match(checklistCopyButton, /formatChecklistImportSections/);
assert.match(checklistCopyButton, /\$\{entry\.label\}:\$\{entry\.quantity\}/);
assert.match(checklistCopyButton, /# \$\{title\}/);
assert.match(checklistCopyButton, /navigator\.clipboard\.writeText/);
assert.match(checklistCopyButton, /results-copy-button/);
assert.match(checklistCopyButton, /results-checklist-modal/);
assert.match(checklistCopyButton, /filteredResults/);
assert.match(checklistCopyButton, /Créer dans la toolbox/);
assert.match(checklistCopyButton, /resultsNoToolbox/);
assert.match(gameListsPage, /export function GameListsPage/);
assert.match(gameListsPage, /game-list-selector/);
assert.match(gameListsPage, /game-list-create-button/);
assert.match(gameListsPage, /module-icon-checklist/);
});
test("mhwilds and diablo pages expose expected route pieces", async () => {
const diablo4Page = await readFile("website/src/features/games/diablo4/Diablo4Page.jsx", "utf8");
const diablo4Overview = await readFile("website/src/features/games/diablo4/Diablo4Overview.jsx", "utf8");
const diablo4Listing = await readFile("website/src/features/games/diablo4/Diablo4Listing.jsx", "utf8");
const diablo4Filters = await readFile("website/src/features/games/diablo4/Diablo4Filters.jsx", "utf8");
const diablo4AffixCard = await readFile("website/src/features/games/diablo4/Diablo4AffixCard.jsx", "utf8");
const diablo4Utils = await readFile("website/src/features/games/diablo4/utils.js", "utf8");
const mhwildsPage = await readFile("website/src/features/games/mhwilds/MhwildsPage.jsx", "utf8");
const mhwildsOverview = await readFile("website/src/features/games/mhwilds/MhwildsOverview.jsx", "utf8");
const mhwildsListing = await readFile("website/src/features/games/mhwilds/MhwildsListing.jsx", "utf8");
const mhwildsLists = await readFile("website/src/features/games/mhwilds/MhwildsLists.jsx", "utf8");
const aniimoPage = await readFile("website/src/features/games/aniimo/AniimoPage.jsx", "utf8");
const aniimoFilters = await readFile("website/src/features/games/aniimo/AniimoFilters.jsx", "utf8");
const aniimoLists = await readFile("website/src/features/games/aniimo/AniimoLists.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");
assert.match(diablo4Page, /export function Diablo4Page/);
assert.match(diablo4Overview, /export function Diablo4Overview/);
assert.match(diablo4Listing, /export function Diablo4Listing/);
assert.match(diablo4Listing, /CopyChecklistItemsButton/);
assert.match(diablo4Listing, /checklistTitle="Affixes"/);
assert.match(diablo4Listing, /filteredResults/);
assert.match(diablo4Filters, /export function Diablo4Filters/);
assert.match(diablo4Filters, /GameFiltersPanel/);
assert.match(diablo4Filters, /variant="horizontal-menu"/);
assert.match(diablo4AffixCard, /export function Diablo4AffixCard/);
assert.match(diablo4AffixCard, /categoryMap/);
assert.match(diablo4Utils, /getFilteredDiablo4Affixes/);
assert.match(diablo4Utils, /getCategoryIconStyle/);
assert.match(mhwildsPage, /export function MhwildsPage/);
assert.match(mhwildsPage, /MhwildsLists/);
assert.match(mhwildsPage, /linkedToolboxId/);
assert.match(mhwildsOverview, /#\/games\/mhwilds\/lists/);
assert.match(mhwildsListing, /export function MhwildsListing/);
assert.match(mhwildsListing, /GameBreadcrumb/);
assert.match(mhwildsListing, /CopyChecklistItemsButton/);
assert.match(mhwildsListing, /checklistTitle=\{label\}/);
assert.match(mhwildsListing, /filteredResults/);
assert.match(mhwildsListing, /endemic_life/);
assert.match(mhwildsLists, /export function MhwildsLists/);
assert.match(mhwildsLists, /GameListsPage/);
assert.match(mhwildsLists, /selectedListId/);
assert.match(aniimoPage, /AniimoLists/);
assert.match(aniimoPage, /content\.variantsChecklistTitle/);
assert.match(aniimoPage, /filteredResults/);
assert.match(aniimoPage, /games\/aniimo\/lists/);
assert.match(aniimoFilters, /data-variant="horizontal-menu"/);
assert.match(aniimoFilters, /GameFilterDropdown/);
assert.match(aniimoFilters, /content\.roles/);
assert.match(aniimoFilters, /content\.elements/);
assert.match(aniimoFilters, /content\.abilities/);
assert.equal((aniimoFilters.match(/columns=\{2\}/g) || []).length, 2);
assert.match(aniimoLists, /GameListsPage/);
assert.match(mhwildsFilters, /export function MhwildsFilters/);
assert.match(mhwildsFilters, /GameFiltersPanel/);
assert.match(mhwildsFilters, /variant="horizontal-compact"/);
assert.match(monsterCard, /export function MonsterCard/);
assert.match(monsterCard, /ui-icon-flip/);
assert.match(endemicCard, /export function EndemicCard/);
assert.match(damageTable, /rowIndex/);
assert.doesNotMatch(`${mhwildsListing}\n${diablo4Listing}\n${diablo4Overview}`, /mhwilds-(home-grid|home-card|heading|title-row|layout|filters|results|grid)/);
});