Add quantitative tasks with checklist controls to the planner
This commit is contained in:
parent
29fcb50fcd
commit
c08452d5a4
22 changed files with 434 additions and 33 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// Rôle : vérifie l'édition, les prérequis et les réinitialisations du planificateur réel.
|
||||
/* global document, window */
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { Buffer } from "node:buffer";
|
||||
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
|
||||
|
|
@ -25,6 +26,125 @@ async function setup(page) {
|
|||
return tool;
|
||||
}
|
||||
|
||||
for (const width of [768, 1280]) {
|
||||
test(`quantitative tasks support editing, completion, hiding and persistence at ${width}px`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
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.getByPlaceholder("Nouvelle tâche", { exact: true }).fill("Collecter");
|
||||
await form.getByRole("spinbutton", { name: "Quantité cible", exact: true }).fill("5");
|
||||
await form.getByRole("combobox", { name: "Type", exact: true }).selectOption("unique");
|
||||
await form.getByRole("button", { name: "Ajouter", exact: true }).click();
|
||||
await expect(form.getByRole("spinbutton", { name: "Quantité cible", exact: true })).toHaveValue("1");
|
||||
const quantity = tool.getByRole("spinbutton", { name: "Quantité actuelle Collecter", exact: true });
|
||||
const item = tool.locator("li.task-planner-item").filter({ has: page.getByRole("spinbutton", { name: "Quantité actuelle Collecter", exact: true }) });
|
||||
await expect(item.getByRole("checkbox")).toHaveCount(0);
|
||||
await expect.poll(async () => {
|
||||
const stepperBox = await item.locator(".task-planner-quantity").boundingBox();
|
||||
const titleBox = await item.getByRole("textbox", { name: "Titre", exact: true }).boundingBox();
|
||||
return Boolean(stepperBox && titleBox && stepperBox.x + stepperBox.width <= titleBox.x
|
||||
&& Math.abs(stepperBox.y + stepperBox.height / 2 - titleBox.y - titleBox.height / 2) < 2);
|
||||
}).toBe(true);
|
||||
await tool.getByRole("button", { name: "Ajouter une quantité Collecter", exact: true }).click();
|
||||
await expect(quantity).toHaveValue("1");
|
||||
await quantity.fill("3");
|
||||
await quantity.press("Tab");
|
||||
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.find((task) => task.title === "Collecter")?.qtyCurrent).toBe(3);
|
||||
await page.reload();
|
||||
await expect(quantity).toHaveValue("3");
|
||||
await quantity.fill("99");
|
||||
await expect(quantity).toHaveValue("5");
|
||||
await expect(item).toHaveClass(/is-complete/);
|
||||
const hide = tool.getByRole("button", { name: "Masquer les tâches effectuées", exact: true });
|
||||
await hide.click();
|
||||
await expect(quantity).toHaveCount(0);
|
||||
await hide.click();
|
||||
await tool.getByRole("button", { name: "Retirer une quantité Collecter", exact: true }).click();
|
||||
await expect(quantity).toHaveValue("4");
|
||||
await expect(item).not.toHaveClass(/is-complete/);
|
||||
await tool.getByRole("button", { name: "Réglages de la tâche Collecter", exact: true }).click();
|
||||
const target = tool.getByRole("spinbutton", { name: "Quantité cible Collecter", exact: true });
|
||||
await target.fill("2");
|
||||
await target.press("Escape");
|
||||
await expect(target).toHaveValue("5");
|
||||
await target.fill("3");
|
||||
await target.press("Enter");
|
||||
await expect(quantity).toHaveValue("3");
|
||||
await quantity.fill("0");
|
||||
await expect(quantity).toHaveValue("0");
|
||||
await tool.getByRole("button", { name: "Retirer une quantité Collecter", exact: true }).click();
|
||||
await expect(quantity).toHaveValue("-1");
|
||||
await quantity.fill("3");
|
||||
await expect(quantity).toHaveValue("3");
|
||||
await target.fill("1");
|
||||
await target.press("Enter");
|
||||
await expect(quantity).toHaveCount(0);
|
||||
await expect(tool.getByRole("checkbox", { name: "Marquer non effectué Collecter", exact: true })).toBeChecked();
|
||||
await target.fill("3");
|
||||
await target.press("Enter");
|
||||
await expect(quantity).toHaveValue("1");
|
||||
await expect(item.getByRole("checkbox")).toHaveCount(0);
|
||||
await quantity.fill("3");
|
||||
await expect.poll(() => page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
|
||||
await tool.getByRole("button", { name: "Configuration", exact: true }).click();
|
||||
await tool.getByRole("button", { name: "Nettoyer les tâches ponctuelles effectuées", exact: true }).click();
|
||||
await expect(quantity).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
|
||||
test("quantitative prerequisites and recurring partial progress survive reload and reset", 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("button", { name: `Réglages de la tâche ${title}`, exact: true }).click();
|
||||
const target = tool.getByRole("spinbutton", { name: `Quantité cible ${title}`, exact: true });
|
||||
await target.fill("5");
|
||||
await target.press("Enter");
|
||||
await tool.getByRole("button", { name: `Réglages de la tâche ${title}`, exact: true }).click();
|
||||
await tool.getByRole("spinbutton", { name: `Quantité actuelle ${title}`, exact: true }).fill("2");
|
||||
}
|
||||
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("spinbutton", { name: "Quantité actuelle Child", exact: true }).fill("5");
|
||||
await expect(tool.getByText("Pré requis parent non effectué", { exact: true })).toBeVisible();
|
||||
await tool.getByRole("spinbutton", { name: "Quantité actuelle Parent", exact: true }).fill("5");
|
||||
await expect(tool.locator(".task-planner-warning")).toHaveCount(0);
|
||||
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.find((task) => task.title === "Parent")?.qtyCurrent).toBe(5);
|
||||
await page.reload();
|
||||
await expect(tool.getByRole("spinbutton", { name: "Quantité actuelle Weekly", exact: true })).toHaveValue("2");
|
||||
await page.clock.fastForward(8 * 24 * 60 * 60 * 1000);
|
||||
await expect(tool.getByRole("spinbutton", { name: "Quantité actuelle Child", exact: true })).toHaveValue("0");
|
||||
await expect(tool.getByRole("spinbutton", { name: "Quantité actuelle Weekly", exact: true })).toHaveValue("0");
|
||||
await expect(tool.getByRole("spinbutton", { name: "Quantité actuelle Parent", exact: true })).toHaveValue("5");
|
||||
});
|
||||
|
||||
test("quantities created in the drawer synchronize with another open page", async ({ page, context }) => {
|
||||
await page.setViewportSize({ width: 768, height: 900 });
|
||||
await setup(page);
|
||||
const other = await context.newPage();
|
||||
await other.goto(page.url());
|
||||
await expect(other.getByRole("checkbox", { name: "Marquer effectué Parent", exact: true })).toBeVisible();
|
||||
await page.goto("/#/games/mhwilds");
|
||||
await page.getByRole("tab", { name: "Toolbox", exact: true }).click();
|
||||
const drawer = page.locator("#toolbox-drawer .drawer-panel");
|
||||
await drawer.getByLabel("Toolbox disponible").selectOption({ label: "Task workflows" });
|
||||
await drawer.getByRole("button", { name: "Associer", exact: true }).click();
|
||||
const tool = drawer.locator('[data-module-type="taskPlanner"]');
|
||||
await tool.getByRole("button", { name: "Afficher l'ajout de Tasks", exact: true }).click();
|
||||
const form = tool.locator(".task-planner-add-form");
|
||||
await form.getByPlaceholder("Nouvelle tâche", { exact: true }).fill("Récolte");
|
||||
await form.getByRole("spinbutton", { name: "Quantité cible", exact: true }).fill("10");
|
||||
await form.getByRole("button", { name: "Ajouter", exact: true }).click();
|
||||
await tool.getByRole("button", { name: "Ajouter une quantité Récolte", exact: true }).click();
|
||||
await expect(other.getByRole("spinbutton", { name: "Quantité actuelle Récolte", exact: true })).toHaveValue("1");
|
||||
await other.getByRole("spinbutton", { name: "Quantité actuelle Récolte", exact: true }).fill("4");
|
||||
await expect(tool.getByRole("spinbutton", { name: "Quantité actuelle Récolte", exact: true })).toHaveValue("4");
|
||||
await expect.poll(() => drawer.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
|
||||
await other.close();
|
||||
});
|
||||
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue