Let a guide checklist update from its page filters without losing checks, and optionally limit the page to what the checklist contains
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
17e5cd5e63
commit
07a43ef848
17 changed files with 486 additions and 36 deletions
|
|
@ -354,6 +354,72 @@ for (const [gameId, category, cardClass, dataPath, dataKey, checklistTitle] of [
|
|||
});
|
||||
}
|
||||
|
||||
test("updating from the page keeps checked rows, adds new results and removes absent rows on request", async ({ page }) => {
|
||||
await seed(page, "aniimo", { forms: [row("Loufeuteau — Forme de base", 1), row("Obsolète", 1)] });
|
||||
await page.goto(route);
|
||||
await page.getByRole("searchbox").fill("emberpup");
|
||||
await page.getByRole("button", { name: "Regrouper les variantes", exact: true }).click();
|
||||
await choose(page, "forms");
|
||||
// Les cochés masqués restent des résultats : la forme de base ne doit pas passer pour absente.
|
||||
await toggleHidden(page);
|
||||
|
||||
await openDrawer(page);
|
||||
await openControls(page, "forms");
|
||||
await controls(page, "forms").getByRole("button", { name: "Mettre à jour depuis la page", exact: true }).click();
|
||||
const dialog = page.getByRole("dialog", { name: "Mettre à jour depuis la page" });
|
||||
const stat = (label) => dialog.locator(".guide-checklist-update-stats > div").filter({ hasText: label }).locator("dd");
|
||||
await expect(stat("Résultats de la page")).toHaveText("3");
|
||||
await expect(stat("À ajouter")).toHaveText("2");
|
||||
await expect(stat("Déjà présents")).toHaveText("1dont 1 coché");
|
||||
await expect(stat("Absents des résultats")).toHaveText("1dont 1 coché");
|
||||
await expect(dialog.getByText("Checklist à mettre à jour", { exact: true })).toBeVisible();
|
||||
const removeMissing = dialog.getByRole("button", { name: "Retirer les éléments absents", exact: true });
|
||||
await expect(removeMissing).toHaveAttribute("aria-pressed", "false");
|
||||
await removeMissing.click();
|
||||
await dialog.getByRole("button", { name: "Mettre à jour", exact: true }).click();
|
||||
await expect(dialog).toHaveCount(0);
|
||||
await expect(page.getByText("Checklist mise à jour depuis la page.")).toBeVisible();
|
||||
|
||||
await expect.poll(async () => normalizeChecklistData(await readModule(page, "forms")).items.map((item) => [item.label, item.qtyCurrent])).toEqual([
|
||||
["Loufeuteau — Forme de base", 1],
|
||||
["Loufeuteau — Forme des montagnes boisées", 0],
|
||||
["Loufeuteau — Hautes-plaines", 0]
|
||||
]);
|
||||
expect(normalizeChecklistData(await readModule(page, "forms")).items[0].id).toBe("Loufeuteau — Forme de base");
|
||||
|
||||
await controls(page, "forms").getByRole("button", { name: "Mettre à jour depuis la page", exact: true }).click();
|
||||
await expect(dialog.getByText("La checklist contient déjà tous les résultats de la page.")).toBeVisible();
|
||||
await expect(dialog.getByRole("button", { name: "Mettre à jour", exact: true })).toBeDisabled();
|
||||
});
|
||||
|
||||
test("« Seulement la checklist » limits the page to listed elements and persists with the association", async ({ page }) => {
|
||||
await seed(page, "aniimo", { forms: [row("Loufeuteau — Forme de base"), row("Unrelated")] });
|
||||
await page.goto(route);
|
||||
await page.getByRole("searchbox").fill("emberpup");
|
||||
await page.getByRole("button", { name: "Regrouper les variantes", exact: true }).click();
|
||||
const count = page.locator('[data-copy-target="true"]');
|
||||
await expect(count).toHaveText("3 / 259 variantes");
|
||||
await openDrawer(page);
|
||||
await openControls(page, "forms");
|
||||
const onlyListed = controls(page, "forms").getByRole("button", { name: "Seulement la checklist", exact: true });
|
||||
await expect(onlyListed).toBeDisabled();
|
||||
await linkButton(page, "forms").click();
|
||||
await onlyListed.click();
|
||||
await expect(onlyListed).toHaveAttribute("aria-pressed", "true");
|
||||
await closeDrawer(page);
|
||||
await expect(count).toHaveText("1 / 259 variantes");
|
||||
expect(JSON.parse(await page.evaluate((key) => globalThis.localStorage.getItem(key), storageKey))["aniimo/aniimos"]).toMatchObject({ moduleId: "forms", onlyListed: true });
|
||||
|
||||
await page.reload();
|
||||
await page.getByRole("searchbox").fill("emberpup");
|
||||
await page.getByRole("button", { name: "Regrouper les variantes", exact: true }).click();
|
||||
await expect(count).toHaveText("1 / 259 variantes");
|
||||
const pageSwitch = page.locator(".guide-checklist-page-controls").getByRole("button", { name: "Seulement la checklist", exact: true });
|
||||
await expect(pageSwitch).toHaveAttribute("aria-pressed", "true");
|
||||
await pageSwitch.click();
|
||||
await expect(count).toHaveText("3 / 259 variantes");
|
||||
});
|
||||
|
||||
test("renames retain a zero-match selection; changing toolbox clears the association", async ({ page }) => {
|
||||
await seed(page);
|
||||
await page.goto(route);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue