Let players use Sokko TCG from a phone through a mobile fallback mode
#/mobile/cards shows the game without the site shell: a title, a footer with the account and a discreet "Version complète" link, and a tab bar fixed at the bottom. Phones opening #/cards are sent to the same section in mobile mode unless the player chose the full version. Account, History and Administration point to the computer. The panels are the computer ones, adapted under .nebula-mobile (and body.nebula-mobile-body for dialogs) for a 393×852 reference phone: small cards with names under them when opening packs, a revealed card shown large on tap, tap-to-pick team recruitment with a single Recruit button and large stars, row lists for explorers and commons in the expedition pickers, a race track and circuit that read at phone size, and full-width actions throughout. Firefox no longer shows a mirrored back on a flipped card. Phone Playwright journeys check that every section fits the screen with no button wrapping, then open a pack, run an expedition and recruit a team by touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0262f596c9
commit
c3e494b8a6
53 changed files with 1830 additions and 123 deletions
|
|
@ -16,7 +16,7 @@ npm run test:cards # seulement le TCG
|
|||
| Fichiers | Sujet |
|
||||
| --- | --- |
|
||||
| `data-validation.test.mjs` + `helpers/data-validation.mjs` | Contenu éditable : `site.json`, données de jeux, Librairie. **Toute nouvelle clé de texte se déclare ici.** |
|
||||
| `nebula-cards*.test.mjs` | Sokko TCG : règles pures, service avec une base SQLite en mémoire, API HTTP, Carte du jour, Expéditions et leur équilibrage, Équipe du jour, Miroir brisé |
|
||||
| `nebula-cards*.test.mjs` | Sokko TCG : règles pures, service avec une base SQLite en mémoire, API HTTP, Carte du jour, Expéditions et leur équilibrage, Équipe du jour, Miroir brisé, adresses et redirection du mode mobile (`nebula-cards-mobile.test.mjs`) |
|
||||
| `server-*.test.mjs`, `static-app.test.mjs`, `deployment-workflow.test.mjs`, `project-env.test.mjs` | Serveur Node (cache, robustesse), application construite, livraison, lecture du `.env` |
|
||||
| `toolbox-modules.test.mjs`, `static-toolboxes.test.mjs`, `persistence-queue.test.mjs`, `deferred-module-data.test.mjs`, `quota-refresh.test.mjs`, `auto-backup.test.mjs`, `library-copy.test.mjs` | Toolboxes : normalisation des outils, file d'écriture, médias différés, sauvegarde, copie depuis la Librairie |
|
||||
| `file-headers.test.mjs`, `function-docs.test.mjs`, `static-styles.test.mjs`, `react-lint.test.mjs`, `toolbox-compactors.test.mjs` | Règles d'architecture vérifiées sur les sources : en-têtes `/** @file … */` du JS (rubriques des fichiers centraux et des gros fichiers), JSDoc des fonctions exportées (cliquet sur `fixtures/undocumented-exports.json`) et `// Rôle :` des feuilles Sass, blocs SassDoc `///` des mixins et fonctions, compacteur de chaque outil, taille des feuilles Sass, chargement des styles du TCG, règles React |
|
||||
|
|
|
|||
|
|
@ -129,6 +129,19 @@ export function validateSiteContent(site) {
|
|||
"cards.discordErrors.expired",
|
||||
"cards.discordErrors.failed",
|
||||
"cards.devLogin",
|
||||
"cards.mobile.tabs.home",
|
||||
"cards.mobile.tabs.guild",
|
||||
"cards.mobile.tabs.packs",
|
||||
"cards.mobile.tabs.collection",
|
||||
"cards.mobile.tabs.shop",
|
||||
"cards.mobile.tabs.transfers",
|
||||
"cards.mobile.fullVersion",
|
||||
"cards.mobile.mobileVersion",
|
||||
"cards.mobile.note",
|
||||
"cards.mobile.unavailableTitle",
|
||||
"cards.mobile.unavailableText",
|
||||
"cards.mobile.unavailableAction",
|
||||
"cards.mobile.backHome",
|
||||
"cards.admin.backToGame",
|
||||
"cards.admin.restrictedTitle",
|
||||
"cards.admin.restrictedText",
|
||||
|
|
@ -250,6 +263,9 @@ export function validateSiteContent(site) {
|
|||
"cards.packs.probabilities",
|
||||
"cards.packs.back",
|
||||
"cards.packs.openAnother",
|
||||
"cards.packs.openAnotherShort",
|
||||
"cards.packs.zoomCard",
|
||||
"cards.packs.zoomClose",
|
||||
"cards.packs.remainingLabel",
|
||||
"cards.packs.remainingReserve",
|
||||
"cards.packs.remainingPurchased",
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ test("Discord OAuth preserves the dedicated admin route", async (t) => {
|
|||
const oauthCookies = authorization.headers["set-cookie"];
|
||||
assert.ok(oauthCookies.some((cookie) => cookie.startsWith("sokkog_cards_oauth_return=%2Fcards%2Fadmin;")));
|
||||
// Le retour après connexion accepte les sections joueur, jamais une adresse hors de Sokko TCG.
|
||||
for (const [returnTo, expected] of [["/cards/shop", "%2Fcards%2Fshop"], ["/cards/admin/collections/nebula", "%2Fcards%2Fadmin%2Fcollections%2Fnebula"], ["/cards/shop/extra", "%2Fcards"], ["/cards/expeditions/34d49df0-2a37-4ba1-83a5-1832ed81c885", "%2Fcards%2Fexpeditions%2F34d49df0-2a37-4ba1-83a5-1832ed81c885"], ["//evil.example/cards", "%2Fcards"], ["/cards/../toolboxes", "%2Fcards"]]) {
|
||||
for (const [returnTo, expected] of [["/cards/shop", "%2Fcards%2Fshop"], ["/cards/admin/collections/nebula", "%2Fcards%2Fadmin%2Fcollections%2Fnebula"], ["/cards/shop/extra", "%2Fcards"], ["/cards/expeditions/34d49df0-2a37-4ba1-83a5-1832ed81c885", "%2Fcards%2Fexpeditions%2F34d49df0-2a37-4ba1-83a5-1832ed81c885"], ["//evil.example/cards", "%2Fcards"], ["/cards/../toolboxes", "%2Fcards"], ["/mobile/cards", "%2Fmobile%2Fcards"], ["/mobile/cards/packs", "%2Fmobile%2Fcards%2Fpacks"], ["/mobile/cards/expeditions/34d49df0-2a37-4ba1-83a5-1832ed81c885", "%2Fmobile%2Fcards%2Fexpeditions%2F34d49df0-2a37-4ba1-83a5-1832ed81c885"], ["/mobile/cards/admin", "%2Fcards"], ["/mobile/cards/../toolboxes", "%2Fcards"], ["/mobile/toolboxes", "%2Fcards"]]) {
|
||||
const response = await call(handler, { path: `/api/cards/auth/discord?returnTo=${encodeURIComponent(returnTo)}` });
|
||||
assert.ok(response.headers["set-cookie"].some((cookie) => cookie.startsWith(`sokkog_cards_oauth_return=${expected};`)), returnTo);
|
||||
}
|
||||
|
|
|
|||
78
tests/nebula-cards-mobile.test.mjs
Normal file
78
tests/nebula-cards-mobile.test.mjs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* @file Vérifie le mode mobile de dépannage de Sokko TCG sans navigateur : adresses des sections, règle de
|
||||
* redirection des téléphones, liens internes des panneaux et textes des onglets.
|
||||
*
|
||||
* Attention : le parcours dans un téléphone simulé est dans e2e/nebula-cards-mobile.spec.js.
|
||||
* @see DESIGN_SYSTEM.md (section 24, « Mode mobile de dépannage »)
|
||||
*/
|
||||
|
||||
import assert from "node:assert/strict";
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { CARDS_BASE, MOBILE_CARDS_BASE, MOBILE_SECTIONS, cardsRoute, isMobileCardsRoute, mobileRedirectTarget, parseMobileCardsRoute } from "../website/src/features/cards/cardsRoutes.js";
|
||||
|
||||
const phone = { phone: true, fullVersion: false };
|
||||
|
||||
test("section routes share their shape between the full version and the mobile mode", () => {
|
||||
assert.equal(cardsRoute(CARDS_BASE), "/cards");
|
||||
assert.equal(cardsRoute(CARDS_BASE, "home"), "/cards");
|
||||
assert.equal(cardsRoute(MOBILE_CARDS_BASE, "packs"), "/mobile/cards/packs");
|
||||
assert.equal(cardsRoute(MOBILE_CARDS_BASE, "expeditions", "abc-123"), "/mobile/cards/expeditions/abc-123");
|
||||
assert.equal(isMobileCardsRoute("/mobile/cards"), true);
|
||||
assert.equal(isMobileCardsRoute("/mobile/cards/guild"), true);
|
||||
assert.equal(isMobileCardsRoute("/mobile/cardsx"), false);
|
||||
assert.equal(isMobileCardsRoute("/cards/guild"), false);
|
||||
assert.deepEqual(parseMobileCardsRoute("/mobile/cards"), { section: "", subsection: "" });
|
||||
assert.deepEqual(parseMobileCardsRoute("/mobile/cards/expeditions/abc-123"), { section: "expeditions", subsection: "abc-123" });
|
||||
});
|
||||
|
||||
test("a phone opening a game section offered on mobile goes to the same section in the mobile mode", () => {
|
||||
assert.equal(mobileRedirectTarget("/cards", phone), "/mobile/cards");
|
||||
assert.equal(mobileRedirectTarget("/cards/packs", phone), "/mobile/cards/packs");
|
||||
assert.equal(mobileRedirectTarget("/cards/daily", phone), "/mobile/cards/daily");
|
||||
// Lien d'invitation à une expédition de groupe : le complément d'adresse suit.
|
||||
assert.equal(mobileRedirectTarget("/cards/expeditions/abc-123", phone), "/mobile/cards/expeditions/abc-123");
|
||||
// Ancienne adresse du recyclage, aujourd'hui dans la Collection.
|
||||
assert.equal(mobileRedirectTarget("/cards/recycling", phone), "/mobile/cards/recycling");
|
||||
});
|
||||
|
||||
test("sections kept on the computer, the rest of the site and other devices are never redirected", () => {
|
||||
for (const route of ["/cards/account", "/cards/history", "/cards/admin", "/cards/admin/guild/team", "/cards/unknown"]) assert.equal(mobileRedirectTarget(route, phone), "", route);
|
||||
for (const route of ["/", "/toolboxes", "/toolbox/abc", "/receive/abc", "/games/mhwilds", "/cardsx", "/mobile/cards"]) assert.equal(mobileRedirectTarget(route, phone), "", route);
|
||||
assert.equal(mobileRedirectTarget("/cards/packs", { phone: false, fullVersion: false }), "");
|
||||
assert.equal(mobileRedirectTarget("/cards/packs", { phone: true, fullVersion: true }), "");
|
||||
});
|
||||
|
||||
test("every mobile section is a player section, and every tab has its label", async () => {
|
||||
const page = await readFile("website/src/features/cards/CardsPage.jsx", "utf8");
|
||||
const navigation = JSON.parse(page.match(/const PLAYER_NAVIGATION = (\[.+\]);/)[1]);
|
||||
const subsections = Object.keys(JSON.parse(page.match(/const SUBSECTION_PARENTS = (\{.+\});/)[1].replace(/(\w+):/g, "\"$1\":")));
|
||||
const playerSections = new Set([...navigation.flat(), ...subsections]);
|
||||
for (const section of MOBILE_SECTIONS) assert.ok(playerSections.has(section), `${section} is not a player section`);
|
||||
for (const section of ["account", "history"]) assert.equal(MOBILE_SECTIONS.has(section), false, `${section} stays on the computer`);
|
||||
|
||||
const layout = await readFile("website/src/features/cards/mobile/MobileCardsLayout.jsx", "utf8");
|
||||
const tabs = JSON.parse(layout.match(/const MOBILE_TABS = (\[.+\]);/)[1]);
|
||||
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
|
||||
for (const tab of tabs) {
|
||||
assert.ok(MOBILE_SECTIONS.has(tab), `tab ${tab} is not offered on mobile`);
|
||||
assert.ok(site.cards.mobile.tabs[tab], `tab ${tab} has no label`);
|
||||
}
|
||||
});
|
||||
|
||||
test("player panels never hard-code a #/cards link, so a phone player stays in the mobile mode", async () => {
|
||||
const root = "website/src/features/cards";
|
||||
const files = (await readdir(root, { recursive: true })).filter((path) => /\.jsx?$/.test(path) && !path.startsWith("admin"));
|
||||
const offenders = [];
|
||||
for (const path of files) {
|
||||
const lines = (await readFile(join(root, path), "utf8")).split("\n");
|
||||
lines.forEach((line, index) => {
|
||||
// Un lien interne commence par « #/cards » dans une chaîne ; l'administration garde sa propre adresse.
|
||||
// Les liens à partager (`${origin}/#/cards/...`) ne sont pas concernés : la redirection s'occupe des téléphones.
|
||||
if (/^\s*(\*|\/\/|\/\*)/.test(line)) return;
|
||||
if (/["'`]#\/cards(?!\/admin)/.test(line)) offenders.push(`${path}:${index + 1}`);
|
||||
});
|
||||
}
|
||||
assert.deepEqual(offenders, [], "use useCardsHref() (website/src/features/cards/useCardsHref.js) instead");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue