// Rôle : vérifie l'édition, les prérequis et les réinitialisations du planificateur réel. import { expect, test } from "@playwright/test"; import { Buffer } from "node:buffer"; async function setup(page) { await page.goto("/#/toolboxes"); await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({ name: "tasks.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify({ toolbox: { id: "tasks", name: "Task workflows", modules: [{ id: "planner", type: "taskPlanner", title: "Tasks" }] }, modules: { planner: { resetTime: "00:00", weeklyResetDay: 1, tasks: [ { id: "parent", title: "Parent", type: "unique", category: "Raid" }, { id: "child", title: "Child", type: "daily" }, { id: "weekly", title: "Weekly", type: "weekly" }, ] } }, })), }); await page.getByRole("link", { name: "Ouvrir Task workflows", exact: true }).first().click(); const tool = page.locator('[data-module-type="taskPlanner"]'); await expect(tool.getByRole("checkbox", { name: "Marquer effectué Parent", exact: true })).toBeVisible(); return tool; } test("creates and edits a categorized task with a multiline description and persists deletion", async ({ page }) => { const tool = await setup(page); await tool.getByRole("button", { name: "Afficher l'ajout de Tasks", exact: true }).click(); const form = tool.locator(".task-planner-add-form"); await form.getByRole("button", { name: "Ajouter", exact: true }).click(); await expect(tool.locator(".task-planner-title-input")).toHaveCount(3); await form.getByPlaceholder("Nouvelle tâche", { exact: true }).fill("New task"); await form.getByPlaceholder("Nom de catégorie", { exact: true }).fill("Crafting"); await form.getByRole("combobox", { name: "Type", exact: true }).selectOption("unique"); await form.getByRole("button", { name: "Ajouter", exact: true }).click(); await expect(form.getByPlaceholder("Nouvelle tâche", { exact: true })).toHaveValue(""); await expect(tool.getByRole("textbox", { name: "Titre", exact: true })).toHaveCount(4); const item = tool.locator("li.task-planner-item").filter({ has: page.getByRole("button", { name: "Supprimer New task", exact: true }) }); await item.getByRole("textbox", { name: "Titre", exact: true }).fill("Renamed"); await item.getByRole("textbox", { name: "Titre", exact: true }).press("Enter"); await tool.getByRole("button", { name: "Afficher la description Renamed", exact: true }).click(); const description = tool.getByRole("textbox", { name: "Description Renamed", exact: true }); await description.fill("First line"); await description.press("End"); await description.press("Enter"); await description.pressSequentially("Second line"); await tool.getByRole("textbox", { name: "Catégorie Renamed", exact: true }).click(); await page.reload(); await tool.getByRole("button", { name: "Afficher la description Renamed", exact: true }).click(); await expect(description).toHaveValue("First line\nSecond line"); await expect(tool.getByRole("textbox", { name: "Catégorie Renamed", exact: true })).toHaveValue("Crafting"); await tool.getByRole("button", { name: "Supprimer Renamed", exact: true }).click(); await page.reload(); await expect(tool.locator(".task-planner-title-input")).toHaveCount(3); await expect(tool.getByRole("button", { name: "Supprimer Renamed", exact: true })).toHaveCount(0); }); test("parent links inherit categories, warn without blocking completion and are removed when the parent is deleted", async ({ page }) => { const tool = await setup(page); await tool.getByRole("button", { name: "Réglages de la tâche Child", exact: true }).click(); await tool.getByRole("combobox", { name: "Définir un parent", exact: true }).selectOption({ label: "Parent" }); await tool.getByRole("checkbox", { name: "Pré requis Parent", exact: true }).check(); await tool.getByRole("button", { name: "Afficher la description Child", exact: true }).click(); const category = tool.getByRole("textbox", { name: "Catégorie Child", exact: true }); await expect(category).toBeDisabled(); await expect(category).toHaveValue("Raid"); await tool.getByRole("checkbox", { name: "Marquer effectué Child", exact: true }).check(); await expect(tool.getByText("Pré requis parent non effectué", { exact: true })).toBeVisible(); await expect(tool.getByRole("checkbox", { name: "Marquer non effectué Child", exact: true })).toBeChecked(); await tool.getByRole("checkbox", { name: "Marquer effectué Parent", exact: true }).check(); await expect(tool.locator(".task-planner-warning")).toHaveCount(0); await page.reload(); await tool.getByRole("button", { name: "Réglages de la tâche Child", exact: true }).click(); await expect(tool.getByRole("checkbox", { name: "Pré requis Parent", exact: true })).toBeChecked(); await tool.getByRole("button", { name: "Supprimer Parent", exact: true }).click(); await expect(tool.getByRole("checkbox", { name: "Pré requis Parent", exact: true })).toHaveCount(0); await expect(tool.getByText("Aucun parent", { exact: true })).toBeVisible(); await tool.getByRole("button", { name: "Afficher la description Child", exact: true }).click(); await expect(category).toBeEnabled(); await page.reload(); await expect(tool.getByRole("button", { name: "Supprimer Child", exact: true })).toBeVisible(); await expect(tool.getByRole("button", { name: "Supprimer Parent", exact: true })).toHaveCount(0); }); test("recurring resets preserve unique completions and cleanup deletes only completed unique tasks", async ({ page }) => { await page.clock.install({ time: new Date("2030-01-07T12:00:00Z") }); const tool = await setup(page); for (const title of ["Parent", "Child", "Weekly"]) { await tool.getByRole("checkbox", { name: `Marquer effectué ${title}`, exact: true }).check(); } await page.clock.fastForward(8 * 24 * 60 * 60 * 1000); await expect(tool.getByRole("checkbox", { name: "Marquer effectué Child", exact: true })).not.toBeChecked(); await expect(tool.getByRole("checkbox", { name: "Marquer effectué Weekly", exact: true })).not.toBeChecked(); await expect(tool.getByRole("checkbox", { name: "Marquer non effectué Parent", exact: true })).toBeChecked(); const hide = tool.getByRole("button", { name: "Masquer les tâches effectuées", exact: true }); await hide.click(); await expect(tool.getByRole("button", { name: "Supprimer Parent", exact: true })).toHaveCount(0); await page.reload(); await expect(hide).toHaveAttribute("aria-pressed", "true"); await hide.click(); await expect(tool.getByRole("checkbox", { name: "Marquer non effectué Parent", exact: true })).toBeChecked(); await tool.getByRole("button", { name: "Réglages du planificateur", exact: true }).click(); const cleanup = tool.getByRole("button", { name: "Nettoyer les tâches ponctuelles effectuées", exact: true }); await cleanup.click(); await expect(cleanup).toBeDisabled(); await page.reload(); await expect(tool.locator(".task-planner-title-input")).toHaveCount(2); await expect(tool.getByRole("checkbox", { name: "Marquer effectué Child", exact: true })).toBeVisible(); await expect(tool.getByRole("checkbox", { name: "Marquer effectué Weekly", exact: true })).toBeVisible(); });