Link guide cards to checklists and refine Aniimo ability filters
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s

This commit is contained in:
Shinuwa 2026-09-24 23:55:06 +02:00
parent b5901b31e3
commit 7b23a8601a
23 changed files with 193 additions and 51 deletions

View file

@ -1,7 +1,7 @@
// Rôle : vérifie les correspondances des guides et la validité des associations de session.
import assert from "node:assert/strict";
import test from "node:test";
import { aniimoChecklistEntries, matchGuideChecklist, normalizeGuideLabel, validGuideAssociations } from "../website/src/features/games/guideChecklist.js";
import { aniimoChecklistEntries, matchGuideChecklist, normalizeGuideLabel, toggleGuideChecklistRows, validGuideAssociations } from "../website/src/features/games/guideChecklist.js";
const variants = [{ key: "1:base", name: "emberpup", form: "base" }, { key: "1:mountain", name: "emberpup", form: "mountain" }];
const entries = aniimoChecklistEntries(variants, { emberpup: "Loufeuteau", base: "Forme de base", mountain: "Montagnes" }, { emberpup: "Emberpup", base: "Basic form", mountain: "Mountain form" });
@ -43,6 +43,21 @@ test("all duplicate lines must reach their own target, including translated alia
assert.equal(matchGuideChecklist(entries, {}).count, 0);
});
test("card toggles update every exact matching row to its target or zero", () => {
const data = { sections: [{ id: "s1", items: [
{ id: "a", label: "Loufeuteau", qtyTarget: 3, qtyCurrent: 1 },
{ id: "b", label: "Emberpup", qtyTarget: 2, qtyCurrent: 0 },
{ id: "c", label: "Unrelated", qtyCurrent: 1 }
] }] };
const match = matchGuideChecklist(entries, data);
assert.deepEqual(match.rowIds.get("1:base"), ["a", "b"]);
const completed = toggleGuideChecklistRows(data, match.rowIds.get("1:base"), true);
assert.deepEqual(completed.sections[0].items.map((item) => item.qtyCurrent), [3, 2, 1]);
const cleared = toggleGuideChecklistRows(completed, match.rowIds.get("1:base"), false);
assert.deepEqual(cleared.sections[0].items.map((item) => item.qtyCurrent), [0, 0, 1]);
assert.equal(data.sections[0].items[0].qtyCurrent, 1);
});
test("session associations require the current linked toolbox and an existing checklist", () => {
const toolbox = { id: "tb", modules: [{ id: "capture", type: "checklist" }, { id: "notes", type: "notepad" }] };
const association = { toolboxId: "tb", moduleId: "capture", hideCompleted: true };