Refine toolbox navigation and local data controls
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s
This commit is contained in:
parent
954240adf9
commit
2f2e79d200
27 changed files with 614 additions and 302 deletions
|
|
@ -65,11 +65,17 @@ async function disk(page) {
|
|||
}
|
||||
|
||||
async function exportJson(page, buttonName = "Exporter tout") {
|
||||
const globalExport = buttonName === "Exporter tout";
|
||||
const management = page.getByRole("dialog", { name: "Données et préférences" });
|
||||
if (globalExport && !await management.isVisible()) {
|
||||
await page.getByRole("button", { name: "Données et préférences", exact: true }).click();
|
||||
}
|
||||
const download = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: buttonName, exact: true }).click();
|
||||
await (globalExport ? management : page).getByRole("button", { name: buttonName, exact: true }).click();
|
||||
const stream = await (await download).createReadStream();
|
||||
const chunks = [];
|
||||
for await (const chunk of stream) chunks.push(chunk);
|
||||
if (globalExport) await management.getByRole("button", { name: "Fermer", exact: true }).last().click();
|
||||
return JSON.parse(Buffer.concat(chunks).toString());
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +186,8 @@ test("failed media exports produce no partial download and can be retried", asyn
|
|||
const downloads = [];
|
||||
page.on("download", (download) => downloads.push(download));
|
||||
await page.evaluate(() => { window.failedMediaKey = "b:images"; });
|
||||
await page.getByRole("button", { name: "Exporter tout", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Données et préférences", exact: true }).click();
|
||||
await page.getByRole("dialog", { name: "Données et préférences" }).getByRole("button", { name: "Exporter tout", exact: true }).click();
|
||||
const dialog = page.getByRole("dialog", { name: "Erreur de stockage local" });
|
||||
await expect(dialog).toBeVisible();
|
||||
expect(downloads).toHaveLength(0);
|
||||
|
|
|
|||
|
|
@ -75,8 +75,10 @@ for (const fault of ["open", "read"]) {
|
|||
expect(await snapshot(page)).toEqual(original);
|
||||
|
||||
await page.evaluate(() => { window.location.hash = "/toolboxes"; });
|
||||
await page.getByRole("button", { name: "Données et préférences", exact: true }).click();
|
||||
const management = page.getByRole("dialog", { name: "Données et préférences" });
|
||||
const downloadPromise = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Exporter tout", exact: true }).click();
|
||||
await management.getByRole("button", { name: "Exporter tout", exact: true }).click();
|
||||
const download = await downloadPromise;
|
||||
const stream = await download.createReadStream();
|
||||
const chunks = [];
|
||||
|
|
@ -85,6 +87,7 @@ for (const fault of ["open", "read"]) {
|
|||
expect(exported.toolboxes[0].id).toBe("saved");
|
||||
expect(exported.modules["saved:note"].items[0].text).toBe("Ne pas perdre");
|
||||
expect(await snapshot(page)).toEqual(original);
|
||||
await management.getByRole("button", { name: "Fermer", exact: true }).last().click();
|
||||
|
||||
await page.getByRole("button", { name: "Nouvelle toolbox", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Nom", exact: true }).fill("Après reprise");
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ for (const width of [1920, 1280, 1025, 1024, 960, 768]) {
|
|||
const storageActions = await page.locator(".sidebar-action-button").evaluateAll((elements) => elements.map((element) => element.getBoundingClientRect()));
|
||||
expect(storageActions[1].x).toBeGreaterThan(storageActions[0].x);
|
||||
expect(storageActions[1].y).toBeCloseTo(storageActions[0].y, 0);
|
||||
await expect(page.locator(".sidebar-storage-action-label")).toBeVisible();
|
||||
const secondaryBox = await secondaryLinks.boundingBox();
|
||||
const storageBox = await page.locator(".sidebar-note").boundingBox();
|
||||
expect(secondaryBox.y + secondaryBox.height).toBeLessThan(storageBox.y);
|
||||
|
|
@ -142,7 +143,8 @@ for (const width of [1280, 768]) {
|
|||
<article class="module layout-calculator" data-module-type="calculator"><div class="calculator-module"><div>Formula</div><div class="calculator-result"><strong>12</strong></div></div></article>
|
||||
<div class="task-planner-module"><div class="task-planner-settings"><label>Reset</label><label>Time</label></div></div>
|
||||
<div class="equipment-planner-summary"><div class="equipment-planner-summary-source-grid"><div>Equipment</div><div>Materials</div></div></div>
|
||||
<div class="toolbox-actions-row"><div>Actions</div><div>Preferences</div></div>
|
||||
<section class="page-hero nds-page-hero primary-list-hero toolbox-list-hero"><div><h1>Toolboxes</h1><p>Collection locale</p><div class="toolbox-list-primary-actions nds-toolbar"><button>Créer</button><button>Importer</button></div></div></section>
|
||||
<div class="toolbox-list-actions nds-toolbar"><button>Préférences</button><button>Librairie</button></div>
|
||||
</main>`);
|
||||
await columns(page.locator(".game-layout"), 1);
|
||||
await expect(page.locator(".game-grid")).toHaveCSS("display", "grid");
|
||||
|
|
@ -156,7 +158,10 @@ for (const width of [1280, 768]) {
|
|||
await columns(page.locator(".equipment-planner-summary-source-grid"), width <= 760 ? 1 : 2);
|
||||
await page.locator(".equipment-planner-summary-source-grid").evaluate((element) => element.classList.add("columns-1"));
|
||||
await columns(page.locator(".equipment-planner-summary-source-grid"), 1);
|
||||
await expect(page.locator(".toolbox-actions-row")).toHaveCSS("flex-direction", width <= 760 ? "column" : "row");
|
||||
await columns(page.locator(".toolbox-list-hero"), 2);
|
||||
await expect(page.locator(".toolbox-list-hero")).toHaveCSS("min-height", "195px");
|
||||
await expect(page.locator(".toolbox-list-primary-actions")).toHaveCSS("justify-content", "flex-start");
|
||||
await expect(page.locator(".toolbox-list-actions")).toHaveCSS("justify-content", "flex-end");
|
||||
await page.locator(".modules").evaluate((element) => { element.dataset.layoutCols = "1"; });
|
||||
await columns(page.locator(".modules"), 1);
|
||||
await expectFits(page.locator("main"));
|
||||
|
|
|
|||
145
e2e/toolbox-list.spec.js
Normal file
145
e2e/toolbox-list.spec.js
Normal 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/);
|
||||
});
|
||||
|
|
@ -328,8 +328,9 @@ test("imports and exports a toolbox payload", async ({ page }) => {
|
|||
|
||||
test("opens the local automatic backup settings modal", async ({ page }) => {
|
||||
await page.goto("/#/toolboxes");
|
||||
await expect(page.getByRole("button", { name: "Sauvegarde automatique", exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Sauvegarde automatique", exact: true }).click();
|
||||
const backupButton = page.locator(".sidebar-note").getByRole("button", { name: "Sauvegarde automatique", exact: true });
|
||||
await expect(backupButton).toBeVisible();
|
||||
await backupButton.click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Sauvegarde automatique" });
|
||||
await expect(dialog).toBeVisible();
|
||||
|
|
@ -343,9 +344,17 @@ test("opens the local automatic backup settings modal", async ({ page }) => {
|
|||
await expect(dialog.getByText("Dossier configuré :", { exact: true })).toBeVisible();
|
||||
await expect(dialog.getByText("Aucun dossier", { exact: true })).toBeVisible();
|
||||
await expect(dialog.getByRole("checkbox")).toBeVisible();
|
||||
const [settingsBox, compatibilityBox, guideBox] = await Promise.all([
|
||||
dialog.locator(".auto-backup-settings").boundingBox(),
|
||||
dialog.locator(".auto-backup-compatibility").boundingBox(),
|
||||
dialog.locator(".auto-backup-permission-guide").boundingBox()
|
||||
]);
|
||||
expect(compatibilityBox.y).toBeGreaterThanOrEqual(settingsBox.y + settingsBox.height);
|
||||
expect(guideBox.y).toBeGreaterThanOrEqual(compatibilityBox.y + compatibilityBox.height);
|
||||
|
||||
await dialog.getByRole("button", { name: "Fermer", exact: true }).last().click();
|
||||
await expect(dialog).toHaveCount(0);
|
||||
await expect(backupButton).toBeFocused();
|
||||
});
|
||||
|
||||
test("offers an actionable backup alert without requesting permission at startup", async ({ page }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue