Add Aniimo elemental matchup calculator
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 18m14s
Validate and deploy Sokko G / deploy (push) Successful in 10s

This commit is contained in:
Shinuwa 2026-10-31 09:43:04 +01:00
parent 72b3b15c7e
commit 243465720f
15 changed files with 518 additions and 10 deletions

View file

@ -0,0 +1,95 @@
// Rôle : vérifie les groupes d'affinités Aniimo, leurs libellés et la sélection au clavier aux largeurs bureau.
import { test, expect } from "@playwright/test";
for (const width of [768, 1440]) {
test(`element guide supports single and dual types at ${width}px`, async ({ page }) => {
// Le premier parcours comprend la compilation à froid des pages de jeu par Vite.
test.setTimeout(60000);
await page.setViewportSize({ width, height: 1000 });
await page.goto("/#/games/aniimo");
const homeIcon = page.locator('a[href="#/games/aniimo/elements"] .aniimo-elements-home-icon');
await expect(homeIcon.locator("img")).toHaveCount(3);
const homeIconPositions = await homeIcon.locator("img").evaluateAll((images) => images.map((image) => ({ x: image.offsetLeft, y: image.offsetTop })));
expect(homeIconPositions).toEqual([{ x: 34, y: 0 }, { x: 68, y: 42 }, { x: 0, y: 42 }]);
await page.getByRole("link", { name: /Faiblesses et résistances/ }).click();
const picker = page.getByRole("group", { name: "Éléments de l’Aniimo" });
await expect(picker.getByRole("button")).toHaveCount(9);
await expect(picker).toHaveCSS("column-gap", "12px");
await expect(page.getByText("Sélectionnez un élément pour afficher ses affinités.")).toBeVisible();
const water = picker.getByRole("button", { name: "Eau", exact: true });
await water.focus();
await page.keyboard.press("Enter");
await expect(water).toHaveAttribute("aria-pressed", "true");
const attack = page.getByRole("region", { name: "En attaque" });
const defense = page.getByRole("region", { name: "En défense" });
await expect(attack).toHaveClass(/nds-panel/);
await expect(defense).toHaveClass(/nds-panel/);
const group = (panel, name) => panel.getByRole("region", { name, exact: true });
const waterAttack = attack.getByRole("region", { name: /Compétence.*Eau/ });
const skillHeading = waterAttack.getByRole("heading", { level: 3, name: /Compétence.*Eau/ });
await expect(skillHeading).toHaveClass(/nds-section-heading/);
await expect(skillHeading).toHaveCSS("justify-content", "flex-start");
await expect(skillHeading).toHaveCSS("column-gap", "12px");
await expect(skillHeading.locator(".aniimo-skill-element")).toContainText("Eau");
await expect(group(waterAttack, "Efficace")).toContainText("×1,6");
await expect(group(waterAttack, "Efficace").getByRole("listitem")).toHaveText(["Feu", "Roche"]);
await expect(group(defense, "Résistant")).toContainText("×0,625");
await expect(group(defense, "Résistant").getByRole("listitem")).toContainText(["Feu", "Eau", "Roche", "Ténèbres"]);
await expect(water.locator("img")).toHaveCSS("width", "48px");
await expect(waterAttack.locator("li img").first()).toHaveCSS("width", "24px");
const ice = picker.getByRole("button", { name: "Glace", exact: true });
await ice.focus();
await page.keyboard.press("Space");
await expect(ice).toHaveAttribute("aria-pressed", "true");
await expect(picker.getByRole("button", { name: "Feu", exact: true })).toBeDisabled();
const iceAttack = attack.getByRole("region", { name: /Compétence.*Glace/ });
await expect(group(waterAttack, "Efficace").getByRole("listitem")).toHaveText(["Feu", "Roche"]);
await expect(group(iceAttack, "Peu efficace")).toContainText("×0,625");
await expect(group(iceAttack, "Peu efficace").getByRole("listitem")).toHaveText(["Feu", "Roche", "Glace"]);
await expect(group(defense, "Dégâts normaux")).toContainText("×1");
await expect(group(defense, "Dégâts normaux").getByRole("listitem")).toHaveText(["Feu", "Électrique", "Roche", "Vent", "Glace", "Sacré"]);
expect(await group(defense, "Dégâts normaux").locator(".aniimo-matchup-members").evaluate((element) => globalThis.getComputedStyle(element).gridTemplateColumns.split(" ").length)).toBe(4);
await expect(group(defense, "Très résistant")).toContainText("×0,390625");
await expect(group(defense, "Très résistant").getByRole("listitem")).toHaveText(["Eau"]);
await expect(waterAttack.getByRole("listitem")).toHaveCount(9);
await expect(iceAttack.getByRole("listitem")).toHaveCount(9);
await expect(defense.getByRole("listitem")).toHaveCount(9);
expect(await page.evaluate(() => globalThis.document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);
for (const panel of [attack, defense]) {
expect(await panel.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
}
const resultColumns = await page.locator(".aniimo-matchup-panels").evaluate((element) => globalThis.getComputedStyle(element).gridTemplateColumns.split(" ").length);
expect(resultColumns).toBe(width === 1440 ? 2 : 1);
const groupColumns = await page.locator(".aniimo-matchup-groups").evaluateAll((groups) => groups.map((group) => ({
mode: group.dataset.mode,
columns: globalThis.getComputedStyle(group).gridTemplateColumns.split(" ").length,
heights: [...group.children].map((card) => Math.round(card.getBoundingClientRect().height)),
fits: [...group.children].every((card) => card.scrollHeight <= card.clientHeight)
})));
for (const groupLayout of groupColumns) {
expect(groupLayout.columns).toBe(3);
expect(Math.max(...groupLayout.heights)).toBeLessThan(244);
expect(groupLayout.fits).toBe(true);
}
await page.screenshot({ path: test.info().outputPath(`aniimo-elements-${width}.png`), fullPage: true });
await ice.click();
await expect(picker.getByRole("button", { name: "Feu", exact: true })).toBeEnabled();
await page.getByRole("button", { name: "Effacer la sélection" }).click();
await expect(attack).toHaveCount(0);
await expect(picker.getByRole("button", { pressed: true })).toHaveCount(0);
await picker.getByRole("button", { name: "Ténèbres", exact: true }).click();
await picker.getByRole("button", { name: "Herbe", exact: true }).click();
await expect(group(defense, "Très vulnérable")).toContainText("×2,56");
await expect(group(defense, "Très vulnérable").getByRole("listitem")).toHaveText(["Vent"]);
});
}
test("element chart loading failure can be retried on the direct guide route", async ({ page }) => {
let fail = true;
await page.route("**/data/aniimo/elements.json", (route) => fail ? route.fulfill({ status: 503, body: "unavailable" }) : route.continue());
await page.goto("/#/games/aniimo/elements");
await expect(page.getByRole("alert")).toContainText("Impossible de charger Aniimo");
fail = false;
await page.getByRole("button", { name: "Réessayer" }).click();
await expect(page.getByRole("group", { name: "Éléments de l’Aniimo" })).toBeVisible();
});

View file

@ -139,7 +139,7 @@ test("catalogue, overview and deferred Aniimo loading preserve filters across na
await page.locator('a[href="#/games/aniimo/aniimos"]').click();
await expect(cards(page)).toHaveCount(3);
await expect(page.getByRole("searchbox")).toHaveValue("EMBERPUP");
expect(requests).toHaveLength(5);
expect(requests).toHaveLength(6);
});
test("Aniimo exposes its regions list", async ({ page }) => {