Improve toolbox persistence and goal tree coverage
All checks were successful
Deploy Sokko G / deploy (push) Successful in 15s

This commit is contained in:
Shinuwa 2026-08-24 16:11:22 +02:00
parent 50029b45a2
commit 7348969ac4
10 changed files with 801 additions and 591 deletions

65
e2e/toolbox.spec.js Normal file
View file

@ -0,0 +1,65 @@
// Rôle : couvre les parcours navigateur principaux des toolboxes locales.
import { expect, test } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { resetSokkoStorage } from "./helpers/storage.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixturePath = path.join(__dirname, "fixtures", "toolbox-export.json");
async function createToolbox(page, name) {
await page.goto("/#/toolboxes");
await expect(page.getByRole("main")).toBeVisible();
await page.getByRole("button", { name: "Nouvelle toolbox" }).click();
const dialog = page.getByRole("dialog", { name: "Nouvelle toolbox" });
await expect(dialog).toBeVisible();
await dialog.getByLabel("Nom").fill(name);
await dialog.getByRole("button", { name: "Créer" }).click();
await expect(page.getByRole("heading", { name })).toBeVisible();
}
test.beforeEach(async ({ page }) => {
await resetSokkoStorage(page);
});
test("creates a toolbox and lazy-loads an added tool", async ({ page }) => {
await createToolbox(page, "E2E Toolbox");
await expect(page.getByRole("heading", { name: "E2E Toolbox" })).toBeVisible();
await expect(page.locator("[data-module-type='notepad']")).toBeVisible();
await expect(page.locator("[data-module-type='links']")).toBeVisible();
await page.getByRole("button", { name: "Ajouter un outil", exact: true }).click();
const addDialog = page.getByRole("dialog", { name: "Ajouter un outil" });
await addDialog.getByRole("button", { name: "Arbre d'objectifs" }).click();
await expect(page.locator("[data-module-type='goalTree']")).toBeVisible();
});
test("creates a game-linked toolbox from the drawer", async ({ page }) => {
await page.goto("/#/games/mhwilds");
await expect(page.getByRole("heading", { name: /Monster Hunter.*Wilds/ })).toBeVisible();
await page.getByRole("button", { name: "Associer une toolbox" }).click();
const drawer = page.locator("#toolbox-drawer .drawer-panel");
await expect(drawer).toBeVisible();
await drawer.getByRole("button", { name: "Créer et associer" }).click();
const dialog = page.getByRole("dialog", { name: "Créer et associer une toolbox" });
await expect(dialog.getByLabel("Nom")).toHaveValue(/Monster Hunter.*Wilds/);
await dialog.getByRole("button", { name: "Créer" }).click();
await expect(drawer.getByRole("heading", { name: /Monster Hunter.*Wilds/ })).toBeVisible();
await expect(drawer.locator("[data-module-type='notepad']")).toBeVisible();
await expect(page.getByRole("button", { name: /Ouvrir la toolbox Monster Hunter.*Wilds/ })).toBeVisible();
});
test("imports and exports a toolbox payload", async ({ page }) => {
await page.goto("/#/toolboxes");
await expect(page.getByRole("main")).toBeVisible();
await page.getByText("Importer une toolbox").locator("input[type='file']").setInputFiles(fixturePath);
await expect(page.getByRole("link", { name: "Ouvrir Fixture Toolbox" }).first()).toBeVisible();
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "Exporter Fixture Toolbox" }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe("fixture-toolbox.sokkog.json");
});