diff --git a/e2e/toolbox.spec.js b/e2e/toolbox.spec.js index d0f2991..7bade09 100644 --- a/e2e/toolbox.spec.js +++ b/e2e/toolbox.spec.js @@ -18,6 +18,13 @@ async function createToolbox(page, name) { await expect(page.getByRole("heading", { name })).toBeVisible(); } +async function addTool(page, name) { + await page.getByRole("button", { name: "Ajouter un outil", exact: true }).click(); + const addDialog = page.getByRole("dialog", { name: "Ajouter un outil" }); + await expect(addDialog).toBeVisible(); + await addDialog.getByRole("button", { name }).click(); +} + test.beforeEach(async ({ page }) => { await resetSokkoStorage(page); }); @@ -29,12 +36,38 @@ test("creates a toolbox and lazy-loads an added tool", async ({ page }) => { 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 addTool(page, "Arbre d'objectifs"); await expect(page.locator("[data-module-type='goalTree']")).toBeVisible(); }); +test("creates, edits and deletes a weekly calendar event", async ({ page }) => { + await createToolbox(page, "Calendar E2E Toolbox"); + await addTool(page, "Calendrier"); + + const calendar = page.locator("[data-module-type='calendar']"); + await expect(calendar).toBeVisible(); + await calendar.getByRole("button", { name: "Hebdomadaire" }).click(); + await expect(calendar.locator(".calendar-week-grid")).toBeVisible(); + + await calendar.getByRole("button", { name: /Afficher l'ajout de Calendrier/ }).click(); + await calendar.getByLabel("Titre").fill("Raid E2E"); + await calendar.getByRole("textbox", { name: "Début" }).fill("18:00"); + await calendar.getByRole("textbox", { name: "Fin" }).fill("20:00"); + await calendar.getByRole("button", { name: "Ajouter" }).click(); + + await expect(calendar.getByRole("button", { name: /Raid E2E/ })).toBeVisible(); + await calendar.getByRole("button", { name: /Raid E2E/ }).click(); + await calendar.getByLabel("Titre").fill("Raid E2E modifié"); + await calendar.getByRole("button", { name: "Enregistrer" }).click(); + + await expect(calendar.getByRole("button", { name: /Raid E2E modifié/ })).toBeVisible(); + await expect(calendar.getByRole("button", { name: /Raid E2E$/ })).toHaveCount(0); + + await calendar.getByRole("button", { name: /Raid E2E modifié/ }).click(); + await calendar.getByRole("button", { name: "Supprimer" }).click(); + await expect(calendar.getByRole("button", { name: /Raid E2E modifié/ })).toHaveCount(0); +}); + 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();