Rework the daily card page around what the player knows and hints opened in any order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6993080d81
commit
880f007cce
24 changed files with 812 additions and 415 deletions
|
|
@ -2115,52 +2115,83 @@ test("a player finds the daily card with hints and copies the result", async ({
|
|||
const hints = page.getByRole("region", { name: "Indices", exact: true });
|
||||
await expect(hints.getByRole("button")).toHaveCount(5);
|
||||
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(0);
|
||||
await expect(hints).toContainText("Aucun indice à dévoiler");
|
||||
// Avant le premier essai, les règles et les cinq familles de sujets.
|
||||
await expect(page.locator(".nebula-daily-rules li")).toHaveCount(3);
|
||||
await expect(page.locator(".nebula-daily-families li")).toHaveCount(5);
|
||||
|
||||
const input = page.getByRole("combobox", { name: /^Votre proposition/ });
|
||||
const input = page.getByRole("combobox", { name: "Quelle est cette carte ?" });
|
||||
const propose = page.getByRole("button", { name: "Proposer", exact: true });
|
||||
await expect(propose).toBeDisabled();
|
||||
await input.fill("zzz");
|
||||
await expect(page.getByRole("option")).toHaveText(["Aucune carte pour « zzz »."]);
|
||||
await expect(propose).toBeDisabled();
|
||||
// Un mot proche trouve aussi une carte dont le nom ne le contient pas.
|
||||
await input.fill("pingouin");
|
||||
await expect(page.getByRole("option", { name: "Manchot des Glaces Étoilées", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("option", { name: "Manchot des Glaces Étoilées" })).toContainText("mot proche : pingouin");
|
||||
// La recherche ignore les accents et la casse.
|
||||
await input.fill(wrong.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase());
|
||||
// Les suggestions dépassent du panneau sans être coupées ni recouvertes.
|
||||
await expectOpenMenuVisible(page, ".nebula-daily-form .nds-autocomplete-menu");
|
||||
await page.getByRole("option", { name: wrong, exact: true }).click();
|
||||
await page.getByRole("button", { name: "Proposer", exact: true }).click();
|
||||
// Entrée prend la première suggestion, puis propose la carte choisie.
|
||||
await input.fill(wrong.slice(0, -1));
|
||||
await input.press("Enter");
|
||||
await expect(input).toHaveValue(wrong);
|
||||
await input.press("Enter");
|
||||
const guesses = page.locator(".nebula-daily-guess");
|
||||
await expect(guesses).toHaveCount(1);
|
||||
await expect(guesses.first()).toContainText(wrong);
|
||||
await expect(guesses.first().locator(".nebula-daily-step").first()).toBeVisible();
|
||||
await expect(guesses.first().locator(".nebula-daily-theme")).toBeVisible();
|
||||
await expect(guesses.first().locator("u")).toHaveCount(1);
|
||||
const feedback = page.locator(".nebula-daily-feedback");
|
||||
await expect(feedback).toContainText(`${wrong} : raté`);
|
||||
await expect(feedback.getByRole("heading", { name: "Ce que vous savez" })).toBeVisible();
|
||||
// La saisie reprend la main ; une carte proposée est citée sans pouvoir être choisie.
|
||||
await expect(input).toBeFocused();
|
||||
await input.fill(wrong);
|
||||
await expect(page.locator(".nebula-daily-form [role=option][aria-disabled=true]")).toContainText("déjà proposée");
|
||||
await expect(propose).toBeDisabled();
|
||||
await input.fill("");
|
||||
// Un essai raté fait venir un morceau plus large de l'illustration.
|
||||
await expect(image).not.toHaveAttribute("src", firstCrop);
|
||||
await expect.poll(() => image.evaluate((element) => element.naturalWidth)).toBe(720);
|
||||
const close = await guesses.first().evaluate((row) => Boolean(row.querySelector(".nebula-daily-theme[data-same]")) || row.querySelectorAll(".nebula-daily-step[data-same]").length > 1);
|
||||
await expect(page.locator(`.nebula-daily-steps li[data-result="${close ? "close" : "miss"}"]`)).toHaveCount(1);
|
||||
await expect(page.locator(`.nebula-daily-track li[data-result="${close ? "close" : "miss"}"]`)).toHaveCount(1);
|
||||
|
||||
// Un essai raté donne un indice, au choix parmi les deux ouverts ; il se retourne sur place et referme les autres.
|
||||
await expect(hints).toContainText("1 indice à retourner, au choix.");
|
||||
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(2);
|
||||
// Un essai raté donne un indice à dévoiler, n'importe lequel ; il s'ouvre sur place, sans changer la taille des cadres, et referme les autres.
|
||||
await expect(hints).toContainText("1 indice à dévoiler");
|
||||
const sameTheme = await guesses.first().locator(".nebula-daily-theme[data-same]").count();
|
||||
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(5 - sameTheme);
|
||||
const frames = () => hints.locator("li").evaluateAll((items) => items.map((item) => [item.offsetWidth, item.offsetHeight].join("×")));
|
||||
const closedFrames = await frames();
|
||||
await hints.getByRole("button", { name: /^Dans votre album/ }).click();
|
||||
await expect(hints.locator('.nebula-daily-hint[data-state="open"]')).toContainText(/Oui, elle y est|Non, elle vous manque/);
|
||||
await expect(hints.locator(".nebula-daily-hint[data-hint=album][data-state=open]")).toContainText(/Oui, vous l’avez|Non, pas encore/);
|
||||
expect(await frames()).toEqual(closedFrames);
|
||||
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(0);
|
||||
await expect(guesses).toHaveCount(1);
|
||||
// Une partie en cours, de l'image aux indices, tient dans un écran de 1280 × 720 sous le bandeau du site (68 px).
|
||||
await expect.poll(() => page.locator(".nebula-daily-layout").evaluate((layout) => layout.getBoundingClientRect().height)).toBeLessThan(652);
|
||||
// L'image, la saisie et les indices tiennent dans un écran de 1280 × 720 sous le bandeau du site (68 px).
|
||||
await expect.poll(() => page.locator(".nebula-daily-layout").evaluate((layout) => layout.querySelector(".nebula-daily-hints").getBoundingClientRect().bottom - layout.getBoundingClientRect().top)).toBeLessThan(652);
|
||||
await hints.evaluate((section) => section.scrollIntoView({ block: "end" }));
|
||||
await expect(input).toBeInViewport();
|
||||
expect(await page.evaluate(() => [...globalThis.document.querySelectorAll(".nebula-daily-row > *, .nebula-daily-hint")].filter((cell) => cell.scrollWidth > cell.clientWidth + 1).map((cell) => cell.textContent))).toEqual([]);
|
||||
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-start.png"), fullPage: true });
|
||||
expect(await page.evaluate(() => [...globalThis.document.querySelectorAll(".nebula-daily-guess > *, .nebula-daily-hint > *, .nebula-daily-form")].filter((cell) => cell.scrollWidth > cell.clientWidth + 1).map((cell) => cell.textContent))).toEqual([]);
|
||||
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-playing.png") });
|
||||
|
||||
await input.fill(answer);
|
||||
await page.getByRole("button", { name: "Proposer", exact: true }).click();
|
||||
await propose.click();
|
||||
const result = page.locator(".nebula-daily-result");
|
||||
await expect(result.getByRole("heading", { name: "Trouvée en 2/6 !" })).toBeVisible();
|
||||
await expect(result).toContainText("+10 poussières gagnées");
|
||||
await expect(result.locator(".nebula-daily-answer strong")).toHaveText(answer);
|
||||
await expect(result.locator(".nebula-card")).toBeVisible();
|
||||
// La partie finie, l'illustration entière arrive à sa taille d'origine, à la place des morceaux de 720 px.
|
||||
await expect.poll(() => image.evaluate((element) => element.naturalWidth)).not.toBe(720);
|
||||
await expect(page.getByRole("combobox", { name: /^Votre proposition/ })).toHaveCount(0);
|
||||
await expect(result.getByRole("heading", { name: "Trouvée en 2 essais !" })).toBeVisible();
|
||||
await expect(result).toContainText("1 indice utilisé");
|
||||
await expect(result).toContainText("+10 poussières");
|
||||
await expect(result.getByRole("heading", { name: "La réponse" })).toBeVisible();
|
||||
await expect(result.locator(".nebula-daily-chip[data-found]").first()).toBeVisible();
|
||||
// La partie finie, la carte prend la place de l'illustration zoomée, et les indices s'effacent.
|
||||
await expect(page.locator(".nebula-daily-stage .nebula-card")).toContainText(answer);
|
||||
await expect(image).toHaveCount(0);
|
||||
await expect(hints).toHaveCount(0);
|
||||
await expect(input).toHaveCount(0);
|
||||
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-won.png"), fullPage: true });
|
||||
|
||||
await result.getByRole("button", { name: "Copier le résultat", exact: true }).click();
|
||||
await expect(result.getByRole("button", { name: "Résultat copié", exact: true })).toBeVisible();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue