diff --git a/.beads/interactions.jsonl b/.beads/interactions.jsonl index 5a35d4b..50ba43e 100644 --- a/.beads/interactions.jsonl +++ b/.beads/interactions.jsonl @@ -501,3 +501,4 @@ {"id":"int-c432affacccf11095a7349e6a9cf1107","kind":"field_change","created_at":"2026-11-30T10:29:14.693613904Z","actor":"Shinuwa","issue_id":"sokko-g-akg7","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Pastille ajoutée (CardsPage navigationCounts.packs), test e2e mis à jour"}} {"id":"int-622c82c7a1fac1f9758f971874d8a80f","kind":"field_change","created_at":"2026-11-30T11:15:28.399226475Z","actor":"Shinuwa","issue_id":"sokko-g-wqfj","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"bonusOffers côté serveur + BonusOffers dans le planificateur. npm run check 463/463, e2e cards 15/15."}} {"id":"int-e75296b6fbef720fbc6ae7cf1f92fb25","kind":"field_change","created_at":"2026-11-30T12:14:21.343085085Z","actor":"Shinuwa","issue_id":"sokko-g-8qjt","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"npm run check 463/463, e2e cards 15/15."}} +{"id":"int-5f9231ef4e37eb6f4a922438fd43ef78","kind":"field_change","created_at":"2026-11-30T13:00:01.89545152Z","actor":"Shinuwa","issue_id":"sokko-g-p2gx","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Tiroir de toolbox ouvert sur toutes les routes /cards via la clé sokko-tcg ; tests unitaires et e2e ajoutés."}} diff --git a/docs/STORAGE_SCHEMA.md b/docs/STORAGE_SCHEMA.md index 277941d..314f19d 100644 --- a/docs/STORAGE_SCHEMA.md +++ b/docs/STORAGE_SCHEMA.md @@ -822,6 +822,10 @@ Les associations entre pages jeux et toolboxes sont stockées dans `kv/links`. } ``` +Sokko TCG n'a pas de liaison : son tiroir liste toutes les toolboxes, liées à un jeu ou non. `localStorage["sokkog:cards-toolbox"]` +retient l'identifiant de la dernière toolbox choisie, pour la rouvrir directement ; une préférence de l'appareil, jamais exportée +ni sauvegardée. Une toolbox supprimée depuis ramène simplement à la liste. + ## Outil Bloc Note Type : `notepad` diff --git a/e2e/nebula-cards.spec.js b/e2e/nebula-cards.spec.js index ad7ab8f..26d377f 100644 --- a/e2e/nebula-cards.spec.js +++ b/e2e/nebula-cards.spec.js @@ -4,6 +4,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { DatabaseSync } from "node:sqlite"; import { expect, test } from "@playwright/test"; +import { readStoredSnapshot } from "./helpers/storage.js"; // Sélecteurs à choix unique du design system (`SelectDropdown`). const selectTrigger = (scope, label) => scope.getByRole("button", { name: new RegExp(`^${label} : `) }); @@ -2705,3 +2706,58 @@ test("an administrator opens the broken mirror and a player rebuilds the easy an await page.getByRole("dialog").getByRole("button", { name: "Fermer", exact: true }).click(); await expect(status).toContainText("Fermé aux joueurs"); }); + +test("the Sokko TCG drawer opens any toolbox from a list and remembers the choice", async ({ page }) => { + test.setTimeout(60_000); + await page.setViewportSize({ width: 1600, height: 900 }); + await page.goto("/#/cards/guild"); + await page.getByRole("button", { name: "Version développement", exact: true }).click(); + await expect(page.locator(".nebula-quests")).toBeVisible(); + const drawer = page.locator("#toolbox-drawer"); + const openedTitle = (name) => drawer.getByRole("heading", { level: 1, name, exact: true }); + const createInDrawer = async (name) => { + await drawer.getByRole("button", { name: "Nouvelle toolbox", exact: true }).click(); + await page.getByRole("textbox", { name: "Nom", exact: true }).fill(name); + await page.getByRole("button", { name: "Créer", exact: true }).click(); + await expect(openedTitle(name)).toBeVisible(); + }; + + // Sans toolbox, le tiroir propose d'en créer une : elle s'y ouvre sans quitter le jeu. + await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click(); + await expect(drawer).toContainText("Aucune toolbox pour l’instant."); + await createInDrawer("Notes TCG"); + await expect(page).toHaveURL(/#\/cards\/guild$/); + + // Passer de la Guilde aux Expéditions garde la toolbox ouverte. + await page.goto("/#/cards/expeditions"); + await expect(page.getByRole("button", { name: "Masquer la toolbox", exact: true })).toHaveAttribute("aria-pressed", "true"); + await expect(openedTitle("Notes TCG")).toBeVisible(); + + // « Changer de toolbox » ramène à la liste, d'où l'on en crée ou en ouvre une autre. + await drawer.getByRole("button", { name: "Changer de toolbox", exact: true }).click(); + await expect(drawer.getByRole("heading", { name: "Quelle toolbox ouvrir ?" })).toBeVisible(); + await expect(drawer.locator(".drawer-toolbox-chooser-row")).toHaveText(["Notes TCGToolbox libre"]); + await createInDrawer("Build"); + + // Le choix est retenu : après un rechargement, le tiroir rouvre directement « Build » (une fois la toolbox enregistrée). + await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.map((toolbox) => toolbox.name)).toContain("Build"); + await page.reload(); + await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click(); + await expect(openedTitle("Build")).toBeVisible(); + + // Une toolbox liée à un jeu reste disponible dans Sokko TCG, sans perdre sa liaison. La liste suit l'ordre de la page Toolboxes. + await page.goto("/#/games/mhwilds"); + await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click(); + await drawer.getByLabel("Toolbox disponible").selectOption({ label: "Notes TCG" }); + await drawer.getByRole("button", { name: "Associer", exact: true }).click(); + await expect(openedTitle("Notes TCG")).toBeVisible(); + await page.goto("/#/cards/collection"); + await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click(); + await drawer.getByRole("button", { name: "Changer de toolbox", exact: true }).click(); + await expect(drawer.locator(".drawer-toolbox-chooser-row")).toHaveText(["BuildToolbox libre", "Notes TCGMonster Hunter Wilds"]); + await drawer.getByRole("button", { name: /^Notes TCG/ }).click(); + await expect(openedTitle("Notes TCG")).toBeVisible(); + await page.goto("/#/games/mhwilds"); + await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click(); + await expect(openedTitle("Notes TCG")).toBeVisible(); +}); diff --git a/tests/helpers/data-validation.mjs b/tests/helpers/data-validation.mjs index ce40a4f..8c677e3 100644 --- a/tests/helpers/data-validation.mjs +++ b/tests/helpers/data-validation.mjs @@ -101,6 +101,7 @@ export function validateSiteContent(site) { "topbar.cards", "topbar.gameViewLabel", "topbar.guideView", + "topbar.cardsView", "topbar.toolboxView", "gamesPage.eyebrow", "gamesPage.title", @@ -942,6 +943,13 @@ export function validateSiteContent(site) { "toolboxes.drawer.selectPlaceholder", "toolboxes.drawer.noAvailable", "toolboxes.drawer.linkLabel", + "toolboxes.drawer.chooser.eyebrow", + "toolboxes.drawer.chooser.title", + "toolboxes.drawer.chooser.actionsLabel", + "toolboxes.drawer.chooser.changeLabel", + "toolboxes.drawer.chooser.freeLabel", + "toolboxes.drawer.chooser.emptyText", + "toolboxes.drawer.chooser.createLabel", "toolboxes.title", "toolboxes.newButton", "toolboxes.createShortButton", diff --git a/tests/toolbox-alert-visibility.test.mjs b/tests/toolbox-alert-visibility.test.mjs index 3f6ab85..b779ac7 100644 --- a/tests/toolbox-alert-visibility.test.mjs +++ b/tests/toolbox-alert-visibility.test.mjs @@ -4,11 +4,14 @@ import assert from "node:assert/strict"; import { getVisibleToolboxIds } from "../website/src/hooks/useToolboxAlerts.js"; test("a mounted compact drawer is visible only while its toolbox view is selected", () => { - const links = { mhwilds: "linked" }; - assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "", links)], []); - assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "mhwilds", links)], ["linked"]); + assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "")], []); + assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "linked")], ["linked"]); +}); + +test("the toolbox chosen in the Sokko TCG drawer is visible like a linked one", () => { + assert.deepEqual([...getVisibleToolboxIds("/cards/guild", "chosen")], ["chosen"]); }); test("a full toolbox page remains visible independently of the game drawer", () => { - assert.deepEqual([...getVisibleToolboxIds("/toolbox/personal", "", {})], ["personal"]); + assert.deepEqual([...getVisibleToolboxIds("/toolbox/personal", "")], ["personal"]); }); diff --git a/tests/toolbox-targets.test.mjs b/tests/toolbox-targets.test.mjs new file mode 100644 index 0000000..02a39fe --- /dev/null +++ b/tests/toolbox-targets.test.mjs @@ -0,0 +1,38 @@ +// Rôle : vérifie quelles pages ouvrent le tiroir de toolbox et quelle toolbox il affiche : la toolbox liée d'un jeu, ou celle +// choisie dans Sokko TCG, sans liaison. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { CARDS_TOOLBOX_TARGET_ID, getDrawerToolboxId, getRouteToolboxTargetId } from "../website/src/features/toolboxes/toolboxTargets.js"; + +test("a game page targets its game", () => { + assert.equal(getRouteToolboxTargetId("/games/mhwilds"), "mhwilds"); + assert.equal(getRouteToolboxTargetId("/games/mhwilds/monsters"), "mhwilds"); +}); + +test("every Sokko TCG section shares the same target", () => { + for (const route of ["/cards", "/cards/guild", "/cards/expeditions", "/cards/expeditions/abc", "/cards/admin/catalog"]) { + assert.equal(getRouteToolboxTargetId(route), CARDS_TOOLBOX_TARGET_ID, route); + } +}); + +test("other pages have no target", () => { + for (const route of ["/", "/games", "/toolboxes", "/toolbox/abc", "/library", "/cardsx", "/games/sokko-tcg"]) { + assert.equal(getRouteToolboxTargetId(route), "", route); + } +}); + +test("a game drawer shows the toolbox linked to the game", () => { + const links = { mhwilds: "tbx1" }; + assert.equal(getDrawerToolboxId("mhwilds", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), "tbx1"); + assert.equal(getDrawerToolboxId("diablo4", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), ""); + assert.equal(getDrawerToolboxId("", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), ""); +}); + +test("the Sokko TCG drawer shows the chosen toolbox, linked to a game or not, until it is deleted", () => { + const links = { mhwilds: "tbx1" }; + const toolboxes = [{ id: "tbx1" }, { id: "tbx2" }]; + assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx1", toolboxes), "tbx1"); + assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx2", toolboxes), "tbx2"); + assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "", toolboxes), ""); + assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "deleted", toolboxes), ""); +}); diff --git a/website/public/data/site.json b/website/public/data/site.json index 825ec49..26fdc96 100644 --- a/website/public/data/site.json +++ b/website/public/data/site.json @@ -25,6 +25,7 @@ "cards": "Sokko TCG", "gameViewLabel": "Vue de la page jeu", "guideView": "Guide", + "cardsView": "Jeu", "toolboxView": "Toolbox" }, "gamesPage": { @@ -2922,7 +2923,16 @@ "selectLabel": "Toolbox disponible", "selectPlaceholder": "Choisir une toolbox", "noAvailable": "Aucune toolbox disponible", - "linkLabel": "Associer" + "linkLabel": "Associer", + "chooser": { + "eyebrow": "Toolbox", + "title": "Quelle toolbox ouvrir ?", + "actionsLabel": "Actions de la toolbox ouverte", + "changeLabel": "Changer de toolbox", + "freeLabel": "Toolbox libre", + "emptyText": "Aucune toolbox pour l’instant.", + "createLabel": "Nouvelle toolbox" + } }, "storageStatus": { "loadingTitle": "Chargement des données locales", diff --git a/website/src/components/AppOverlays.jsx b/website/src/components/AppOverlays.jsx index 77e9b59..458bbcc 100644 --- a/website/src/components/AppOverlays.jsx +++ b/website/src/components/AppOverlays.jsx @@ -65,7 +65,9 @@ export function AppOverlays({ if (!name) return; const toolbox = actions.createToolbox(name, gameId, { tutorial: createModal.tutorial === true }); if (toolbox && createModal.tutorial === true) setPendingTutorialToolboxId?.(toolbox.id); - if (toolbox && gameId) setDrawerGameId(gameId); + // Créée depuis le tiroir de Sokko TCG : elle s'y ouvre, sans liaison ni changement de page. + if (toolbox && createModal.onCreated) createModal.onCreated(toolbox); + else if (toolbox && gameId) setDrawerGameId(gameId); else if (toolbox) { navigate(`/toolbox/${toolbox.id}`); scrollToTopAfterNavigation(); diff --git a/website/src/components/Shell.jsx b/website/src/components/Shell.jsx index 8ec0041..6a20e1f 100644 --- a/website/src/components/Shell.jsx +++ b/website/src/components/Shell.jsx @@ -5,11 +5,10 @@ import { Icon } from "./Icon.jsx"; import { ImportButton } from "./ImportButton.jsx"; import { Tooltip } from "./Tooltip.jsx"; -export function Shell({ route, content, games, drawerGameId = "", drawerVisible = false, compactGameLayout = false, reducedSidebar = false, cardsEnabled = false, actions, onOpenAutoBackup, children }) { - const gameId = route.split("/")[1] === "games" ? route.split("/")[2] || "" : ""; - const game = games.find((item) => item.id === gameId); +// `toolboxTargetId` : le jeu (sa toolbox liée) ou Sokko TCG (une toolbox au choix) dont la page ouvre le tiroir, sinon vide. +export function Shell({ route, content, toolboxTargetId = "", drawerGameId = "", drawerVisible = false, compactGameLayout = false, reducedSidebar = false, cardsEnabled = false, actions, onOpenAutoBackup, children }) { const topbarLabel = route === "/design-system" && import.meta.env.DEV ? "Design system" : route.startsWith("/toolbox") || route.startsWith("/receive/") ? content.topbar.toolbox : route.startsWith("/games") ? content.topbar.games : route === "/library" ? content.topbar.library : route.startsWith("/cards") ? content.topbar.cards : content.topbar.dashboard; - const toolboxOpen = Boolean(game && drawerGameId === game.id && drawerVisible); + const toolboxOpen = Boolean(toolboxTargetId && drawerGameId === toolboxTargetId && drawerVisible); const toolboxLabel = toolboxOpen ? "Masquer la toolbox" : "Afficher la toolbox"; const compactSidebar = Boolean(reducedSidebar || (!compactGameLayout && toolboxOpen)); const compactToolboxVisible = Boolean(compactGameLayout && toolboxOpen); @@ -80,17 +79,17 @@ export function Shell({ route, content, games, drawerGameId = "", drawerVisible