Add real toolbox module e2e coverage
All checks were successful
Deploy Sokko G / deploy (push) Successful in 15s

This commit is contained in:
Shinuwa 2026-08-25 08:30:46 +02:00
parent 6dd64f87c3
commit 7d2a25c672

View file

@ -25,6 +25,14 @@ async function addTool(page, name) {
await addDialog.getByRole("button", { name }).click(); await addDialog.getByRole("button", { name }).click();
} }
function moduleByType(page, type) {
return page.locator(`[data-module-type='${type}']`);
}
function tableCell(table, address) {
return table.getByRole("textbox", { name: `Cellule ${address}`, exact: true });
}
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await resetSokkoStorage(page); await resetSokkoStorage(page);
}); });
@ -131,3 +139,119 @@ test("imports and exports a toolbox payload", async ({ page }) => {
const download = await downloadPromise; const download = await downloadPromise;
expect(download.suggestedFilename()).toBe("fixture-toolbox.sokkog.json"); expect(download.suggestedFilename()).toBe("fixture-toolbox.sokkog.json");
}); });
test("edits a table with formulas and persists values", async ({ page }) => {
await createToolbox(page, "Table E2E Toolbox");
await addTool(page, "Tableau");
const table = moduleByType(page, "table");
await expect(table).toBeVisible();
await table.getByRole("button", { name: "Ajouter une ligne" }).click();
await table.getByRole("button", { name: "Ajouter une colonne" }).click();
await tableCell(table, "A1").dblclick();
await tableCell(table, "A1").fill("12");
await tableCell(table, "B1").dblclick();
await tableCell(table, "B1").fill("3");
await tableCell(table, "C1").dblclick();
await tableCell(table, "C1").fill("=A1*B1");
await tableCell(table, "C1").press("Enter");
await expect(tableCell(table, "C1")).toHaveValue("36");
await page.reload();
await expect(tableCell(moduleByType(page, "table"), "A1")).toHaveValue("12");
await expect(tableCell(moduleByType(page, "table"), "C1")).toHaveValue("36");
});
test("creates edits and deletes a combo", async ({ page }) => {
await createToolbox(page, "Combos E2E Toolbox");
await addTool(page, "Combos");
const combos = moduleByType(page, "combos");
await expect(combos).toBeVisible();
await combos.getByRole("button", { name: /Afficher l'ajout de Combos/ }).click();
await combos.getByPlaceholder("Nom du combo").fill("Combo E2E");
await combos.getByRole("button", { name: "←" }).click();
await combos.getByRole("button", { name: "□" }).click();
await combos.getByRole("button", { name: "Ajouter le combo" }).click();
await expect(combos.locator(".combo-card .combo-input-token")).toHaveCount(2);
await combos.getByRole("button", { name: "Modifier le combo Combo E2E" }).click();
await combos.getByPlaceholder("Nom du combo").fill("Combo E2E modifié");
await combos.getByRole("button", { name: "Enregistrer" }).click();
await expect(combos.getByRole("button", { name: "Modifier le combo Combo E2E modifié" })).toBeVisible();
await combos.getByRole("button", { name: "Supprimer le combo Combo E2E modifié" }).click();
await expect(combos.getByRole("button", { name: "Modifier le combo Combo E2E modifié" })).toHaveCount(0);
});
test("creates edits summarizes and deletes equipment", async ({ page }) => {
await createToolbox(page, "Equipment E2E Toolbox");
await addTool(page, "Planificateur d'équipements");
const equipmentPlanner = moduleByType(page, "equipmentPlanner");
await expect(equipmentPlanner).toBeVisible();
await equipmentPlanner.getByRole("button", { name: /Afficher l'ajout de Planificateur d'équipements/ }).click();
await equipmentPlanner.getByPlaceholder("Nouvel équipement").fill("Épée E2E");
await equipmentPlanner.getByRole("button", { name: "Ajouter" }).click();
await expect(equipmentPlanner.getByText("Épée E2E")).toBeVisible();
await expect(equipmentPlanner.getByText("1 équipement actif")).toBeVisible();
await equipmentPlanner.locator(".equipment-planner-row-edit-button").click();
await equipmentPlanner.getByPlaceholder("Catégorie").fill("Stats");
await equipmentPlanner.getByPlaceholder("Nom").fill("Attaque");
await equipmentPlanner.getByPlaceholder("Valeur").fill("12");
await equipmentPlanner.locator(".equipment-planner-trait-form").getByRole("button", { name: "Ajouter" }).click();
await expect(equipmentPlanner.getByText("Attaque").first()).toBeVisible();
await expect(equipmentPlanner.getByText("12").first()).toBeVisible();
await page.reload();
const persistedPlanner = moduleByType(page, "equipmentPlanner");
await expect(persistedPlanner.getByText("Épée E2E")).toBeVisible();
await expect(persistedPlanner.getByText("Attaque").first()).toBeVisible();
await persistedPlanner.getByRole("button", { name: "Supprimer Épée E2E" }).click();
await expect(persistedPlanner.getByText("Épée E2E")).toHaveCount(0);
});
test("edits rich notepad content and persists it", async ({ page }) => {
await createToolbox(page, "Notepad E2E Toolbox");
const notepad = moduleByType(page, "notepad");
await expect(notepad).toBeVisible();
const editor = notepad.getByRole("textbox");
await editor.click();
await page.keyboard.press("Control+A");
await page.keyboard.press("Backspace");
await notepad.locator(".notepad-toolbar-button[title='Titre']").click();
await page.keyboard.type("Note E2E importante");
await expect(editor).toContainText("Note E2E importante");
await expect(notepad.getByRole("heading", { name: "Note E2E importante" })).toBeVisible();
await page.waitForTimeout(500);
await page.reload();
const persistedEditor = moduleByType(page, "notepad").getByRole("textbox");
await expect(persistedEditor).toContainText("Note E2E importante");
await expect(moduleByType(page, "notepad").getByRole("heading", { name: "Note E2E importante" })).toBeVisible();
});
test("creates resets and deletes a countdown timer", async ({ page }) => {
await createToolbox(page, "Timer E2E Toolbox");
await addTool(page, "Timer");
const timer = moduleByType(page, "timer");
await expect(timer).toBeVisible();
await timer.getByRole("tab", { name: "Compte à rebours" }).click();
await timer.getByLabel("Libellé").fill("Boss E2E");
const durationParts = timer.getByRole("group", { name: "Format heure minute seconde" }).first().locator("input");
await durationParts.nth(1).fill("01");
await timer.getByRole("button", { name: "Ajouter" }).click();
const countdown = timer.locator(".timer-list-item").filter({ hasText: "Boss E2E" });
await expect(countdown).toBeVisible();
await countdown.locator(".timer-inline-reset").click();
await expect(countdown).toBeVisible();
await countdown.getByRole("button", { name: "Supprimer" }).click();
await expect(countdown).toHaveCount(0);
});