Refine toolbox navigation and local data controls
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s

This commit is contained in:
Shinuwa 2026-10-15 10:52:34 +02:00
parent 954240adf9
commit 2f2e79d200
27 changed files with 614 additions and 302 deletions

145
e2e/toolbox-list.spec.js Normal file
View file

@ -0,0 +1,145 @@
// Rôle : valide l’accès immédiat aux toolboxes et aux réglages locaux de la collection.
/* global document */
import { expect, test } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
function toolbox(id, name) {
return {
id,
name,
modules: [],
updatedAt: `2026-10-${String(Number(id.replace("toolbox-", "")) + 1).padStart(2, "0")}T10:00:00.000Z`
};
}
async function seedToolboxes(page, toolboxes, links = {}) {
await page.evaluate(async ({ nextToolboxes, nextLinks }) => {
const db = await import("/src/utils/indexedDbStorage.js");
await db.setToolboxSnapshot(nextToolboxes, nextLinks, {});
}, { nextToolboxes: toolboxes, nextLinks: links });
await page.reload();
}
test.beforeEach(async ({ page }) => {
await page.setViewportSize({ width: 768, height: 720 });
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
});
test("keeps the empty action clear and groups local data settings in one dialog", async ({ page }) => {
await expect(page.getByRole("heading", { name: "Aucune toolbox" })).toBeVisible();
await expect(page.getByRole("button", { name: "Créer ma première toolbox" })).toBeVisible();
const automaticBackup = page.locator(".sidebar-note").getByRole("button", { name: "Sauvegarde automatique" });
await expect(automaticBackup).toBeVisible();
await expect(automaticBackup).toHaveAttribute("data-variant", "primary");
await expect(page.locator(".sidebar-note").getByRole("button", { name: "Importer toutes les toolboxes" })).toBeVisible();
await expect(page.locator(".sidebar-note").getByRole("button", { name: "Exporter toutes les toolboxes" })).toHaveCount(0);
await expect(page.getByLabel("Budget recommandé de stockage local")).toBeVisible();
const individualImport = page.locator(".toolbox-list-hero").getByRole("button", { name: "Importer une toolbox" });
await expect(individualImport).toBeVisible();
await individualImport.focus();
const fileChooser = page.waitForEvent("filechooser");
await individualImport.press("Enter");
await fileChooser;
const managementTrigger = page.getByRole("button", { name: "Données et préférences" });
await managementTrigger.click();
const management = page.getByRole("dialog", { name: "Données et préférences" });
await expect(management).toBeVisible();
await expect(management.getByRole("radio", { checked: true })).toBeFocused();
await expect(management.getByRole("button", { name: "Importer tout" })).toBeVisible();
await expect(management.getByRole("radiogroup", { name: "Positionnement des alertes" })).toBeVisible();
const preferencesHeading = management.getByRole("heading", { name: "Positionnement des alertes" });
const transfersHeading = management.getByRole("heading", { name: "Transferts de la collection" });
const [preferencesBox, transfersBox] = await Promise.all([preferencesHeading.boundingBox(), transfersHeading.boundingBox()]);
expect(preferencesBox.y).toBeLessThan(transfersBox.y);
const storageDetails = management.getByText("Comprendre le stockage local", { exact: true });
await storageDetails.focus();
await storageDetails.press("Enter");
await expect(management.getByText(/Rien n’est envoyé sur un serveur/)).toBeVisible();
await page.keyboard.press("Escape");
await expect(management).toHaveCount(0);
await expect(managementTrigger).toBeFocused();
await page.setViewportSize({ width: 1280, height: 720 });
const backupLabel = page.locator(".sidebar-storage-action-label");
await expect(backupLabel).toBeVisible();
await expect(backupLabel).toHaveText("Sauvegarde auto");
await expect(automaticBackup).toHaveCSS("padding-left", "8px");
await expect(automaticBackup).toHaveCSS("padding-right", "8px");
const sidebarImport = page.locator(".sidebar-note").getByRole("button", { name: "Importer toutes les toolboxes" });
await expect(sidebarImport).toHaveText("");
await expect(automaticBackup.locator(".ui-icon")).toHaveCount(0);
await expect(sidebarImport.locator(".ui-icon")).toHaveCount(1);
const [noteBox, actionsBox, backupBox, importBox] = await Promise.all([
page.locator(".sidebar-note").boundingBox(),
page.locator(".sidebar-storage-actions").boundingBox(),
automaticBackup.boundingBox(),
sidebarImport.boundingBox()
]);
expect(actionsBox.width).toBeLessThan(noteBox.width - 16);
expect(importBox.x).toBeGreaterThan(backupBox.x + backupBox.width);
expect(importBox.y).toBeCloseTo(backupBox.y, 0);
expect(importBox.height).toBeCloseTo(backupBox.height, 0);
expect(backupBox.height).toBeCloseTo(34, 0);
expect(importBox.width).toBeCloseTo(34, 0);
});
test("uses the same hero height as the games page", async ({ page }) => {
const toolboxHeroHeight = (await page.locator(".toolbox-list-hero").boundingBox()).height;
await page.goto("/#/games");
const gamesHero = page.locator(".page-hero");
await expect(gamesHero).toBeVisible();
const gamesHeroHeight = (await gamesHero.boundingBox()).height;
expect(toolboxHeroHeight).toBeCloseTo(gamesHeroHeight, 0);
});
test("shows one long game-linked toolbox name and its open action without scrolling", async ({ page }) => {
const longName = "Toolbox de préparation extrêmement longue pour la prochaine expédition coopérative";
await seedToolboxes(page, [toolbox("toolbox-1", longName)], { mhwilds: "toolbox-1" });
const card = page.locator(".toolbox-card");
const name = card.getByRole("heading", { name: longName });
const open = card.getByRole("link", { name: `Ouvrir ${longName}` }).first();
await expect(name).toBeVisible();
await expect(open).toBeVisible();
await expect(card.getByText(/Monster Hunter.*Wilds/)).toBeVisible();
const [nameBox, openBox] = await Promise.all([name.boundingBox(), open.boundingBox()]);
expect(nameBox.y + nameBox.height).toBeLessThanOrEqual(720);
expect(openBox.y + openBox.height).toBeLessThanOrEqual(720);
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(768);
});
test("renders ten toolboxes without overflow and persists card reordering", async ({ page }) => {
const toolboxes = Array.from({ length: 10 }, (_, index) => toolbox(
`toolbox-${index + 1}`,
`Collection ${index + 1} — préparation détaillée avec un nom volontairement très long`
));
await seedToolboxes(page, toolboxes, { mhwilds: "toolbox-1", diablo4: "toolbox-2" });
const cards = page.locator(".toolbox-card");
await expect(cards).toHaveCount(10);
await expect(page.locator(".toolbox-collection-heading .nds-badge")).toHaveText("10");
const [titleBox, badgeBox] = await Promise.all([
page.getByRole("heading", { name: "Mes toolboxes" }).boundingBox(),
page.locator(".toolbox-collection-heading .nds-badge").boundingBox()
]);
expect(badgeBox.x).toBeGreaterThanOrEqual(titleBox.x + titleBox.width);
expect(badgeBox.x - (titleBox.x + titleBox.width)).toBeLessThanOrEqual(12);
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(768);
const sourceHandle = cards.nth(0).getByRole("button", { name: /Déplacer Collection 1/ });
const target = cards.nth(1);
const [sourceBox, targetBox] = await Promise.all([sourceHandle.boundingBox(), target.boundingBox()]);
await page.mouse.move(sourceBox.x + sourceBox.width / 2, sourceBox.y + sourceBox.height / 2);
await page.mouse.down();
await page.mouse.move(targetBox.x + targetBox.width * 0.8, targetBox.y + targetBox.height / 2, { steps: 8 });
await page.mouse.up();
await expect(cards.nth(0).getByRole("heading")).toHaveText(/Collection 2/);
await page.reload();
await expect(cards.nth(0).getByRole("heading")).toHaveText(/Collection 2/);
});