- Each owned item that would add a destination today (guide star, sky chart, or enough treasure map fragments) gets a dashed frame under the destinations: what it does, the difficulty and the loot bonus of the added destination. A click uses the item, as in the bag. - Frames appear only while the item is owned in sufficient number and its slot is still free, and share the destinations' grid. - "1 destinations débloquées" becomes singular. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2694 lines
206 KiB
JavaScript
2694 lines
206 KiB
JavaScript
// Rôle : valide l'ouverture, la reprise, l'album et l'administration de Sokko TCG.
|
||
import { readFile, writeFile } from "node:fs/promises";
|
||
import { tmpdir } from "node:os";
|
||
import { join } from "node:path";
|
||
import { DatabaseSync } from "node:sqlite";
|
||
import { expect, test } from "@playwright/test";
|
||
|
||
// Sélecteurs à choix unique du design system (`SelectDropdown`).
|
||
const selectTrigger = (scope, label) => scope.getByRole("button", { name: new RegExp(`^${label} : `) });
|
||
async function chooseOption(scope, label, option) {
|
||
await selectTrigger(scope, label).click();
|
||
await scope.getByRole("option", typeof option === "string" ? { name: option, exact: true } : { name: option }).click();
|
||
}
|
||
async function expectOptions(page, scope, label, options) {
|
||
await selectTrigger(scope, label).click();
|
||
await expect(scope.getByRole("option")).toHaveText(options);
|
||
await page.keyboard.press("Escape");
|
||
}
|
||
const INHERITED = /hérité|défaut/;
|
||
// En demi-écran, le menu de sections est replié derrière un bouton qui nomme la section courante : l'ouvrir avant d'y choisir une entrée.
|
||
async function expandSections(page, name) {
|
||
const toggle = selectTrigger(page, name);
|
||
if (await toggle.isVisible() && await toggle.getAttribute("aria-expanded") === "false") await toggle.click();
|
||
}
|
||
|
||
// Le menu ouvert reste entièrement visible et personne ne le recouvre, quel que soit le bord dont il est proche.
|
||
async function expectOpenMenuVisible(page, selector) {
|
||
const result = await page.locator(selector).evaluate((menu) => {
|
||
const box = menu.getBoundingClientRect();
|
||
const clip = menu.ownerDocument.querySelector("main").getBoundingClientRect();
|
||
const points = [[box.left + 8, box.top + 8], [box.right - 8, box.top + 8], [box.left + 8, box.bottom - 8], [box.right - 8, box.bottom - 8]];
|
||
return {
|
||
inside: box.left >= clip.left && box.right <= Math.min(clip.right, globalThis.innerWidth) && box.top >= 0 && box.bottom <= globalThis.innerHeight,
|
||
covered: points.filter(([x, y]) => !menu.contains(menu.ownerDocument.elementFromPoint(x, y))).length
|
||
};
|
||
});
|
||
expect(result).toEqual({ inside: true, covered: 0 });
|
||
}
|
||
|
||
// Chaque option d'un menu ouvert est bien celle qu'on toucherait en son centre : aucun voisin ne la recouvre.
|
||
async function expectOpenOptionsOnTop(page, selector) {
|
||
const covered = await page.locator(selector).evaluate((menu) => [...menu.querySelectorAll("[role=option]")].filter((option) => {
|
||
const box = option.getBoundingClientRect();
|
||
return !option.contains(menu.ownerDocument.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2));
|
||
}).map((option) => option.textContent));
|
||
expect(covered).toEqual([]);
|
||
}
|
||
|
||
// Une phase d'aura dure de 300 à 450 ms, pilotées par setTimeout : sur une machine chargée, elle peut finir avant la lecture de ses styles.
|
||
// Figer l'horloge de la page garde chaque phase affichée le temps des assertions ; `page.clock.runFor()` passe à la suivante et `resume()` relance le temps.
|
||
const holdRevealTimers = async (page) => page.clock.pauseAt(await page.evaluate(() => Date.now()) + 1000);
|
||
|
||
// Rend un anneau légendaire et un anneau mythique figés au même instant, avec une palette unie identique,
|
||
// puis compare leurs profils de luminance radiaux : la silhouette (trait + lueur) doit être la même.
|
||
async function expectMythicRingSilhouetteToMatchLegendary(page) {
|
||
const color = "#f6c453";
|
||
await page.evaluate((probeColor) => {
|
||
const style = globalThis.document.createElement("style");
|
||
style.dataset.ringProbe = "";
|
||
style.textContent = "[data-ring-probe] .nebula-card-particles::after, [data-ring-probe] .nebula-card-particles i { display: none !important; } [data-ring-probe] *, [data-ring-probe] *::before { animation-play-state: paused !important; animation-delay: -400ms !important; }";
|
||
globalThis.document.head.append(style);
|
||
for (const [index, rarity] of ["legendary", "mythic"].entries()) {
|
||
const probe = globalThis.document.createElement("div");
|
||
probe.className = "nebula-card";
|
||
probe.dataset.ringProbe = rarity;
|
||
probe.dataset.rarity = rarity;
|
||
probe.dataset.particleShape = "sparks";
|
||
probe.style.cssText = `position: fixed; z-index: 2147483647; top: 0; left: ${index * 320}px; width: 320px; height: 320px; max-width: none; aspect-ratio: auto; background: #000; --opening-aura: ${probeColor}; --particle-gradient: ${probeColor}; --opening-particle-duration: 1200ms;`;
|
||
const particles = globalThis.document.createElement("span");
|
||
particles.className = "nebula-card-particles";
|
||
if (rarity === "mythic") particles.innerHTML = '<span class="nebula-card-particle-ring-glow" data-glow="outer"><span><span></span></span></span><span class="nebula-card-particle-ring-glow" data-glow="inner"><span><span></span></span></span>';
|
||
probe.append(particles);
|
||
globalThis.document.body.append(probe);
|
||
}
|
||
}, color);
|
||
const shot = await page.screenshot({ clip: { x: 0, y: 0, width: 640, height: 320 } });
|
||
const profiles = await page.evaluate(async (base64) => {
|
||
const image = new globalThis.Image();
|
||
image.src = `data:image/png;base64,${base64}`;
|
||
await image.decode();
|
||
const canvas = globalThis.document.createElement("canvas");
|
||
canvas.width = image.width;
|
||
canvas.height = image.height;
|
||
const context = canvas.getContext("2d");
|
||
context.drawImage(image, 0, 0);
|
||
const scale = image.width / 640;
|
||
const directions = Array.from({ length: 8 }, (_, index) => [Math.cos(index * Math.PI / 4), Math.sin(index * Math.PI / 4)]);
|
||
const profile = (centerX) => Array.from({ length: 50 }, (_, step) => {
|
||
const radius = step * 3;
|
||
const total = directions.reduce((sum, [dx, dy]) => {
|
||
const [red, green, blue] = context.getImageData(Math.round((centerX + dx * radius) * scale), Math.round((160 + dy * radius) * scale), 1, 1).data;
|
||
return sum + (red + green + blue) / 3;
|
||
}, 0);
|
||
return total / directions.length;
|
||
});
|
||
globalThis.document.querySelectorAll("[data-ring-probe]").forEach((element) => element.remove());
|
||
return { legendary: profile(160), mythic: profile(480) };
|
||
}, shot.toString("base64"));
|
||
expect(Math.max(...profiles.legendary)).toBeGreaterThan(100);
|
||
const differences = profiles.legendary.map((value, index) => Math.abs(value - profiles.mythic[index]));
|
||
expect(Math.max(...differences)).toBeLessThan(24);
|
||
expect(differences.reduce((sum, value) => sum + value, 0) / differences.length).toBeLessThan(4);
|
||
}
|
||
|
||
async function expectArtworkFramed(card) {
|
||
const layout = await card.evaluate((element) => {
|
||
const bounds = (selector) => {
|
||
const rect = element.querySelector(selector).getBoundingClientRect();
|
||
return { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left, width: rect.width };
|
||
};
|
||
const artwork = element.querySelector(".nebula-card-art img, .nebula-card-placeholder-mark");
|
||
return { face: bounds(".nebula-card-face"), art: bounds(".nebula-card-art"), artwork: bounds(artwork.matches("img") ? ".nebula-card-art img" : ".nebula-card-placeholder-mark"), image: artwork.matches("img"), size: element.dataset.cardSize, title: bounds("h3") };
|
||
});
|
||
expect(layout.artwork.bottom).toBeLessThanOrEqual(layout.art.bottom + 0.5);
|
||
expect(layout.artwork.left).toBeGreaterThanOrEqual(layout.art.left - 0.5);
|
||
expect(layout.artwork.right).toBeLessThanOrEqual(layout.art.right + 0.5);
|
||
if (layout.image) {
|
||
expect(layout.artwork.width / layout.art.width).toBeGreaterThan(0.98);
|
||
} else if (layout.size === "md") {
|
||
expect(layout.artwork.bottom).toBeLessThanOrEqual(layout.title.top + 0.5);
|
||
expect(layout.artwork.width / layout.face.width).toBeLessThan(0.46);
|
||
} else {
|
||
expect(layout.artwork.top).toBeGreaterThanOrEqual(layout.title.bottom - 0.5);
|
||
expect(layout.artwork.width / layout.face.width).toBeLessThan(0.46);
|
||
}
|
||
}
|
||
|
||
async function expectFixedTitleBand(card, position) {
|
||
const layout = await card.evaluate((element) => {
|
||
const title = element.querySelector("h3").getBoundingClientRect();
|
||
const art = element.querySelector(".nebula-card-art").getBoundingClientRect();
|
||
return { title: { top: title.top, bottom: title.bottom, height: title.height }, art: { top: art.top, bottom: art.bottom } };
|
||
});
|
||
expect(Math.abs(layout.title.height - 52)).toBeLessThan(0.6);
|
||
if (position === "top") {
|
||
expect(Math.abs(layout.title.bottom - layout.art.top)).toBeLessThan(0.6);
|
||
} else {
|
||
expect(Math.abs(layout.art.bottom - layout.title.top)).toBeLessThan(0.6);
|
||
}
|
||
}
|
||
|
||
async function expectStandardCardFrame(card, size) {
|
||
const layout = await card.evaluate((element) => {
|
||
const face = element.querySelector(".nebula-card-face");
|
||
const art = element.querySelector(".nebula-card-art");
|
||
const title = element.querySelector("h3");
|
||
const copy = element.querySelector(".nebula-card-copy");
|
||
const rarity = element.querySelector(".nebula-card-rarity-symbol");
|
||
const faceBounds = face.getBoundingClientRect();
|
||
const artBounds = art.getBoundingClientRect();
|
||
const styles = element.ownerDocument.defaultView;
|
||
const titleStyles = styles.getComputedStyle(title);
|
||
const titleTextStyles = styles.getComputedStyle(title.querySelector("span"));
|
||
const rarityStyles = styles.getComputedStyle(rarity);
|
||
return {
|
||
layout: face.dataset.cardLayout,
|
||
facePattern: styles.getComputedStyle(face).backgroundImage,
|
||
titleBackground: titleStyles.backgroundColor,
|
||
titleDisplay: titleStyles.display,
|
||
titleAlignItems: titleStyles.alignItems,
|
||
titleJustifyItems: titleStyles.justifyItems,
|
||
titleFontSize: Number.parseFloat(titleStyles.fontSize),
|
||
titlePaddingRight: Number.parseFloat(titleStyles.paddingRight),
|
||
titleTextAlign: titleTextStyles.textAlign,
|
||
titleLineClamp: titleTextStyles.webkitLineClamp,
|
||
copyBackground: copy ? styles.getComputedStyle(copy).backgroundColor : null,
|
||
rarityPosition: rarityStyles.position,
|
||
rarityWidth: Number.parseFloat(rarityStyles.width),
|
||
leftInset: artBounds.left - faceBounds.left,
|
||
rightInset: faceBounds.right - artBounds.right
|
||
};
|
||
});
|
||
expect(layout.layout).toBe("standard");
|
||
expect(layout.facePattern).not.toBe("none");
|
||
expect(layout.facePattern).not.toContain("repeating-linear-gradient");
|
||
expect(layout.facePattern.match(/radial-gradient/g)).toHaveLength(4);
|
||
expect(layout.titleBackground).toBe("rgba(0, 0, 0, 0)");
|
||
expect(layout.titleDisplay).toBe("grid");
|
||
expect(layout.titleAlignItems).toBe("center");
|
||
expect(layout.titleJustifyItems).toBe("center");
|
||
expect(layout.titleTextAlign).toBe("center");
|
||
expect(layout.titleLineClamp).toBe("2");
|
||
if (size === "lg") {
|
||
expect(layout.copyBackground).toBe("rgba(0, 0, 0, 0)");
|
||
expect(layout.leftInset).toBeGreaterThan(10);
|
||
expect(layout.rightInset).toBeGreaterThan(10);
|
||
} else {
|
||
expect(layout.leftInset).toBeLessThan(3);
|
||
expect(layout.rightInset).toBeLessThan(3);
|
||
expect(layout.titleFontSize).toBeLessThan(14);
|
||
expect(layout.titlePaddingRight).toBeLessThan(12);
|
||
expect(layout.rarityPosition).toBe("absolute");
|
||
expect(layout.rarityWidth).toBe(13);
|
||
}
|
||
}
|
||
|
||
test("a failed Discord return explains the failure once on the login screen", async ({ page }) => {
|
||
await page.goto("/?cardsAuth=denied#/cards/shop");
|
||
await expect(page.getByRole("alert")).toHaveText("Connexion annulée : vous n’avez pas autorisé l’accès depuis Discord.");
|
||
await expect(page.getByRole("link", { name: "Se connecter avec Discord", exact: true })).toHaveAttribute("href", "/api/cards/auth/discord?returnTo=%2Fcards%2Fshop");
|
||
await expect(page).toHaveURL(/:\d+\/#\/cards\/shop$/);
|
||
await page.reload();
|
||
await expect(page.getByRole("heading", { name: "Sokko TCG", exact: true })).toBeVisible();
|
||
await expect(page.getByRole("alert")).toHaveCount(0);
|
||
});
|
||
|
||
test("player opens and reveals a three-card pack", async ({ page }) => {
|
||
test.setTimeout(60_000);
|
||
await page.goto("/#/cards");
|
||
await expect(page.locator(".nav-icon-cards")).toHaveCSS("mask-image", /tcg\.svg/);
|
||
await expect(page.locator(".sidebar-note")).toContainText("Sokko TCG");
|
||
await expect(page.getByRole("heading", { name: "Sokko TCG", exact: true })).toBeVisible();
|
||
await expect(page.getByText("Trading Card Game", { exact: true })).toBeVisible();
|
||
const loginArt = page.locator('.nebula-login-art img[src="/static/img/cards/login.webp"]');
|
||
await expect(loginArt).toBeVisible();
|
||
await expect.poll(() => loginArt.evaluate((image) => image.naturalWidth)).toBeGreaterThan(0);
|
||
const discordLogin = page.getByRole("link", { name: "Se connecter avec Discord", exact: true });
|
||
await expect(discordLogin).toHaveCSS("background-color", "rgb(88, 101, 242)");
|
||
await expect(discordLogin.locator("span")).toHaveCSS("color", "rgb(255, 255, 255)");
|
||
const discordIcon = discordLogin.locator('img[src="/static/icons/discord.svg"]');
|
||
await expect(discordIcon).toBeVisible();
|
||
await expect(discordIcon).toHaveCSS("width", "26px");
|
||
await expect(discordIcon).toHaveCSS("height", "26px");
|
||
await expect(page.getByRole("button", { name: "Test administrateur", exact: true })).toHaveCount(0);
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
const administrationButton = page.getByRole("link", { name: "Administration", exact: true });
|
||
const logoutButton = page.getByRole("button", { name: "Déconnexion", exact: true });
|
||
await expect(administrationButton).toBeVisible();
|
||
await expect(administrationButton).toHaveAttribute("href", "#/cards/admin");
|
||
await expect(logoutButton).toHaveAttribute("data-variant", "secondary");
|
||
// Le lien de bascule précède le menu latéral collant et l'accompagne au défilement.
|
||
expect(await administrationButton.evaluate((element) => element.nextElementSibling?.querySelector("nav")?.getAttribute("aria-label"))).toBe("Sections de Sokko TCG");
|
||
await expect(page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Accueil", exact: true })).toHaveAttribute("aria-current", "page");
|
||
await expect(page.locator(".nebula-player-hero.nds-page-hero")).toBeVisible();
|
||
await expect(page.getByRole("heading", { name: "Vue d’ensemble", exact: true })).toBeVisible();
|
||
await expect(page.locator('.nebula-opening-reserve[aria-label="Ouvertures disponibles"] .nebula-opening-reserve-value')).toContainText("3/ 5");
|
||
await expect(page.getByText("Probabilités", { exact: true })).toHaveCount(0);
|
||
// En 1280 × 720, l'en-tête, la rangée Guilde / meilleur tirage et les chiffres clés tiennent sans défiler.
|
||
// Comme sur Paquets, la réserve d'ouvertures se range sous le menu, avec un accès direct aux paquets.
|
||
await expect(page.locator(".nebula-dashboard-aside-slot .nebula-opening-reserve")).toContainText("Voir les paquets");
|
||
expect(await page.locator(".nebula-home-stats").evaluate((element) => element.getBoundingClientRect().bottom <= element.ownerDocument.defaultView.innerHeight + 1)).toBe(true);
|
||
|
||
await expandSections(page, "Sections de Sokko TCG");
|
||
// L'entrée Paquets porte le nombre d'ouvertures de la réserve automatique, comme la Guilde ses quêtes.
|
||
const packsLink = page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: /^Paquets/ });
|
||
await expect(packsLink.locator(".nds-badge")).toHaveText("3");
|
||
await packsLink.click();
|
||
await expect(page.getByRole("heading", { name: "Paquets permanents", exact: true })).toBeVisible();
|
||
await expect(page.getByRole("heading", { name: "Paquets événements", exact: true })).toBeVisible();
|
||
// Les ouvertures disponibles sont sous le menu, et non plus dans le titre de la page.
|
||
await expect(page.locator(".nebula-dashboard-aside-slot .nebula-opening-reserve")).toBeVisible();
|
||
// Les deux catégories sont côte à côte : elles commencent à la même hauteur.
|
||
const packCategoryBoxes = await page.locator(".nebula-pack-category").evaluateAll((sections) => sections.map((section) => section.getBoundingClientRect()).map(({ top, left }) => ({ top, left })));
|
||
expect(packCategoryBoxes[0].top).toBeCloseTo(packCategoryBoxes[1].top, 0);
|
||
expect(packCategoryBoxes[1].left).toBeGreaterThan(packCategoryBoxes[0].left);
|
||
// Titres et paquets restent alignés d'une section à l'autre, même si un sous-titre passe à la ligne.
|
||
for (const selector of [".nebula-pack-category h3", ".nebula-pack-category .nebula-pack"]) {
|
||
const [first, second] = await page.locator(selector).evaluateAll((elements) => elements.map((element) => element.getBoundingClientRect().top));
|
||
expect(first).toBeCloseTo(second, 0);
|
||
}
|
||
await expect(page.locator(".nebula-pack .nebula-collection-back")).toHaveCount(2);
|
||
await expect(page.locator('.nebula-pack-back img[src="/static/img/cards/primordial-nebula/back.webp"]')).toBeVisible();
|
||
await expect(page.locator('.nebula-pack-back img[src="/static/img/cards/astral-genesis/back.webp"]')).toBeVisible();
|
||
await expect(page.locator('.nebula-pack-back[data-card-size="md"]')).toHaveCount(2);
|
||
expect((await page.locator(".nebula-pack-back").first().boundingBox()).width).toBeCloseTo(180, 0);
|
||
await expect(page.locator(".nebula-pack").filter({ hasText: "Genèse Astrale" })).toBeVisible();
|
||
const originsPack = page.locator(".nebula-pack").filter({ hasText: "La Nébuleuse Originelle" });
|
||
await expect(originsPack.locator(".nebula-collection-back-copy")).toHaveText("La Nébuleuse Originelle");
|
||
await expect(originsPack.locator(".nebula-collection-back-copy")).not.toContainText("Sokko TCG");
|
||
expect(await originsPack.locator(".nebula-collection-back").evaluate((back) => {
|
||
const backBox = back.getBoundingClientRect();
|
||
const copyBox = back.querySelector(".nebula-collection-back-copy").getBoundingClientRect();
|
||
return (copyBox.top + copyBox.height / 2 - backBox.top) / backBox.height;
|
||
})).toBeGreaterThan(0.68);
|
||
// La tuile compacte se limite au dos de carte et à la description : elle est entièrement cliquable.
|
||
expect((await originsPack.boundingBox()).width).toBeCloseTo(180, 0);
|
||
await expect(originsPack).not.toHaveClass(/nds-card/);
|
||
// Le survol illumine le dos sans peindre le bouton derrière la description.
|
||
await originsPack.hover();
|
||
await expect(originsPack).toHaveCSS("background-image", "none");
|
||
await expect(originsPack).toHaveCSS("box-shadow", "none");
|
||
await expect(originsPack.locator(".nebula-pack-back")).toHaveCSS("box-shadow", /246, 196, 83/);
|
||
await expect(originsPack.locator(".nebula-pack-copy")).toHaveCSS("-webkit-line-clamp", "3");
|
||
// Les descriptions actuelles tiennent sur ces trois lignes, sans points de suspension.
|
||
expect(await page.locator(".nebula-pack-copy").evaluateAll((copies) => copies.every((copy) => copy.scrollHeight <= copy.clientHeight))).toBe(true);
|
||
await expect(page.locator(".nebula-pack-categories > .nds-panel")).toHaveCount(2);
|
||
await expect(page.getByText("Probabilités", { exact: true })).toHaveCount(0);
|
||
await page.getByRole("button", { name: "Ouvrir ce paquet : La Nébuleuse Originelle", exact: true }).click();
|
||
// L'étape d'ouverture garde le hero, affiche les probabilités et ne propose le retour qu'une fois les cartes révélées.
|
||
await expect(page.locator(".nebula-player-hero")).toBeVisible();
|
||
// Les particules passent sous la barre du haut : son flou serait recalculé à chaque image de l'animation.
|
||
await expect(page.locator(".topbar")).toHaveCSS("backdrop-filter", "none");
|
||
const openingOdds = page.getByRole("list", { name: "Probabilités" }).getByRole("listitem");
|
||
await expect(openingOdds).toHaveCount(5);
|
||
await expect(openingOdds.first()).toContainText(/Commun.*%/);
|
||
await expect(page.getByRole("button", { name: "Retour", exact: true })).toHaveCount(0);
|
||
await expect(page.getByRole("button", { name: "Révéler la carte" })).toHaveCount(3);
|
||
await expect(page.locator('.nebula-card-back img[src="/static/img/cards/primordial-nebula/back.webp"]')).toHaveCount(3);
|
||
await expect(page.locator(".nebula-card-back").first()).toHaveCSS("background-image", /primordial-nebula\/back\.webp/);
|
||
await expect(page.locator(".nebula-card-back .nebula-collection-back-copy strong")).toHaveText(["La Nébuleuse Originelle", "La Nébuleuse Originelle", "La Nébuleuse Originelle"]);
|
||
expect(await page.locator(".nebula-card-back .nebula-collection-back").first().evaluate((back) => {
|
||
const backBox = back.getBoundingClientRect();
|
||
const copyBox = back.querySelector(".nebula-collection-back-copy").getBoundingClientRect();
|
||
return (copyBox.top + copyBox.height / 2 - backBox.top) / backBox.height;
|
||
})).toBeLessThan(0.9);
|
||
// L'adresse de section survit au rechargement : l'ouverture en attente réapparaît, et l'accueil propose aussi de la reprendre.
|
||
await page.reload();
|
||
await expect(page.getByRole("button", { name: "Révéler la carte" })).toHaveCount(3);
|
||
// Le journal ne dévoile pas les cartes d'une ouverture encore en attente.
|
||
await page.goto("/#/cards/history");
|
||
await expect(page.getByText("Cartes à révéler", { exact: true })).toBeVisible();
|
||
await expect(page.getByRole("list", { name: "Cartes obtenues" })).toHaveCount(0);
|
||
await page.goto("/#/cards");
|
||
// L'accueil ne dévoile pas non plus la meilleure carte d'un tirage encore caché.
|
||
await expect(page.getByRole("button", { name: "Reprendre l’ouverture", exact: true })).toBeVisible();
|
||
await expect(page.locator(".nebula-home-rarest-card")).toHaveCount(0);
|
||
await page.getByRole("button", { name: "Reprendre l’ouverture", exact: true }).click();
|
||
await expect(page.getByRole("button", { name: "Révéler la carte" })).toHaveCount(3);
|
||
// Le badge « New » suit l'édition non possédée et n'apparaît qu'une fois la carte révélée : la première carte du tout premier paquet est forcément nouvelle.
|
||
const newEditions = await page.evaluate(async () => (await globalThis.fetch("/api/cards/state")).json().then((state) => state.pendingOpening.cards.map((card) => card.isNewEdition)));
|
||
expect(newEditions[0]).toBe(true);
|
||
await expect(page.locator(".nebula-card-new-badge")).toHaveCount(0);
|
||
await page.getByRole("button", { name: "Tout révéler" }).click();
|
||
const openingStage = page.locator(".nebula-opening-stage");
|
||
const revealedCards = page.locator('.nebula-opening-cards .nebula-card[data-card-size="lg"]');
|
||
await expect(revealedCards).toHaveCount(3);
|
||
await expect(page.getByRole("button", { name: "Retour", exact: true })).toHaveCount(0);
|
||
await expect(revealedCards.first()).toHaveAttribute("data-reveal-phase", /aura|revealing/);
|
||
// L'ouverture montre le vrai format `lg`, 300 x 420 px, dès que les trois cartes tiennent.
|
||
const revealedBox = await revealedCards.first().boundingBox();
|
||
expect([Math.round(revealedBox.width), Math.round(revealedBox.height)]).toEqual([300, 420]);
|
||
expect(await revealedCards.evaluateAll((cards) => cards.map((card) => card.ownerDocument.defaultView.getComputedStyle(card).opacity))).toEqual(["1", "1", "1"]);
|
||
await expect(revealedCards.first().locator(".nebula-card-face")).toHaveCSS("background-image", /conic-gradient\(from 20deg, rgb\(255, 209, 92\)/);
|
||
await expect(revealedCards.first().locator(".nebula-card-rarity-symbol svg")).toHaveCSS("fill", /url\(/);
|
||
await expect(revealedCards.first().locator(".nebula-card-particles i").first()).toHaveCSS("color", "rgb(255, 59, 48)");
|
||
await expect(page.getByRole("button", { name: "Retour", exact: true })).toBeVisible();
|
||
expect(await revealedCards.evaluateAll((cards) => cards.map((card) => card.querySelector(".nebula-card-new-badge")?.textContent === "New"))).toEqual(newEditions);
|
||
expect(await revealedCards.evaluateAll((cards) => cards.map((card) => card.getAttribute("aria-label").endsWith(", nouvelle carte")))).toEqual(newEditions);
|
||
const revealedNames = await revealedCards.evaluateAll((cards) => cards.map((card) => card.getAttribute("aria-label").replace(/ révélée(, nouvelle carte)?$/, "")));
|
||
await expect.poll(() => page.evaluate(async () => (await globalThis.fetch("/api/cards/state")).json().then((state) => state.pendingOpening))).toBeNull();
|
||
expect((await openingStage.boundingBox()).width).toBeLessThanOrEqual(1000);
|
||
await expect(page.locator(".nebula-opening-summary")).toHaveCount(0);
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
await expect(page.getByRole("button", { name: "Retour", exact: true })).toBeVisible();
|
||
expect(await page.evaluate(() => globalThis.document.documentElement.scrollWidth <= globalThis.document.documentElement.clientWidth)).toBe(true);
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
await page.getByRole("button", { name: "Retour", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Paquets permanents", exact: true })).toBeVisible();
|
||
await expect(page).toHaveURL(/#\/cards\/packs$/);
|
||
// Une fois révélées, les cartes apparaissent en référence dans le journal.
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Historique", exact: true }).click();
|
||
const historyCards = page.getByRole("list", { name: "Cartes obtenues" }).getByRole("listitem");
|
||
await expect(historyCards).toHaveCount(3);
|
||
await expect(historyCards.first().getByRole("img")).toHaveAttribute("aria-label", /^(Commun|Rare|Épique|Légendaire|Mythique)$/);
|
||
await expect(historyCards.locator(".nds-badge").filter({ hasText: /· (Commun|Rare|Épique|Légendaire|Mythique)\b/ })).toHaveCount(0);
|
||
// Le symbole de chaque carte prend la couleur de sa rareté (une légendaire n'a pas la couleur d'une commune).
|
||
expect(await historyCards.evaluateAll((items) => items.every((item) => {
|
||
const color = item.ownerDocument.defaultView.getComputedStyle(item.querySelector(".nebula-history-rarity")).color;
|
||
return color === { common: "rgb(156, 163, 175)", rare: "rgb(59, 130, 246)", epic: "rgb(217, 70, 239)", legendary: "rgb(246, 196, 83)", mythic: "rgb(244, 241, 255)" }[item.dataset.rarity];
|
||
}))).toBe(true);
|
||
for (const name of revealedNames) await expect(historyCards.filter({ hasText: name }).first()).toBeVisible();
|
||
await expect(page.getByText("Cartes à révéler", { exact: true })).toHaveCount(0);
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Accueil", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Carte la plus rare tirée", exact: true })).toBeVisible();
|
||
expect(revealedNames).toContain(await page.locator(".nebula-home-rarest-copy > strong").textContent());
|
||
const rarestCard = page.locator('.nebula-home-rarest-card .nebula-card[data-card-size="md"]');
|
||
await expect(rarestCard.locator(".nebula-card-art")).toBeVisible();
|
||
await expect(rarestCard.locator(".nebula-card-art img")).toBeVisible();
|
||
await expect(rarestCard.locator(".nebula-card-rarity-symbol")).toBeVisible();
|
||
await expect(rarestCard.locator("h3")).toBeVisible();
|
||
// La carte la plus rare ouvre la même fiche que l'album, en grand format.
|
||
const rarestName = await page.locator(".nebula-home-rarest-copy > strong").textContent();
|
||
await page.getByRole("button", { name: `Voir ${rarestName}`, exact: true }).click();
|
||
const rarestDialog = page.getByRole("dialog", { name: rarestName, exact: true });
|
||
await expect(rarestDialog.locator('.nebula-card[data-card-size="lg"]')).toBeVisible();
|
||
await expect(rarestDialog.locator("dl > div").filter({ hasText: "Exemplaires possédés" }).locator("dd")).toHaveText(/^[1-9]\d*$/);
|
||
await expect(rarestDialog.getByRole("button", { name: "Ajouter aux favoris" })).toBeVisible();
|
||
await rarestDialog.getByRole("button", { name: "Fermer" }).click();
|
||
await expect(rarestDialog).toHaveCount(0);
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Collection", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: /Album/ })).toHaveCount(0);
|
||
await expect(page.getByRole("heading", { name: "Ma collection", exact: true, level: 2 })).toBeVisible();
|
||
// L'album sépare les cartes par collection, dans l'ordre du catalogue ; un filtre masque les groupes vides.
|
||
await expect(page.locator(".nebula-album-group > h3")).toHaveText([/^La Nébuleuse Originelle \d+ \/ \d+$/, /^Genèse Astrale \d+ \/ \d+$/, /^Poussières d'étoiles \d+ \/ \d+$/]);
|
||
// Le titre porte le badge des éditions différentes possédées et une fine barre de progression.
|
||
const nebulaBadge = page.locator(".nebula-album-group > h3 .nds-badge").first();
|
||
await expect(page.locator(".nebula-progress-tile")).toHaveCount(0);
|
||
await expect(page.locator(".nebula-album-group > .nds-progress")).toHaveCount(3);
|
||
await expect(nebulaBadge).toHaveText(/^[1-9]\d* \/ \d+$/);
|
||
await expect(page.locator(".nebula-album-group", { hasText: "Genèse Astrale" }).locator(".nebula-album-entry").first()).toBeVisible();
|
||
// Les filtres reprennent les menus à cases à cocher des pages de jeux, avec leurs badges actifs.
|
||
await expect(page.locator(".nebula-album-filters")).toHaveAttribute("data-variant", "horizontal-menu");
|
||
const albumFilters = page.locator(".nebula-album-filters");
|
||
await albumFilters.getByRole("button", { name: "Collection", exact: true }).click();
|
||
await albumFilters.getByRole("checkbox", { name: "Genèse Astrale" }).check();
|
||
await page.keyboard.press("Escape");
|
||
// Le menu passe au-dessus des cartes : sa dernière option reste cliquable, et un badge permet de la retirer.
|
||
await albumFilters.getByRole("button", { name: "Rareté", exact: true }).click();
|
||
await albumFilters.getByRole("checkbox", { name: "Mythique" }).check();
|
||
await page.keyboard.press("Escape");
|
||
await albumFilters.getByRole("button", { name: "Retirer le filtre Rareté : Mythique" }).click();
|
||
await expect(page.locator(".nebula-album-group > h3")).toHaveText([/^Genèse Astrale \d+ \/ \d+$/]);
|
||
// Le bouton de réinitialisation vide la recherche et remet tous les filtres à zéro.
|
||
await expect(albumFilters.getByRole("button", { name: "Retirer le filtre Collection : Genèse Astrale" })).toBeVisible();
|
||
await page.getByPlaceholder("Rechercher...").first().fill("aucune carte ne porte ce nom");
|
||
await expect(page.getByText("Aucune édition ne correspond à ces filtres.")).toBeVisible();
|
||
await page.getByRole("button", { name: "Réinitialiser les filtres" }).click();
|
||
await expect(page.getByPlaceholder("Rechercher...").first()).toHaveValue("");
|
||
await expect(albumFilters.locator(".nds-active-filter")).toHaveCount(0);
|
||
await expect(page.locator(".nebula-album-group > h3")).toHaveCount(3);
|
||
// Au défilement, le menu collant reste sous le header au lieu de passer derrière.
|
||
await page.evaluate(() => globalThis.scrollTo(0, 900));
|
||
await expect.poll(() => page.evaluate(() => globalThis.scrollY)).toBeGreaterThan(0);
|
||
const [topbarBottom, stickyNavTop] = await page.evaluate(() => [globalThis.document.querySelector(".topbar").getBoundingClientRect().bottom, globalThis.document.querySelector(".nebula-dashboard-nav").getBoundingClientRect().top]);
|
||
expect(stickyNavTop).toBeGreaterThanOrEqual(topbarBottom);
|
||
await page.evaluate(() => globalThis.scrollTo(0, 0));
|
||
await expect(page.locator(".nebula-album-entry:not([data-missing])").first()).toBeVisible();
|
||
await expect(page.locator(".nebula-card-concealed").first()).toBeVisible();
|
||
await expect(page.locator('.nebula-card-concealed[data-card-size="md"]').first()).toBeVisible();
|
||
await expect(page.locator(".nebula-card-concealed .nebula-card-face")).toHaveCount(0);
|
||
const undiscoveredCard = page.locator(".nebula-album-entry[data-undiscovered] .nebula-card-concealed").first();
|
||
await expect(undiscoveredCard).toBeVisible();
|
||
await expect(undiscoveredCard.locator(".nebula-card-tilt-surface")).toHaveCSS("filter", "grayscale(0.6) brightness(0.72)");
|
||
await expect(undiscoveredCard.locator(".nebula-card-tilt-surface")).toHaveCSS("opacity", "0.7");
|
||
expect((await undiscoveredCard.boundingBox()).width).toBeLessThanOrEqual(181);
|
||
const holographicCard = page.locator('.nebula-card[data-holo-effect="spectral-prism"][data-holo-palette="aurora"]').first();
|
||
const cosmicCard = page.locator('.nebula-card[data-holo-effect="spectral-prism"][data-holo-palette="cosmic"]').first();
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toBeAttached();
|
||
await expect(holographicCard.locator(".nebula-card-holo-secondary")).toBeAttached();
|
||
await expect(holographicCard).toHaveAttribute("data-card-size", "md");
|
||
await expect(holographicCard.locator("h3")).toBeVisible();
|
||
await expect(holographicCard.locator(".nebula-card-rarity-symbol")).toBeVisible();
|
||
await expect(holographicCard.locator(".nebula-card-quantity")).toBeVisible();
|
||
await expect(holographicCard.locator(".nebula-card-copy")).toHaveCount(0);
|
||
await expect(cosmicCard).toBeAttached();
|
||
expect(await holographicCard.evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--holo-1").trim())).toBe("#0b5e4a");
|
||
expect(await cosmicCard.evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--holo-1").trim())).toBe("#1e1b6b");
|
||
const holographicGradient = await holographicCard.evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--holo-gradient").trim());
|
||
const renderedSpectrum = await holographicCard.locator(".nebula-card-holo-primary").evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element).backgroundImage);
|
||
expect(holographicGradient).not.toMatch(/\d+%/);
|
||
expect(holographicGradient.match(/#[0-9a-f]{6}/gi)).toHaveLength(21);
|
||
expect(renderedSpectrum.match(/linear-gradient/g)).toHaveLength(1);
|
||
await expectArtworkFramed(holographicCard);
|
||
await expectFixedTitleBand(holographicCard, "bottom");
|
||
await expectStandardCardFrame(holographicCard, "md");
|
||
await expect.poll(() => holographicCard.locator(".nebula-card-art img").evaluate((image) => ({ width: image.naturalWidth, height: image.naturalHeight }))).toEqual({ width: 800, height: 800 });
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toHaveCSS("background-repeat", "no-repeat");
|
||
await holographicCard.scrollIntoViewIfNeeded();
|
||
const bounds = await holographicCard.boundingBox();
|
||
await page.mouse.move(bounds.x + bounds.width * 0.82, bounds.y + bounds.height * 0.24);
|
||
await expect.poll(() => holographicCard.evaluate((element) => Number.parseFloat(element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--card-tilt-y")))).toBeGreaterThan(1);
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toHaveCSS("opacity", "0.46");
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toHaveCSS("animation-name", "nebula-spectral-prism");
|
||
await expect(holographicCard.locator(".nebula-card-holo-secondary")).toHaveCSS("opacity", "0.28");
|
||
await page.mouse.move(bounds.x + bounds.width + 5, bounds.y + bounds.height * 0.5);
|
||
await expect.poll(() => holographicCard.evaluate((element) => element.matches(":hover"))).toBe(true);
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toHaveCSS("opacity", "0.46");
|
||
const tiltedHitbox = await holographicCard.boundingBox();
|
||
expect(Math.abs(tiltedHitbox.x - bounds.x)).toBeLessThan(0.1);
|
||
expect(Math.abs(tiltedHitbox.y - bounds.y)).toBeLessThan(0.1);
|
||
await page.mouse.move(0, 0);
|
||
const tiltAfterLeave = await holographicCard.evaluate((element) => Math.abs(Number.parseFloat(element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--card-tilt-y"))));
|
||
expect(tiltAfterLeave).toBeGreaterThan(0.2);
|
||
await expect.poll(() => holographicCard.evaluate((element) => Math.abs(Number.parseFloat(element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--card-tilt-y"))))).toBeLessThan(0.1);
|
||
await holographicCard.click();
|
||
const detailDialog = page.getByRole("dialog");
|
||
const largeCard = detailDialog.locator('.nebula-card[data-card-size="lg"][data-holo-palette="aurora"]');
|
||
await expect(detailDialog).toHaveCSS("overflow-x", "hidden");
|
||
expect((await detailDialog.boundingBox()).width).toBeGreaterThan(900);
|
||
await expectArtworkFramed(largeCard);
|
||
await expectFixedTitleBand(largeCard, "top");
|
||
await expectStandardCardFrame(largeCard, "lg");
|
||
await expect(largeCard.locator(".nebula-card-copy p")).toBeVisible();
|
||
await expect(largeCard.locator(".nebula-card-quantity")).toHaveCount(0);
|
||
// Vérifié sur le build : le flou plein écran derrière une carte animée ruine sa fluidité.
|
||
await expect(page.locator(".nds-modal-backdrop")).toHaveCSS("backdrop-filter", "none");
|
||
const ownedCopiesLabel = detailDialog.getByText("Exemplaires possédés", { exact: true });
|
||
await expect(ownedCopiesLabel).toBeVisible();
|
||
await expect(ownedCopiesLabel).toHaveCSS("white-space", "nowrap");
|
||
await expect(detailDialog.locator("dl > div").filter({ hasText: "Exemplaires possédés" }).locator("dd")).toHaveText(/^[1-9]\d*$/);
|
||
expect(await largeCard.evaluate((element) => ({
|
||
holographicLayer: Number(element.ownerDocument.defaultView.getComputedStyle(element.querySelector(".nebula-card-holo-primary")).zIndex),
|
||
copy: Number(element.ownerDocument.defaultView.getComputedStyle(element.querySelector(".nebula-card-copy")).zIndex)
|
||
}))).toEqual({ holographicLayer: 2, copy: 3 });
|
||
expect(await detailDialog.evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
expect(await detailDialog.evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
expect(await ownedCopiesLabel.evaluate((element) => {
|
||
const styles = element.ownerDocument.defaultView.getComputedStyle(element);
|
||
return element.getBoundingClientRect().height <= Number.parseFloat(styles.lineHeight) * 1.1;
|
||
})).toBe(true);
|
||
await detailDialog.getByRole("button", { name: "Fermer" }).click();
|
||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||
await holographicCard.hover();
|
||
await expect(holographicCard.locator(".nebula-card-tilt-surface")).toHaveCSS("transform", "none");
|
||
await expect(holographicCard.locator(".nebula-card-holo-primary")).toHaveCSS("animation-name", "none");
|
||
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
const overflow = await page
|
||
.locator("html")
|
||
.evaluate((element) => element.scrollWidth > element.clientWidth);
|
||
expect(overflow).toBe(false);
|
||
|
||
// Boutique : barème, recyclage et achat d'une ouverture (pas assez de poussière au départ).
|
||
await expandSections(page, "Sections de Sokko TCG");
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Boutique", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Boutique", exact: true })).toBeVisible();
|
||
const shopItem = page.locator('.nebula-shop-item:not([data-item="pack"])');
|
||
// Le paquet de la boutique se présente avec son dos et son prix, et reste hors de portée sans assez de poussière.
|
||
const shopPackItem = page.locator('.nebula-shop-item[data-item="pack"]');
|
||
await expect(shopPackItem.getByRole("heading", { name: "Poussières d'étoiles" })).toBeVisible();
|
||
await expect(shopPackItem.locator('img[src="/static/img/cards/stardust/back.webp"]')).toBeVisible();
|
||
await expect(shopPackItem.getByRole("button", { name: "Acheter et ouvrir" })).toBeDisabled();
|
||
await expect(shopPackItem).toContainText("Il vous manque 60 poussières.");
|
||
// Le manque s'affiche au-dessus du bouton : les boutons d'une même rangée d'articles restent alignés.
|
||
const buyButtons = await page.locator(".nebula-shop-grid .nebula-shop-item-actions > button:last-child").evaluateAll((buttons) => buttons.map((button) => ({
|
||
row: Math.round(button.closest(".nebula-shop-item").getBoundingClientRect().top), bottom: Math.round(button.getBoundingClientRect().bottom),
|
||
last: button === button.parentElement.lastElementChild
|
||
})));
|
||
expect(buyButtons.length).toBeGreaterThan(1);
|
||
for (const button of buyButtons) {
|
||
expect(button.last).toBe(true);
|
||
expect(button.bottom).toBe(buyButtons.find((other) => other.row === button.row).bottom);
|
||
}
|
||
await page.locator(".nebula-shop-grid").screenshot({ path: join(tmpdir(), "sokkog-cards-shop.png") });
|
||
// Le solde ne met plus en avant les ouvertures achetées : la boutique est une grille d'articles illustrés.
|
||
await expect(page.locator(".nebula-shop-wallet")).not.toContainText("Ouvertures achetées");
|
||
// Le solde est sous le menu, et la page se limite à son en-tête et à ses articles.
|
||
await expect(page.locator(".nebula-dashboard-aside-slot .nebula-shop-wallet")).toBeVisible();
|
||
await expect(page.getByRole("heading", { name: "À échanger", exact: true })).toHaveCount(0);
|
||
await expect(shopItem.getByRole("button", { name: /Utiliser/ })).toHaveCount(0);
|
||
await expect(page.locator(".nebula-shop")).not.toContainText("doublon");
|
||
const shopItemImage = shopItem.locator('.nds-card-cover img[src="/static/img/cards/shop/pack.webp"]');
|
||
await expect(shopItemImage).toBeVisible();
|
||
await expect.poll(() => shopItemImage.evaluate((image) => image.complete && image.naturalWidth)).toBeGreaterThan(0);
|
||
await expect(shopItem.getByRole("heading", { name: "Ouverture de paquet" })).toBeVisible();
|
||
await expect(shopItem.getByRole("button", { name: "Acheter" })).toBeDisabled();
|
||
await expect(shopItem).toContainText("Il vous manque 30 poussières.");
|
||
expect(await page.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await expect(page).toHaveURL(/#\/cards\/shop$/);
|
||
|
||
// Le recyclage vit dans la Collection : plus d'entrée de menu, et l'ancienne adresse y mène.
|
||
await expect(page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Recyclage", exact: true })).toHaveCount(0);
|
||
await page.goto("/#/cards/recycling");
|
||
// Le bouton du menu replié nomme la section courante ; la pastille des quêtes en attente le suit.
|
||
await expect(selectTrigger(page, "Sections de Sokko TCG").locator(".nebula-dashboard-menu-current")).toHaveText("Sections de Sokko TCG : Collection");
|
||
await expect(page.locator(".nebula-album-group").first()).toBeVisible();
|
||
await expect(page.locator(".nebula-recycle-box")).toHaveCount(0);
|
||
expect(await page.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
|
||
// En demi-écran, le hero empile le texte et le compte au lieu d'écraser le titre.
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
expect(await page.locator(".nebula-player-hero > div").first().evaluate((element) => element.getBoundingClientRect().width)).toBeGreaterThan(400);
|
||
expect(await page.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
|
||
// Échanges et dons : le type se choisit avec le groupe NDS et l'adresse de la section se recharge.
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Échanges et dons", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Échanges et dons", exact: true })).toBeVisible();
|
||
await page.reload();
|
||
await expect(page.getByRole("heading", { name: "Échanges et dons", exact: true })).toBeVisible();
|
||
await expect(page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Échanges et dons", exact: true })).toHaveAttribute("aria-current", "page");
|
||
});
|
||
|
||
test("administrator navigates sections, manages mythic content and previews visuals", async ({ page }) => {
|
||
test.setTimeout(90_000);
|
||
await page.clock.install();
|
||
const noOverflow = async () => expect(await page.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await page.goto("/#/cards/admin");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin$/);
|
||
const backToGame = page.getByRole("link", { name: "Retour au jeu", exact: true });
|
||
await expect(backToGame).toHaveAttribute("href", "#/cards");
|
||
expect(await backToGame.evaluate((element) => element.nextElementSibling?.querySelector("nav")?.getAttribute("aria-label"))).toBe("Sections de l’administration");
|
||
await expect(page.getByRole("navigation", { name: "Sections de Sokko TCG" })).toHaveCount(0);
|
||
await expect(page.getByRole("heading", { name: "Tableau de bord Sokko TCG", exact: true })).toBeVisible();
|
||
const playersStat = page.locator(".nebula-dashboard-stat").filter({ has: page.getByText("Joueurs", { exact: true }) });
|
||
await expect(playersStat.locator("strong")).toHaveText("2");
|
||
await expect(playersStat.locator("small")).toHaveText(/^[0-9]+ actifs? sur 7 jours$/);
|
||
await expect(page.locator(".nebula-admin-alerts")).toContainText("Rien à signaler.");
|
||
await expect(page.locator(".nebula-dashboard-stat .nebula-dashboard-stat-label")).toHaveText(["Joueurs", "Collections actives", "Cartes différentes", /^Carte du jour n° \d+$/]);
|
||
const collectionsStat = page.locator(".nebula-dashboard-stat").filter({ has: page.getByText("Collections actives", { exact: true }) });
|
||
await expect(collectionsStat.locator("strong")).toHaveText("3");
|
||
await expect(collectionsStat.locator("small")).toHaveText("sur 7 collections au total");
|
||
await expect(page.locator(".nebula-dashboard-stat").filter({ has: page.getByText("Cartes différentes", { exact: true }) }).locator("small")).toHaveText(/^dont [0-9]+ variantes? mythiques?$/);
|
||
// Les joueurs sont dans la vue d'ensemble : l'ancienne adresse y redirige.
|
||
const players = page.locator(".nebula-admin-player-list");
|
||
await expect(players.getByRole("columnheader")).toHaveText(["Joueur", "Paquets", "Dernier", "Cartes", "Échanges", "Réserve", "Poussière"]);
|
||
const devRow = players.getByRole("row", { name: /Version développement/ });
|
||
await expect(devRow).toContainText(/[0-5] \/ 5/);
|
||
await expect(devRow.locator(".nebula-stardust")).toHaveText("0");
|
||
await expect(devRow.locator(".nebula-stardust .nebula-currency-icon")).toHaveAttribute("src", "/static/icons/stardust.svg");
|
||
|
||
const navigation = page.getByRole("navigation", { name: "Sections de l’administration" });
|
||
await expect(navigation.getByRole("link")).toHaveText(["Vue d’ensemble", "Collections", "Codes cadeaux", "Boutique", "Guilde", "Atelier visuel", "Historique"]);
|
||
await expect(navigation.getByRole("link", { name: "Vue d’ensemble" })).toHaveAttribute("aria-current", "page");
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
expect(await page.locator(".nebula-dashboard-aside").evaluate((element) => globalThis.getComputedStyle(element).position)).toBe("sticky");
|
||
// En demi-écran, le menu se replie derrière un bouton qui nomme la section courante et l'ouvre par-dessus le contenu.
|
||
await page.setViewportSize({ width: 768, height: 720 });
|
||
const sectionsToggle = selectTrigger(page, "Sections de l’administration");
|
||
await expect(sectionsToggle).toHaveText("Sections de l’administration : Vue d’ensemble");
|
||
await expect(navigation).toBeHidden();
|
||
await sectionsToggle.click();
|
||
await expect(sectionsToggle).toHaveAttribute("aria-expanded", "true");
|
||
expect(await navigation.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
|
||
for (const link of await navigation.getByRole("link").all()) await expect(link).toBeInViewport();
|
||
await page.keyboard.press("Escape");
|
||
await expect(navigation).toBeHidden();
|
||
await expect(sectionsToggle).toBeFocused();
|
||
await sectionsToggle.click();
|
||
await page.locator("#nebula-admin-title").click();
|
||
await expect(navigation).toBeHidden();
|
||
await noOverflow();
|
||
|
||
await page.goto("/#/cards/admin/players");
|
||
await expect(selectTrigger(page, "Sections de l’administration")).toHaveText("Sections de l’administration : Vue d’ensemble");
|
||
await expect(players).toBeVisible();
|
||
|
||
await page.goto("/#/cards/admin/collections");
|
||
await expect(selectTrigger(page, "Sections de l’administration")).toHaveText("Sections de l’administration : Collections");
|
||
const collectionTiles = page.locator(".nebula-admin-collection-tile");
|
||
await expect(collectionTiles).toHaveCount(7);
|
||
const genesisTile = page.getByRole("link", { name: "Ouvrir la collection Genèse Astrale" });
|
||
await expect(genesisTile).toContainText("Événement");
|
||
await expect(genesisTile.locator(".nebula-admin-collection-counts > span")).toHaveText(["11cartes", "12variations", "1mythique tirable"]);
|
||
await expect(genesisTile.locator(".nebula-admin-rarity-counts b")).toHaveText(["4", "4", "2", "1", "1"]);
|
||
await expect(genesisTile.locator(".nebula-admin-pack-activity")).toHaveText(/^\d+ ouvertures? sur 7 jours/);
|
||
await expect(genesisTile).not.toContainText("Ouverture mythique");
|
||
await expect(genesisTile.locator(".nebula-collection-back")).toBeVisible();
|
||
const tileBackWidth = async () => Math.round((await genesisTile.locator(".nebula-admin-collection-back").boundingBox()).width);
|
||
expect(await tileBackWidth()).toBe(140);
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
expect(await tileBackWidth()).toBe(180);
|
||
await page.setViewportSize({ width: 768, height: 720 });
|
||
await expect(page.locator(".nebula-admin-catalog-card")).toHaveCount(0);
|
||
await noOverflow();
|
||
|
||
await page.getByRole("link", { name: "Ouvrir la collection La Nébuleuse Originelle" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/collections\/primordial-nebula$/);
|
||
await expect(selectTrigger(page, "Sections de l’administration")).toHaveText("Sections de l’administration : Collections");
|
||
await expect(page.locator(".nebula-admin-collection-card")).toContainText("Primordial Nebula");
|
||
const dragonCatalogCard = page.locator(".nebula-admin-catalog-card").filter({ hasText: "Dragon du Néant Étoilé" }).filter({ hasText: "Prisme spectral — Aurore" });
|
||
await expect(dragonCatalogCard.locator('.nebula-card[data-card-size="sm"]')).toBeVisible();
|
||
await dragonCatalogCard.getByRole("button", { name: "Voir Dragon du Néant Étoilé" }).click();
|
||
const dragonDialog = page.getByRole("dialog", { name: "Dragon du Néant Étoilé" });
|
||
await expect(dragonDialog.locator('.nebula-card[data-card-size="lg"]')).toBeVisible();
|
||
await expect(dragonDialog).toContainText("Prisme spectral — Aurore");
|
||
await dragonDialog.getByRole("button", { name: "Configurer la version mythique" }).click();
|
||
await expect(dragonDialog).toHaveCount(0);
|
||
const dragonMythic = page.locator("#nebula-admin-mythic-starvoid-dragon");
|
||
const mythicEditorPanel = page.locator("#nebula-admin-mythic-editor-panel");
|
||
await expect(page.locator(".nebula-admin-mythic-tile")).toHaveCount(6);
|
||
await expect(dragonMythic.locator('.nebula-card[data-card-size="md"]')).toHaveCount(1);
|
||
await expect(dragonMythic.locator(".nebula-admin-mythic-hint")).toHaveText("2 mythiques");
|
||
await expect(page.locator(".nebula-admin-catalog-card code")).toHaveCount(0);
|
||
const dragonTileButton = dragonMythic.getByRole("button", { name: "Configurer la version mythique de Dragon du Néant Étoilé" });
|
||
await expect(dragonTileButton).toHaveAttribute("aria-pressed", "true");
|
||
await expect(mythicEditorPanel.getByRole("heading", { name: "Version mythique · Dragon du Néant Étoilé" })).toBeVisible();
|
||
await expect(mythicEditorPanel.getByRole("heading", { name: "Ouverture mythique de la carte" })).toBeVisible();
|
||
await expect(mythicEditorPanel.locator(".nebula-admin-card-opening-block .nebula-card")).toHaveAttribute("data-card-size", "md");
|
||
await expect(mythicEditorPanel.getByRole("button", { name: "Retirer Prisme spectral — Aurore des tirages" })).toHaveClass(/ui-tooltip-anchor/);
|
||
const dragonVariations = mythicEditorPanel.locator(".nebula-admin-mythic-variation");
|
||
await expect(dragonVariations).toHaveCount(2);
|
||
await expect(dragonVariations.locator("strong")).toHaveText(["Aurore", "Cosmique"]);
|
||
await expect(dragonVariations.locator('.nebula-card[data-card-size="sm"]')).toHaveCount(2);
|
||
await expect(mythicEditorPanel.getByRole("button", { name: "Ajouter une variation" })).toBeVisible();
|
||
await dragonVariations.nth(1).getByRole("button", { name: "Régler Prisme spectral — Cosmique" }).click();
|
||
await expect(dragonVariations.nth(1)).toHaveAttribute("data-selected", "true");
|
||
await expect(mythicEditorPanel.locator(".nebula-admin-card-opening-block")).toContainText("Prisme spectral — Cosmique");
|
||
// La variation sélectionnée se règle dans un panneau à onglets : Holo, puis Particules (aucune animation au départ).
|
||
const cosmicSettings = mythicEditorPanel.getByRole("region", { name: "Réglages de Prisme spectral — Cosmique" });
|
||
await expect(cosmicSettings.getByRole("tab")).toHaveText(["Holo", "Particules"]);
|
||
// Un effet dont la carte n'a pas les fichiers reste visible mais désactivé, avec la liste des fichiers manquants.
|
||
await selectTrigger(cosmicSettings, "Effet").click();
|
||
await expect(cosmicSettings.getByRole("option")).toHaveText(["Prisme spectral", "Reflet diffractif", "Glace brisée", /^Parallaxe prismatique/]);
|
||
const parallaxOption = cosmicSettings.getByRole("option", { name: /^Parallaxe prismatique/ });
|
||
await expect(parallaxOption).toBeDisabled();
|
||
await expect(parallaxOption.locator(".nds-select-option-hint")).toHaveText("Fichiers manquants : __cutout et __backdrop");
|
||
await page.keyboard.press("Escape");
|
||
// La corbeille de la variation sélectionnée est dans l'en-tête de son panneau.
|
||
const trashButton = cosmicSettings.getByRole("button", { name: "Supprimer la variation Prisme spectral — Cosmique" });
|
||
await expect(trashButton).toHaveAttribute("data-variant", "danger");
|
||
await expect(trashButton).toHaveClass(/nds-icon-button/);
|
||
await expect(trashButton).not.toHaveText(/./);
|
||
await cosmicSettings.getByRole("tab", { name: "Particules" }).click();
|
||
await expect(selectTrigger(cosmicSettings, "Animation")).toBeEnabled();
|
||
await expect(selectTrigger(cosmicSettings, "Animation")).toHaveText("Aucune");
|
||
await cosmicSettings.getByRole("tab", { name: "Holo" }).click();
|
||
// Changer la finition d'une variation possédée : confirmation, même identifiant, nouvelle finition visible.
|
||
await dragonVariations.first().getByRole("button", { name: "Régler Prisme spectral — Aurore" }).click();
|
||
const auroraSettings = mythicEditorPanel.getByRole("region", { name: "Réglages de Prisme spectral — Aurore" });
|
||
const saveAurora = auroraSettings.getByRole("button", { name: "Enregistrer" });
|
||
await expect(saveAurora).toBeDisabled();
|
||
await auroraSettings.getByLabel("Palette holographique").click();
|
||
await auroraSettings.getByRole("button", { name: "Cosmique", exact: true }).click();
|
||
await expect(auroraSettings.getByRole("status")).toHaveText("Cette combinaison existe déjà.");
|
||
await expect(saveAurora).toBeDisabled();
|
||
await auroraSettings.getByLabel("Palette holographique").click();
|
||
await auroraSettings.getByRole("button", { name: "Solaire", exact: true }).click();
|
||
await expect(mythicEditorPanel.locator(".nebula-admin-card-opening-block")).toContainText("Prisme spectral — Solaire");
|
||
await expect(dragonVariations.first()).toHaveAttribute("data-modified", "true");
|
||
await expect(dragonVariations.first()).toContainText("Non enregistrée");
|
||
await saveAurora.click();
|
||
const finishDialog = page.getByRole("dialog", { name: "Changer la finition de Prisme spectral — Aurore ?" });
|
||
// D'autres parcours peuvent tirer cette variation : le nombre de joueurs varie selon l'ordre des tests.
|
||
await expect(finishDialog).toContainText(/Les joueurs qui la possèdent \(\d+\) verront Prisme spectral — Solaire à la place\./);
|
||
await finishDialog.getByRole("button", { name: "Changer la finition" }).click();
|
||
await expect(dragonVariations.locator("strong")).toHaveText(["Solaire", "Cosmique"]);
|
||
await expect(dragonVariations.first()).not.toHaveAttribute("data-modified");
|
||
const changedConfig = await page.evaluate(() => globalThis.fetch("/api/cards/config").then((response) => response.json()));
|
||
expect(changedConfig.catalog.editions.find((edition) => edition.id === "starvoid-dragon-spectral-prism-aurora")?.finishIds).toEqual(["spectral-prism-solar"]);
|
||
// « Annuler » oublie le réglage en cours sans rien enregistrer.
|
||
const solarSettings = mythicEditorPanel.getByRole("region", { name: "Réglages de Prisme spectral — Solaire" });
|
||
await solarSettings.getByLabel("Palette holographique").click();
|
||
await solarSettings.getByRole("button", { name: "Aurore", exact: true }).click();
|
||
await solarSettings.getByRole("button", { name: "Annuler" }).click();
|
||
await expect(solarSettings.getByRole("button", { name: "Palette holographique : Solaire" })).toBeVisible();
|
||
await expect(dragonVariations.first()).not.toHaveAttribute("data-modified");
|
||
// Retour à la finition d'origine : la suite du parcours retrouve l'état de départ.
|
||
await solarSettings.getByLabel("Palette holographique").click();
|
||
await solarSettings.getByRole("button", { name: "Aurore", exact: true }).click();
|
||
await solarSettings.getByRole("button", { name: "Enregistrer" }).click();
|
||
await page.getByRole("dialog", { name: "Changer la finition de Prisme spectral — Solaire ?" }).getByRole("button", { name: "Changer la finition" }).click();
|
||
await expect(dragonVariations.locator("strong")).toHaveText(["Aurore", "Cosmique"]);
|
||
// Les paliers d'une variation, de 1 à 5 : l'aperçu suit le curseur, l'enregistrement attend « Enregistrer ».
|
||
const tunedSettings = mythicEditorPanel.getByRole("region", { name: "Réglages de Prisme spectral — Aurore" });
|
||
const tunedCard = dragonVariations.first().locator('.nebula-card[data-card-size="sm"]');
|
||
const tunedEdition = async () => (await page.evaluate(() => globalThis.fetch("/api/cards/config").then((response) => response.json()))).catalog.editions.find((edition) => edition.id === "starvoid-dragon-spectral-prism-aurora");
|
||
await tunedSettings.getByRole("slider", { name: "Intensité" }).fill("5");
|
||
await expect(tunedCard).toHaveAttribute("data-holo-intensity", "5");
|
||
// Le panneau montre la variation en grand, au vrai format `lg`, avec les réglages en cours.
|
||
const settingsCard = tunedSettings.locator('.nebula-admin-mythic-settings-preview > .nebula-card');
|
||
await expect(settingsCard).toHaveAttribute("data-card-size", "lg");
|
||
await expect(settingsCard).toHaveAttribute("data-holo-intensity", "5");
|
||
const settingsCardBox = await settingsCard.boundingBox();
|
||
expect([Math.round(settingsCardBox.width), Math.round(settingsCardBox.height)]).toEqual([300, 420]);
|
||
await tunedSettings.getByRole("slider", { name: "Vitesse" }).fill("1");
|
||
await expect(tunedCard).toHaveAttribute("data-holo-level", "1");
|
||
await expect(tunedSettings.locator(".nebula-admin-customizer-summary")).toHaveText("Prisme spectral · Aurore · Standard · Intensité très intense · Vitesse très lente · Particules : aucune");
|
||
expect((await tunedEdition()).holoIntensity).toBeUndefined();
|
||
// Passer à une autre variation garde le réglage en cours, signalé sur sa tuile.
|
||
await dragonVariations.nth(1).getByRole("button", { name: "Régler Prisme spectral — Cosmique" }).click();
|
||
await expect(tunedCard).toHaveAttribute("data-holo-intensity", "5");
|
||
await expect(dragonVariations.first()).toContainText("Non enregistrée");
|
||
await dragonVariations.first().getByRole("button", { name: "Régler Prisme spectral — Aurore" }).click();
|
||
await tunedSettings.getByRole("button", { name: "Enregistrer" }).click();
|
||
await expect.poll(async () => { const edition = await tunedEdition(); return [edition.holoIntensity, edition.holoLevel]; }).toEqual([5, 1]);
|
||
await expect(dragonVariations.first()).not.toHaveAttribute("data-modified");
|
||
// Retour aux paliers centraux : la variation retrouve son rendu de référence, sans attribut.
|
||
await tunedSettings.getByRole("slider", { name: "Intensité" }).fill("3");
|
||
await tunedSettings.getByRole("slider", { name: "Vitesse" }).fill("3");
|
||
await tunedSettings.getByRole("button", { name: "Enregistrer" }).click();
|
||
await expect.poll(async () => { const edition = await tunedEdition(); return [edition.holoIntensity, edition.holoLevel]; }).toEqual([undefined, undefined]);
|
||
await expect(tunedCard).not.toHaveAttribute("data-holo-level");
|
||
await expect(tunedCard).not.toHaveAttribute("data-holo-intensity");
|
||
// Les particules s'enregistrent avec le même bouton : la carte les affiche avant, la configuration publiée après.
|
||
await tunedSettings.getByRole("tab", { name: "Particules" }).click();
|
||
await chooseOption(tunedSettings, "Animation", "Lucioles");
|
||
await expect(tunedSettings.getByRole("slider", { name: "Nombre" })).toBeVisible();
|
||
await expect(tunedCard).toHaveAttribute("data-flare", "fireflies");
|
||
await expect(dragonVariations.first()).toContainText("Non enregistrée");
|
||
await tunedSettings.getByRole("button", { name: "Enregistrer" }).click();
|
||
await expect.poll(async () => (await tunedEdition()).flareId).toBe("fireflies");
|
||
await expect(dragonVariations.first()).not.toHaveAttribute("data-modified");
|
||
await expect(tunedSettings.locator('.nebula-admin-mythic-settings-preview .nebula-card-flare[data-flare="fireflies"]')).toHaveCount(1);
|
||
// Retirer les particules : « Aucune », puis Enregistrer.
|
||
await chooseOption(tunedSettings, "Animation", "Aucune");
|
||
await tunedSettings.getByRole("button", { name: "Enregistrer" }).click();
|
||
await expect.poll(async () => (await tunedEdition()).flareId).toBeUndefined();
|
||
await expect(tunedCard).not.toHaveAttribute("data-flare");
|
||
await tunedSettings.getByRole("tab", { name: "Holo" }).click();
|
||
await mythicEditorPanel.getByRole("button", { name: "Fermer" }).click();
|
||
await expect(mythicEditorPanel).toHaveCount(0);
|
||
await expect(dragonTileButton).toHaveAttribute("aria-pressed", "false");
|
||
await noOverflow();
|
||
|
||
await page.getByRole("navigation", { name: "Fil d’Ariane" }).getByRole("link", { name: "Collections" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/collections$/);
|
||
await genesisTile.click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/collections\/astral-genesis$/);
|
||
const genesisOpening = page.getByRole("region", { name: "Ouverture mythique de la collection" });
|
||
await expectOptions(page, genesisOpening, "Forme de particules", ["Étincelles (défaut)", "Flocons de neige"]);
|
||
await expectOptions(page, genesisOpening, "Palette de particules", ["Violet épique", "Or légendaire", "Arc-en-ciel (défaut)", "Comme la palette holo"]);
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
// En grand, taux de tirage et ouverture mythique côte à côte (50:50), de même hauteur, sans défilement du tableau.
|
||
const openingBox = await genesisOpening.boundingBox();
|
||
const ratesBox = await page.getByRole("region", { name: "Taux de tirage" }).boundingBox();
|
||
expect(Math.abs(openingBox.width - ratesBox.width)).toBeLessThanOrEqual(1);
|
||
expect(Math.abs(openingBox.height - ratesBox.height)).toBeLessThanOrEqual(1);
|
||
expect(await page.locator(".nebula-admin-drop-scroll").evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
|
||
expect(openingBox.x).toBeGreaterThan(ratesBox.x + ratesBox.width);
|
||
expect(Math.abs(openingBox.y - ratesBox.y)).toBeLessThanOrEqual(1);
|
||
await page.setViewportSize({ width: 900, height: 900 });
|
||
const [stackedOpening, stackedRates] = await Promise.all([genesisOpening.boundingBox(), page.getByRole("region", { name: "Taux de tirage" }).boundingBox()]);
|
||
expect(stackedOpening.y).toBeGreaterThan(stackedRates.y + stackedRates.height);
|
||
expect(Math.abs(stackedOpening.width - stackedRates.width)).toBeLessThanOrEqual(1);
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
await chooseOption(genesisOpening, "Forme de particules", "Flocons de neige");
|
||
await expect(selectTrigger(genesisOpening, "Forme de particules")).toHaveText("Flocons de neige");
|
||
await expect(genesisOpening).toHaveCSS("overflow", "visible");
|
||
// Les deux menus côte à côte, à la même hauteur.
|
||
const [shapeBox, paletteBox] = await Promise.all([selectTrigger(genesisOpening, "Forme de particules").boundingBox(), selectTrigger(genesisOpening, "Palette de particules").boundingBox()]);
|
||
expect(Math.abs(shapeBox.y - paletteBox.y)).toBeLessThanOrEqual(1);
|
||
expect(shapeBox.x + shapeBox.width).toBeLessThan(paletteBox.x);
|
||
await genesisOpening.getByRole("button", { name: "Révéler la carte mythique de la collection" }).click();
|
||
await expect(genesisOpening.locator(".nebula-card-reveal")).toHaveAttribute("data-particle-shape", "snowflakes");
|
||
await expect(genesisOpening.locator(".nebula-card-particles i").first()).toBeAttached();
|
||
await noOverflow();
|
||
|
||
const mythicPullEditions = page.locator(".nebula-admin-catalog-card").filter({ hasText: "La Pioche Mythique" });
|
||
await expect(mythicPullEditions).toHaveCount(2);
|
||
const pullItem = page.locator("#nebula-admin-mythic-mythic-card-pull");
|
||
await pullItem.getByRole("button", { name: "Configurer la version mythique de La Pioche Mythique" }).click();
|
||
const editor = page.locator("#nebula-admin-mythic-editor-panel .nebula-admin-mythic-editor");
|
||
const variations = editor.locator(".nebula-admin-mythic-variation");
|
||
await expect(variations).toHaveCount(1);
|
||
await expect(variations.first().locator("strong")).toHaveText("Solaire");
|
||
await expect(variations.first().locator("small")).toHaveText("Prisme spectral");
|
||
await expect(editor.locator(".nebula-admin-customizer-summary")).toHaveText("Prisme spectral · Solaire · Standard · Intensité normale · Vitesse normale · Particules : aucune");
|
||
// La variation sélectionnée s'ouvre dans le panneau de réglages : rien à enregistrer tant qu'aucun réglage ne change.
|
||
await expect(editor.getByRole("button", { name: "Enregistrer" })).toBeDisabled();
|
||
const cardOpening = editor.getByRole("group", { name: "Ouverture mythique de la carte" });
|
||
await expectOptions(page, cardOpening, "Forme de particules", ["Étincelles", "Flocons de neige (hérité de la collection)"]);
|
||
await expect(selectTrigger(cardOpening, "Forme de particules")).toHaveText("Flocons de neige (hérité de la collection)");
|
||
await selectTrigger(cardOpening, "Palette de particules").click();
|
||
await expect(cardOpening.getByRole("option", { name: /Arc-en-ciel/ })).toHaveText(["Arc-en-ciel (défaut)"]);
|
||
await page.keyboard.press("Escape");
|
||
await editor.getByRole("button", { name: "Ajouter une variation" }).click();
|
||
await expect(variations).toHaveCount(2);
|
||
const draftSettings = editor.getByRole("region", { name: "Réglages de la nouvelle variation" });
|
||
await expect(draftSettings.getByRole("button", { name: "Palette holographique : Arc-en-ciel" })).toBeVisible();
|
||
await expect(variations.nth(1)).toHaveAttribute("data-selected", "true");
|
||
await expect(editor.getByRole("button", { name: "Ajouter une variation" })).toHaveCount(0);
|
||
const createVariation = draftSettings.getByRole("button", { name: "Créer la variation" });
|
||
await expect(createVariation).toHaveAttribute("data-variant", "primary");
|
||
await draftSettings.getByLabel("Palette holographique").click();
|
||
await draftSettings.getByRole("button", { name: "Solaire", exact: true }).click();
|
||
await expect(draftSettings.getByRole("status")).toHaveText("Cette combinaison existe déjà.");
|
||
await expect(createVariation).toBeDisabled();
|
||
await draftSettings.getByRole("button", { name: "Annuler" }).click();
|
||
await expect(variations).toHaveCount(1);
|
||
await editor.getByRole("button", { name: "Ajouter une variation" }).click();
|
||
await expect(variations).toHaveCount(2);
|
||
// Les miniatures des variations se suivent sur une ligne ; le panneau de réglages prend toute la largeur en dessous et
|
||
// place la carte `lg` à gauche de la personnalisation quand il a la place, au-dessus sinon.
|
||
const stripThenPanel = async () => {
|
||
const [first, second, settings, block] = await Promise.all([variations.first().boundingBox(), variations.nth(1).boundingBox(), draftSettings.boundingBox(), editor.locator(".nebula-admin-mythic-variations-block").boundingBox()]);
|
||
return Math.abs(first.y - second.y) <= 1 && second.x > first.x + first.width - 1 && settings.y > first.y + first.height && Math.abs(settings.width - block.width) <= 1;
|
||
};
|
||
const cardBesideCustomizer = async () => {
|
||
const [preview, customizer] = await Promise.all([draftSettings.locator(".nebula-admin-mythic-settings-preview > .nebula-card").boundingBox(), draftSettings.locator(".nebula-admin-customizer").boundingBox()]);
|
||
return customizer.x >= preview.x + preview.width - 1;
|
||
};
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
expect(await stripThenPanel()).toBe(true);
|
||
expect(await cardBesideCustomizer()).toBe(true);
|
||
await page.setViewportSize({ width: 768, height: 720 });
|
||
expect(await stripThenPanel()).toBe(true);
|
||
expect(await cardBesideCustomizer()).toBe(false);
|
||
// En demi-écran comme en grand, le menu de palette se recale au lieu d'être coupé.
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
await draftSettings.scrollIntoViewIfNeeded();
|
||
await draftSettings.getByRole("button", { name: "Palette holographique : Arc-en-ciel" }).click();
|
||
await expectOpenMenuVisible(page, ".nebula-admin-palette-menu.is-open");
|
||
await page.keyboard.press("Escape");
|
||
await page.evaluate(() => globalThis.scrollTo(0, globalThis.document.documentElement.scrollHeight));
|
||
await draftSettings.getByRole("button", { name: "Palette holographique : Arc-en-ciel" }).click();
|
||
await expectOpenMenuVisible(page, ".nebula-admin-palette-menu.is-open");
|
||
await page.keyboard.press("Escape");
|
||
await page.setViewportSize({ width: 768, height: 720 });
|
||
await draftSettings.getByRole("button", { name: "Palette holographique : Arc-en-ciel" }).click();
|
||
const lastPaletteOption = draftSettings.getByRole("button", { name: "Ténèbres", exact: true });
|
||
await expect(lastPaletteOption).toBeVisible();
|
||
await lastPaletteOption.scrollIntoViewIfNeeded();
|
||
// L'événement de défilement part à la frame suivante : le menu doit rester défilé après son traitement.
|
||
// Le menu se recale après le défilement : on attend sa position stable, et un vrai recouvrement échoue à l'expiration.
|
||
await expect.poll(() => lastPaletteOption.evaluate((element) => {
|
||
const box = element.getBoundingClientRect();
|
||
return element.contains(element.ownerDocument.elementFromPoint(box.left + box.width / 2, box.bottom - 4));
|
||
})).toBe(true);
|
||
await page.keyboard.press("Escape");
|
||
await chooseOption(cardOpening, "Palette de particules", "Comme la palette holo");
|
||
await expect(selectTrigger(cardOpening, "Palette de particules")).toHaveText("Comme la palette holo");
|
||
await expect(variations).toHaveCount(2);
|
||
await editor.getByRole("button", { name: "Révéler la variation mythique" }).click();
|
||
const editorSurface = editor.locator(".nebula-card-reveal");
|
||
await expect(editorSurface).toHaveAttribute("data-particle-shape", "snowflakes");
|
||
await expect(editorSurface).toHaveAttribute("data-particle-palette", "match-holo");
|
||
await expect(editorSurface).toHaveCSS("--opening-aura", "#ff0000");
|
||
// Les paliers se règlent dès la création : ils s'enregistrent avec la nouvelle variation.
|
||
const draftVariation = editor.locator(".nebula-admin-mythic-variation[data-new]");
|
||
await draftSettings.getByRole("slider", { name: "Intensité" }).fill("4");
|
||
await expect(draftVariation.locator('.nebula-card[data-card-size="sm"]')).toHaveAttribute("data-holo-intensity", "4");
|
||
await createVariation.click();
|
||
await expect(editor.locator(".nebula-admin-mythic-variation[data-new]")).toHaveCount(0);
|
||
await expect(editor.locator(".nebula-admin-mythic-variation")).toHaveCount(2);
|
||
await expect(editor.locator(".nebula-admin-mythic-variation strong")).toHaveText(["Arc-en-ciel", "Solaire"]);
|
||
await expect(editor.getByRole("button", { name: "Ajouter une variation" })).toBeVisible();
|
||
await expect(selectTrigger(editor.getByRole("group", { name: "Ouverture mythique de la carte" }), "Palette de particules")).toHaveText("Comme la palette holo");
|
||
await expect(mythicPullEditions).toHaveCount(3);
|
||
await noOverflow();
|
||
|
||
const config = await page.evaluate(() => globalThis.fetch("/api/cards/config").then((response) => response.json()));
|
||
expect(config.catalog.editions.find((edition) => edition.id === "mythic-card-pull-spectral-prism-rainbow")?.holoIntensity).toBe(4);
|
||
expect(config.catalog.mythicOpeningSettings).toEqual(expect.arrayContaining([
|
||
{ scope: "card", targetId: "mythic-card-pull", particleShapeId: null, particlePaletteId: "match-holo" },
|
||
{ scope: "collection", targetId: "astral-genesis", particleShapeId: "snowflakes", particlePaletteId: null }
|
||
]));
|
||
await editor.getByRole("button", { name: "Supprimer la variation Prisme spectral — Arc-en-ciel" }).click();
|
||
const removalDialog = page.getByRole("dialog", { name: "Supprimer Prisme spectral — Arc-en-ciel ?" });
|
||
await removalDialog.getByRole("button", { name: "Annuler" }).click();
|
||
await expect(editor.locator(".nebula-admin-mythic-variation")).toHaveCount(2);
|
||
await editor.getByRole("button", { name: "Supprimer la variation Prisme spectral — Arc-en-ciel" }).click();
|
||
await removalDialog.getByRole("button", { name: "Supprimer" }).click();
|
||
await expect(editor.locator(".nebula-admin-mythic-variation")).toHaveCount(1);
|
||
await chooseOption(editor.getByRole("group", { name: "Ouverture mythique de la carte" }), "Palette de particules", INHERITED);
|
||
await expect(selectTrigger(editor.getByRole("group", { name: "Ouverture mythique de la carte" }), "Palette de particules")).toHaveText(INHERITED);
|
||
await chooseOption(genesisOpening, "Forme de particules", INHERITED);
|
||
await expect(selectTrigger(genesisOpening, "Forme de particules")).toHaveText(INHERITED);
|
||
await expect(mythicPullEditions).toHaveCount(2);
|
||
|
||
await page.goto("/#/cards/admin/catalog/inconnue");
|
||
await expect(page.getByText("Cette collection n’existe pas.", { exact: true })).toBeVisible();
|
||
|
||
await expandSections(page, "Sections de l’administration");
|
||
await navigation.getByRole("link", { name: "Atelier visuel" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/visual-lab$/);
|
||
const openingEffects = page.locator(".nebula-admin-opening-effect-card");
|
||
await expect(openingEffects).toHaveCount(4);
|
||
await expect(openingEffects.locator(".eyebrow")).toHaveText(["Effet de rareté", "Effet de rareté", "Effet de rareté", "Effet de rareté"]);
|
||
await expect(openingEffects.locator("h4")).toHaveText(["Mythique", "Rare", "Épique", "Légendaire"]);
|
||
await expect(openingEffects.first().locator(".nebula-admin-style-preview > span")).toHaveText(/^Aperçu · .+ — Prisme spectral — /);
|
||
const holoSectionBox = await page.getByRole("heading", { name: /Effets holographiques mythiques/ }).boundingBox();
|
||
const openingSectionBox = await page.getByRole("heading", { name: /Effets d’ouverture/ }).boundingBox();
|
||
expect(holoSectionBox.y).toBeLessThan(openingSectionBox.y);
|
||
const openingColumns = () => page.locator('[data-opening-group="rarities"]').evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element).gridTemplateColumns.trim().split(/\s+/).length);
|
||
expect(await openingColumns()).toBe(2);
|
||
await noOverflow();
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
expect(await openingColumns()).toBe(3);
|
||
const mythicOpeningCard = openingEffects.filter({ has: page.getByRole("heading", { name: "Mythique", exact: true }) });
|
||
const legendaryOpeningCard = openingEffects.filter({ has: page.getByRole("heading", { name: "Légendaire", exact: true }) });
|
||
const [mythicBox, legendaryBox, gridBox] = await Promise.all([mythicOpeningCard.boundingBox(), legendaryOpeningCard.boundingBox(), page.locator('[data-opening-group="rarities"]').boundingBox()]);
|
||
expect(mythicBox.y + mythicBox.height).toBeLessThan(legendaryBox.y + 1);
|
||
expect(Math.round(mythicBox.width)).toBe(760);
|
||
expect(Math.abs((mythicBox.x - gridBox.x) - (gridBox.x + gridBox.width - mythicBox.x - mythicBox.width))).toBeLessThanOrEqual(1);
|
||
|
||
// Un seul banc d'essai : une miniature par effet pour le choisir, puis l'aperçu `lg` et le panneau à onglets Holo / Particules.
|
||
const bench = page.locator(".nebula-admin-lab-bench");
|
||
const labCard = bench.locator(".nebula-admin-style-preview > .nebula-card");
|
||
const tryEffect = (label) => bench.getByRole("button", { name: `Essayer ${label}` }).click();
|
||
await expect(bench.locator(".nebula-admin-lab-effect > span")).toHaveText(["Prisme spectral", "Reflet diffractif", "Parallaxe prismatique", "Glace brisée"]);
|
||
await expect(bench.locator('.nebula-admin-lab-effect .nebula-card[data-card-size="sm"]')).toHaveCount(4);
|
||
await expect(bench.getByRole("button", { name: "Essayer Prisme spectral" })).toHaveAttribute("aria-pressed", "true");
|
||
await expect(bench.getByRole("tab")).toHaveText(["Holo", "Particules"]);
|
||
await tryEffect("Glace brisée");
|
||
await expect(bench.getByRole("heading", { name: "Glace brisée", exact: true })).toBeVisible();
|
||
await expect(bench.getByRole("button", { name: "Essayer Glace brisée" })).toHaveAttribute("aria-pressed", "true");
|
||
const iceCard = bench.locator('.nebula-admin-style-preview > .nebula-card[data-holo-effect="shattered-ice"]');
|
||
await expect(iceCard.locator(".nebula-card-holo-shards > i")).toHaveCount(4);
|
||
await expect(iceCard.locator('.nebula-card-holo-shards > [data-facet="0"]')).toHaveCSS("mask-image", /shattered-ice-facet-0\.webp/);
|
||
// En format standard, la glace passe sous l'illustration, qui reste intacte.
|
||
expect(await iceCard.evaluate((element) => { const view = element.ownerDocument.defaultView; return Number(view.getComputedStyle(element.querySelector(".nebula-card-art")).zIndex) > Number(view.getComputedStyle(element.querySelector(".nebula-card-holo-shards")).zIndex); })).toBe(true);
|
||
await expect(bench.getByRole("slider", { name: "Taille des éclats" })).toBeVisible();
|
||
// La Parallaxe prismatique pose le héros détouré de la carte sur son décor sans lui, puis les décale selon leur profondeur.
|
||
await tryEffect("Parallaxe prismatique");
|
||
const parallaxCard = bench.locator('.nebula-admin-style-preview > .nebula-card[data-holo-effect="prismatic-backdrop"]');
|
||
await expect(parallaxCard.locator(".nebula-card-art")).toHaveAttribute("data-parallax-setup", "clean");
|
||
await expect(parallaxCard.locator(".nebula-card-depth-layer")).toHaveCount(2);
|
||
await expect(parallaxCard.locator('[data-depth-layer="backdrop"] img[src$="/mythic_card_pull__backdrop.webp"]')).toBeVisible();
|
||
await expect(parallaxCard.locator('[data-depth-layer="subject"] img[src$="/mythic_card_pull__cutout.webp"]')).toBeVisible();
|
||
await expect(parallaxCard.locator('[data-depth-layer="backdrop"] .nebula-card-depth-tint')).toHaveCSS("mix-blend-mode", "overlay");
|
||
await parallaxCard.scrollIntoViewIfNeeded();
|
||
const parallaxBounds = await parallaxCard.boundingBox();
|
||
await page.mouse.move(parallaxBounds.x + parallaxBounds.width * 0.9, parallaxBounds.y + parallaxBounds.height * 0.2);
|
||
await expect.poll(() => parallaxCard.evaluate((element) => Number.parseFloat(element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("--card-tilt-nx")))).toBeGreaterThan(0.3);
|
||
// Le décor (profondeur 1) part à l'opposé du pointeur ; le héros (profondeur négative) le suit.
|
||
const layerShiftX = (layer) => parallaxCard.locator(`[data-depth-layer="${layer}"]`).evaluate((element) => { const view = element.ownerDocument.defaultView; return new view.DOMMatrixReadOnly(view.getComputedStyle(element).transform).m41; });
|
||
await expect.poll(() => layerShiftX("backdrop")).toBeLessThan(-3);
|
||
expect(await layerShiftX("subject")).toBeGreaterThan(0);
|
||
await page.mouse.move(0, 0);
|
||
await chooseOption(bench, "Format", "Pleine illustration");
|
||
await expect(parallaxCard.locator('[data-depth-layer="backdrop"] img[src$="/mythic_card_pull__full__backdrop.webp"]')).toBeVisible();
|
||
await expect(parallaxCard.locator('[data-depth-layer="subject"] img[src$="/mythic_card_pull__full__cutout.webp"]')).toBeVisible();
|
||
await chooseOption(bench, "Format", "Standard");
|
||
// Les paliers, de 1 à 5, s'essaient sur l'aperçu : intensité de la palette pour tous les effets, amplitude pour la parallaxe.
|
||
const labIntensity = bench.getByRole("slider", { name: "Intensité" });
|
||
await expect(labIntensity).toHaveValue("3");
|
||
await expect(parallaxCard).not.toHaveAttribute("data-holo-intensity");
|
||
await labIntensity.fill("5");
|
||
await expect(parallaxCard).toHaveAttribute("data-holo-intensity", "5");
|
||
await expect(bench.locator(".nebula-admin-tuning-range").first()).toContainText("Très intense");
|
||
await bench.getByRole("slider", { name: "Amplitude" }).fill("1");
|
||
await expect(parallaxCard).toHaveAttribute("data-holo-level", "1");
|
||
// Les miniatures suivent les mêmes réglages pour comparer les effets à réglages égaux ; le résumé les reprend.
|
||
await expect(bench.locator('.nebula-admin-lab-effect .nebula-card[data-holo-effect="spectral-prism"]')).toHaveAttribute("data-holo-intensity", "5");
|
||
await expect(bench.locator(".nebula-admin-customizer-summary")).toHaveText("Parallaxe prismatique · Arc-en-ciel · Standard · Intensité très intense · Amplitude très douce · Particules : aucune");
|
||
await labIntensity.fill("3");
|
||
await bench.getByRole("slider", { name: "Amplitude" }).fill("3");
|
||
await expect(parallaxCard).not.toHaveAttribute("data-holo-level");
|
||
// Le Reflet diffractif n'a que l'intensité.
|
||
await tryEffect("Reflet diffractif");
|
||
await expect(bench.getByRole("slider")).toHaveCount(1);
|
||
await tryEffect("Prisme spectral");
|
||
// Les aperçus holographiques gardent le vrai format `lg`, 300 x 420 px.
|
||
const holoPreviewBox = await labCard.boundingBox();
|
||
expect([Math.round(holoPreviewBox.width), Math.round(holoPreviewBox.height)]).toEqual([300, 420]);
|
||
// Pleine illustration : l'image remplit la carte, la description disparaît et le nom reste, avec son effet métallique.
|
||
await chooseOption(bench, "Format", "Pleine illustration");
|
||
const fullArtCard = bench.locator('.nebula-admin-style-preview > .nebula-card[data-card-layout="full-art"][data-holo-effect="spectral-prism"]');
|
||
await expect(fullArtCard.locator('.nebula-card-art img[src$="/astral-genesis/legendary/mythic_card_pull__full.webp"]')).toBeVisible();
|
||
await expect(fullArtCard.locator(".nebula-card-copy")).toHaveCount(0);
|
||
await expect(fullArtCard.locator("h3")).toBeVisible();
|
||
await expect(fullArtCard.locator("h3 > span")).toHaveCSS("color", "rgba(0, 0, 0, 0)");
|
||
// Une ombre de texte se peindrait par-dessus le dégradé et ternirait le nom.
|
||
await expect(fullArtCard.locator("h3 > span")).toHaveCSS("text-shadow", "none");
|
||
const fullArtBounds = await fullArtCard.evaluate((element) => {
|
||
const face = element.querySelector(".nebula-card-face").getBoundingClientRect();
|
||
const art = element.querySelector(".nebula-card-art").getBoundingClientRect();
|
||
return { widthGap: face.width - art.width, heightGap: face.height - art.height };
|
||
});
|
||
expect(fullArtBounds.widthGap).toBeLessThanOrEqual(5);
|
||
expect(fullArtBounds.heightGap).toBeLessThanOrEqual(5);
|
||
await chooseOption(bench, "Format", "Standard");
|
||
await expect(labCard.locator('.nebula-card-art img[src$="/astral-genesis/legendary/mythic_card_pull.webp"]')).toHaveCount(1);
|
||
await expect(bench.getByRole("heading", { name: "Prisme spectral", exact: true })).toBeVisible();
|
||
// L'onglet Particules essaie les éclairs : un canvas dans l'illustration, avec palette, intensité et fréquence.
|
||
await bench.getByRole("tab", { name: "Particules" }).click();
|
||
await expect(bench.getByRole("tab", { name: "Particules" })).toHaveAttribute("aria-selected", "true");
|
||
await expect(selectTrigger(bench, "Animation")).toHaveText("Aucune");
|
||
await expect(labCard.locator(".nebula-card-flare")).toHaveCount(0);
|
||
await chooseOption(bench, "Animation", "Éclairs");
|
||
await expect(labCard).toHaveAttribute("data-flare", "lightning");
|
||
const lightningCanvas = labCard.locator(".nebula-card-art > .nebula-card-flare");
|
||
await expect(lightningCanvas).toHaveCount(1);
|
||
expect(await lightningCanvas.evaluate((canvas) => canvas.width > 0 && canvas.height > 0)).toBe(true);
|
||
// L'animation dessine : des pixels apparaissent dans le canvas d'une carte affichée en grand.
|
||
await expect.poll(() => lightningCanvas.evaluate((canvas) => canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height).data.some((value, index) => index % 4 === 3 && value > 0)), { timeout: 5000 }).toBe(true);
|
||
await expect(bench.getByRole("button", { name: "Palette des particules : Comme le holo" })).toBeVisible();
|
||
await expect(bench.getByRole("slider", { name: "Fréquence" })).toHaveValue("3");
|
||
await expect(bench.locator(".nebula-admin-customizer-summary")).toContainText("Particules : éclairs");
|
||
// Sur toute la carte, le canvas couvre la face, sous la description et le nom ; retour à l'illustration ensuite.
|
||
await chooseOption(bench, "Zone", "Toute la carte");
|
||
await expect(labCard.locator(".nebula-card-face > .nebula-card-flare")).toHaveAttribute("data-flare-scope", "card");
|
||
await expect(labCard.locator(".nebula-card-art .nebula-card-flare")).toHaveCount(0);
|
||
await chooseOption(bench, "Zone", "Illustration");
|
||
await expect(labCard.locator(".nebula-card-art > .nebula-card-flare")).toHaveCount(1);
|
||
// Avec la parallaxe, les éclairs passent entre le décor et le héros détouré.
|
||
await tryEffect("Parallaxe prismatique");
|
||
await expect(labCard.locator('.nebula-card-flare-plane + [data-depth-layer="subject"]')).toHaveCount(1);
|
||
await expect(labCard.locator(".nebula-card-flare")).toHaveAttribute("data-behind-subject", "true");
|
||
await tryEffect("Prisme spectral");
|
||
// Les scintillements : motifs qui apparaissent et disparaissent, devant l'illustration ; motif, nombre, vitesse, intensité.
|
||
await chooseOption(bench, "Animation", "Scintillements");
|
||
await expect(labCard.locator(".nebula-card-art > .nebula-card-flare")).toHaveAttribute("data-flare", "twinkle");
|
||
await expect(selectTrigger(bench, "Motif")).toHaveText("Étoile à quatre branches");
|
||
await expect(bench.getByRole("slider")).toHaveCount(3);
|
||
await expect(bench.getByRole("slider", { name: "Nombre" })).toHaveAttribute("aria-valuetext", "≈ 4");
|
||
await expect(bench.getByRole("slider", { name: "Vitesse" })).toBeVisible();
|
||
await chooseOption(bench, "Motif", "Cœur");
|
||
const twinkleCanvas = labCard.locator(".nebula-card-art > .nebula-card-flare");
|
||
await expect.poll(() => twinkleCanvas.evaluate((canvas) => canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height).data.some((value, index) => index % 4 === 3 && value > 0)), { timeout: 5000 }).toBe(true);
|
||
// Les lucioles : lueurs qui flottent et pulsent, avec leurs propres motifs et paliers.
|
||
await chooseOption(bench, "Animation", "Lucioles");
|
||
await expect(labCard.locator(".nebula-card-art > .nebula-card-flare")).toHaveAttribute("data-flare", "fireflies");
|
||
// Le motif choisi pour les scintillements (Cœur) existe aussi chez les lucioles : il est gardé.
|
||
await expect(selectTrigger(bench, "Motif")).toHaveText("Cœur");
|
||
await expect(bench.getByRole("slider", { name: "Nombre" })).toHaveAttribute("aria-valuetext", "≈ 8");
|
||
await expect.poll(() => labCard.locator(".nebula-card-art > .nebula-card-flare").evaluate((canvas) => canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height).data.some((value, index) => index % 4 === 3 && value > 0)), { timeout: 5000 }).toBe(true);
|
||
await expect(bench.locator(".nebula-admin-customizer-summary")).toContainText("Particules : lucioles");
|
||
await chooseOption(bench, "Animation", "Scintillements");
|
||
// Même avec la parallaxe, les scintillements restent devant le héros.
|
||
await tryEffect("Parallaxe prismatique");
|
||
await expect(labCard.locator(".nebula-card-flare-plane")).toHaveCount(0);
|
||
await expect(labCard.locator(".nebula-card-art > .nebula-card-flare")).toHaveCount(1);
|
||
await tryEffect("Prisme spectral");
|
||
await chooseOption(bench, "Animation", "Aucune");
|
||
await expect(labCard).not.toHaveAttribute("data-flare");
|
||
await expect(labCard.locator(".nebula-card-flare")).toHaveCount(0);
|
||
await bench.getByRole("tab", { name: "Holo" }).click();
|
||
const paletteTrigger = bench.getByRole("button", { name: "Palette holographique : Arc-en-ciel" });
|
||
const paletteTriggerLabel = paletteTrigger.getByText("Arc-en-ciel", { exact: true });
|
||
await expect(paletteTriggerLabel).toBeVisible();
|
||
expect(await paletteTriggerLabel.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
|
||
await expect(paletteTrigger.locator('.nebula-admin-palette[data-compact="true"] i').first()).toHaveCSS("width", "10px");
|
||
await paletteTrigger.click();
|
||
await expect(bench).toHaveCSS("overflow", "visible");
|
||
const solarPaletteOption = bench.getByRole("button", { name: "Solaire", exact: true });
|
||
await expect(solarPaletteOption.locator('.nebula-admin-palette[data-compact="true"] i')).toHaveCount(7);
|
||
await solarPaletteOption.click();
|
||
await expect(bench.getByRole("button", { name: "Palette holographique : Solaire" })).toBeVisible();
|
||
await expect(labCard).toHaveAttribute("data-holo-palette", "solar");
|
||
|
||
// Reflet diffractif : la palette choisie reste quand on change d'effet ; tout découle du tilt, sans animation automatique.
|
||
await tryEffect("Reflet diffractif");
|
||
const diffractionCard = labCard;
|
||
const diffractionLayer = diffractionCard.locator(".nebula-card-holo-primary");
|
||
await chooseOption(bench, "Format", "Pleine illustration");
|
||
await expect(diffractionCard).toHaveAttribute("data-card-layout", "full-art");
|
||
await chooseOption(bench, "Format", "Standard");
|
||
await expect(diffractionCard).toHaveAttribute("data-holo-palette", "solar");
|
||
await diffractionCard.scrollIntoViewIfNeeded();
|
||
await expect(diffractionLayer).toHaveCSS("opacity", "0.05");
|
||
const diffractionBox = await diffractionCard.boundingBox();
|
||
const tiltTo = async (ratioX, ratioY) => {
|
||
await page.mouse.move(diffractionBox.x + diffractionBox.width * ratioX, diffractionBox.y + diffractionBox.height * ratioY);
|
||
await expect.poll(() => diffractionCard.evaluate((element, expected) => Math.abs(Number.parseFloat(element.style.getPropertyValue("--card-pointer-x")) - expected), ratioX * 100)).toBeLessThan(1);
|
||
return diffractionLayer.evaluate((element) => {
|
||
const style = element.ownerDocument.defaultView.getComputedStyle(element);
|
||
return { opacity: Number(style.opacity), position: style.backgroundPosition, animation: style.animationName };
|
||
});
|
||
};
|
||
const flat = await tiltTo(0.5, 0.5);
|
||
const tilted = await tiltTo(0.95, 0.9);
|
||
expect(flat.animation).toBe("none");
|
||
expect(tilted.animation).toBe("none");
|
||
expect(tilted.opacity).toBeGreaterThan(flat.opacity + 0.2);
|
||
expect(tilted.position).not.toBe(flat.position);
|
||
await page.mouse.move(0, 0);
|
||
await expect.poll(() => diffractionLayer.evaluate((element) => Number(element.ownerDocument.defaultView.getComputedStyle(element).opacity))).toBeLessThan(0.07);
|
||
|
||
const rarePreview = openingEffects.filter({ has: page.locator('[data-opening-effect="rare-opening"]') });
|
||
const rareCard = rarePreview.getByRole("button", { name: "Révéler la carte Rare", exact: true });
|
||
const rareSurface = rarePreview.locator(".nebula-card-reveal");
|
||
await rareCard.focus();
|
||
await holdRevealTimers(page);
|
||
await rareCard.press("Enter");
|
||
await expect(rareSurface).toHaveAttribute("data-reveal-phase", "aura");
|
||
await expect(rareSurface).not.toHaveAttribute("disabled", "");
|
||
await expect(rareSurface).toHaveCSS("opacity", "1");
|
||
await expect(rareSurface).toHaveCSS("--card-rarity", "#3b82f6");
|
||
await expect(rareSurface).toHaveCSS("--opening-aura", "#3b82f6");
|
||
expect(await rareSurface.evaluate((element) => element.ownerDocument.defaultView.getComputedStyle(element, "::after").animationName)).toBe("nebula-opening-aura");
|
||
await expect(rareSurface.locator(".nebula-card-particles i")).toHaveCount(0);
|
||
await page.clock.resume();
|
||
await expect(rarePreview.getByRole("button", { name: "Remettre la carte Rare face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
await rarePreview.getByRole("button", { name: "Remettre la carte Rare face cachée", exact: true }).click();
|
||
await expect(rarePreview.getByRole("button", { name: "Révéler la carte Rare", exact: true })).toHaveAttribute("data-reveal-phase", "concealed");
|
||
|
||
const epicPreview = openingEffects.filter({ has: page.locator('[data-opening-effect="epic-opening"]') });
|
||
const epicCard = epicPreview.getByRole("button", { name: "Révéler la carte Épique", exact: true });
|
||
const epicSurface = epicPreview.locator(".nebula-card-reveal");
|
||
await holdRevealTimers(page);
|
||
await epicCard.click();
|
||
await expect(epicSurface).toHaveAttribute("data-reveal-phase", "aura");
|
||
await expect(epicSurface).toHaveCSS("--card-rarity", "#d946ef");
|
||
await expect(epicSurface).toHaveCSS("--opening-aura", "#d946ef");
|
||
await page.clock.runFor(350);
|
||
await expect(epicSurface.locator(".nebula-card-particles i")).toHaveCount(18);
|
||
await expect(epicSurface.locator(".nebula-card-particles i").first()).toHaveCSS("animation-name", "nebula-particle");
|
||
await page.clock.resume();
|
||
await expect(epicPreview.getByRole("button", { name: "Remettre la carte Épique face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
|
||
const legendaryPreview = openingEffects.filter({ has: page.locator('[data-opening-effect="legendary-opening"]') });
|
||
const legendaryCard = legendaryPreview.getByRole("button", { name: "Révéler la carte Légendaire", exact: true });
|
||
const legendarySurface = legendaryPreview.locator(".nebula-card-reveal");
|
||
await holdRevealTimers(page);
|
||
await legendaryCard.click();
|
||
await expect(legendarySurface).toHaveAttribute("data-reveal-phase", "aura");
|
||
await expect(legendarySurface).toHaveCSS("--opening-aura", "#f6c453");
|
||
await page.clock.runFor(450);
|
||
await expect(legendarySurface.locator(".nebula-card-particles i")).toHaveCount(32);
|
||
await page.clock.resume();
|
||
await expect(legendaryPreview.getByRole("button", { name: "Remettre la carte Légendaire face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
|
||
await legendaryPreview.getByRole("button", { name: "Remettre la carte Légendaire face cachée", exact: true }).click();
|
||
await expect(legendaryPreview.getByRole("button", { name: "Révéler la carte Légendaire", exact: true })).toHaveAttribute("data-reveal-phase", "concealed");
|
||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||
await legendaryPreview.getByRole("button", { name: "Révéler la carte Légendaire", exact: true }).click();
|
||
await expect(legendaryPreview.getByRole("button", { name: "Remettre la carte Légendaire face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
await expect(legendarySurface.locator(".nebula-card-particles")).toHaveCSS("display", "none");
|
||
await page.emulateMedia({ reducedMotion: "no-preference" });
|
||
const legendaryBurstVisual = await legendarySurface.locator(".nebula-card-particles").evaluate((element) => {
|
||
const styles = element.ownerDocument.defaultView;
|
||
const normalizeColors = (value) => value.replace(/(?:rgba?|color)\([^)]*\)/g, "<color>");
|
||
const before = styles.getComputedStyle(element, "::before");
|
||
const after = styles.getComputedStyle(element, "::after");
|
||
const particle = styles.getComputedStyle(element.querySelector("i"));
|
||
return {
|
||
geometry: {
|
||
ring: { width: before.width, height: before.height, border: before.borderWidth, radius: before.borderRadius, shadow: normalizeColors(before.boxShadow), animation: before.animationName, duration: before.animationDuration, easing: before.animationTimingFunction },
|
||
rays: { width: after.width, height: after.height, radius: after.borderRadius, filter: normalizeColors(after.filter), animation: after.animationName, duration: after.animationDuration, easing: after.animationTimingFunction },
|
||
particle: { width: particle.width, height: particle.height, radius: particle.borderRadius, clipPath: particle.clipPath, animation: particle.animationName, duration: particle.animationDuration, easing: particle.animationTimingFunction, x: particle.getPropertyValue("--x"), y: particle.getPropertyValue("--y") },
|
||
particleSizes: [...element.querySelectorAll("i")].map((item) => `${styles.getComputedStyle(item).width}x${styles.getComputedStyle(item).height}`).join(" ")
|
||
},
|
||
paint: { ringBackground: before.backgroundImage, ringMask: before.maskImage || before.webkitMaskImage, rayBackground: after.backgroundImage, rayMask: after.maskImage || after.webkitMaskImage }
|
||
};
|
||
});
|
||
expect(legendaryBurstVisual.geometry.ring.width).toBe("92px");
|
||
expect(legendaryBurstVisual.geometry.ring.height).toBe("92px");
|
||
expect(legendaryBurstVisual.geometry.ring.border).toBe("6px");
|
||
expect(legendaryBurstVisual.paint.ringBackground).toBe("none");
|
||
expect(legendaryBurstVisual.paint.ringMask).toBe("none");
|
||
expect(legendaryBurstVisual.geometry.rays.width).toBe("260px");
|
||
expect(legendaryBurstVisual.geometry.rays.height).toBe("260px");
|
||
expect(legendaryBurstVisual.paint.rayBackground).toContain("repeating-conic-gradient");
|
||
expect(legendaryBurstVisual.paint.rayMask).toContain("radial-gradient");
|
||
expect(legendaryBurstVisual.paint.rayMask).not.toContain("repeating-conic-gradient");
|
||
expect(legendaryBurstVisual.geometry.rays.filter).toContain("drop-shadow");
|
||
expect(legendaryBurstVisual.geometry.rays.animation).toBe("nebula-particle-flash");
|
||
expect(legendaryBurstVisual.geometry.rays.duration).toBe("0.68s");
|
||
await expect(legendarySurface.locator(".nebula-card-particle-ring-glow")).toHaveCount(0);
|
||
const legendaryAuraBase = await legendarySurface.evaluate((element) => {
|
||
const style = globalThis.getComputedStyle(element, "::after");
|
||
const normalizeColors = (value) => value.replace(/(?:rgba?|color)\([^)]*\)/g, "<color>");
|
||
return { inset: style.inset, border: style.borderWidth, radius: style.borderRadius, background: normalizeColors(style.backgroundImage), shadow: normalizeColors(style.boxShadow), filter: normalizeColors(style.filter), mask: style.maskImage || style.webkitMaskImage };
|
||
});
|
||
|
||
await expect(legendarySurface).not.toHaveAttribute("data-aura-palette");
|
||
await expect(legendarySurface.locator(".nebula-card-glow-palette, .nebula-card-opening-glow-palette")).toHaveCount(0);
|
||
const mythicPreview = openingEffects.filter({ has: page.locator('[data-opening-effect="mythic-default-opening"]') });
|
||
const mythicSurface = mythicPreview.locator(".nebula-card-reveal");
|
||
await expect(mythicPreview).not.toContainText("Effet personnalisé");
|
||
await expect(mythicSurface).toHaveCSS("--card-rarity", "#f4f1ff");
|
||
await expect(mythicSurface).toHaveAttribute("data-particle-shape", "sparks");
|
||
await expect(mythicSurface).toHaveAttribute("data-particle-palette", "rainbow");
|
||
await expect(mythicPreview.getByRole("button", { name: "Forme de particules : Étincelles" })).toBeVisible();
|
||
const particlePaletteTrigger = mythicPreview.getByRole("button", { name: "Palette de particules : Arc-en-ciel" });
|
||
await expect(particlePaletteTrigger.locator('.nebula-admin-palette[data-compact="true"] i')).toHaveCount(7);
|
||
await particlePaletteTrigger.click();
|
||
await mythicPreview.getByRole("button", { name: "Violet épique", exact: true }).click();
|
||
await expect(mythicSurface).toHaveAttribute("data-particle-palette", "epic-violet");
|
||
await expect(mythicSurface).toHaveCSS("--opening-aura-secondary", "#f0abfc");
|
||
expect(await mythicSurface.evaluate((element) => element.style.getPropertyValue("--opening-aura-gradient"))).toBe("conic-gradient(from 15deg, #ffffff, #f0abfc, #d946ef, #a21caf, #ffffff)");
|
||
const violetRayVisual = await mythicSurface.evaluate((element) => {
|
||
const particles = element.ownerDocument.createElement("span");
|
||
particles.className = "nebula-card-particles";
|
||
element.append(particles);
|
||
const style = globalThis.getComputedStyle(particles, "::after");
|
||
const visual = { background: style.backgroundImage, mask: style.maskImage || style.webkitMaskImage };
|
||
particles.remove();
|
||
return visual;
|
||
});
|
||
await mythicPreview.getByRole("button", { name: "Palette de particules : Violet épique" }).click();
|
||
await mythicPreview.getByRole("button", { name: "Arc-en-ciel", exact: true }).click();
|
||
const rainbowRayVisual = await mythicSurface.evaluate((element) => {
|
||
const particles = element.ownerDocument.createElement("span");
|
||
particles.className = "nebula-card-particles";
|
||
element.append(particles);
|
||
const style = globalThis.getComputedStyle(particles, "::after");
|
||
const visual = { background: style.backgroundImage, mask: style.maskImage || style.webkitMaskImage };
|
||
particles.remove();
|
||
return visual;
|
||
});
|
||
expect(violetRayVisual.mask).toBe(rainbowRayVisual.mask);
|
||
expect(rainbowRayVisual.mask).toContain("repeating-conic-gradient");
|
||
expect(rainbowRayVisual.mask).toContain("18deg");
|
||
expect(violetRayVisual.background).toContain("rgb(217, 70, 239)");
|
||
expect(rainbowRayVisual.background).toContain("rgb(52, 199, 89)");
|
||
const mythicCard = mythicPreview.getByRole("button", { name: "Révéler la carte Mythique", exact: true });
|
||
await mythicPreview.getByRole("button", { name: "Forme de particules : Étincelles" }).click();
|
||
await expect(mythicPreview.getByRole("button", { name: "Flocons de neige", exact: true })).toBeVisible();
|
||
await mythicPreview.getByRole("button", { name: "Flocons de neige", exact: true }).click();
|
||
await expect(mythicSurface).toHaveAttribute("data-particle-shape", "snowflakes");
|
||
await mythicCard.click();
|
||
await expect(mythicSurface.locator(".nebula-card-particles i")).toHaveCount(48);
|
||
const snowflakeVisual = await mythicSurface.locator(".nebula-card-particles").evaluate((element) => {
|
||
const styles = element.ownerDocument.defaultView;
|
||
const before = styles.getComputedStyle(element, "::before");
|
||
const after = styles.getComputedStyle(element, "::after");
|
||
const particle = element.querySelectorAll("i");
|
||
const flake = styles.getComputedStyle(particle[0], "::before");
|
||
return {
|
||
ring: { width: before.width, border: before.borderWidth, mask: before.maskImage || before.webkitMaskImage },
|
||
rays: { width: after.width, animation: after.animationName },
|
||
sizes: [particle[0], particle[2]].map((item) => styles.getComputedStyle(item).width),
|
||
particleAnimation: styles.getComputedStyle(particle[0]).animationName,
|
||
flakeMask: flake.maskImage || flake.webkitMaskImage,
|
||
clipPath: styles.getComputedStyle(particle[0]).clipPath
|
||
};
|
||
});
|
||
expect(snowflakeVisual.ring).toEqual({ width: "92px", border: "6px", mask: expect.stringContaining("radial-gradient") });
|
||
expect(snowflakeVisual.rays).toEqual({ width: "260px", animation: "nebula-particle-flash" });
|
||
expect(snowflakeVisual.sizes).toEqual(["24px", "14px"]);
|
||
expect(snowflakeVisual.particleAnimation).toBe("nebula-particle-snowflake");
|
||
expect(snowflakeVisual.flakeMask).toContain("svg");
|
||
expect(snowflakeVisual.clipPath).toBe("none");
|
||
await expect(mythicPreview.getByRole("button", { name: "Remettre la carte Mythique face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
await mythicPreview.getByRole("button", { name: "Remettre la carte Mythique face cachée", exact: true }).click();
|
||
await expect(mythicCard).toHaveAttribute("data-reveal-phase", "concealed");
|
||
await mythicPreview.getByRole("button", { name: "Forme de particules : Flocons de neige" }).click();
|
||
await mythicPreview.getByRole("button", { name: "Étincelles", exact: true }).click();
|
||
await expect(mythicSurface).toHaveAttribute("data-particle-shape", "sparks");
|
||
await holdRevealTimers(page);
|
||
await mythicCard.click();
|
||
await expect(mythicSurface).toHaveAttribute("data-reveal-phase", "aura");
|
||
await expect(mythicSurface).toHaveCSS("--opening-aura", "#ff3b30");
|
||
await expect(mythicSurface).toHaveCSS("--opening-aura-duration", "450ms");
|
||
await expect(mythicSurface).toHaveCSS("--opening-particle-duration", "1200ms");
|
||
await expect(mythicSurface).toHaveCSS("--opening-aura-secondary", "#ff9500");
|
||
await expect(mythicSurface).toHaveCSS("--opening-aura-tertiary", "#ffcc00");
|
||
expect(await mythicSurface.evaluate((element) => element.style.getPropertyValue("--opening-aura-gradient"))).toBe("conic-gradient(from 15deg, #ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #3b82f6, #d946ef, #ff3b30)");
|
||
const mythicAuraBase = await mythicSurface.evaluate((element) => {
|
||
const style = globalThis.getComputedStyle(element, "::after");
|
||
const normalizeColors = (value) => value.replace(/(?:rgba?|color)\([^)]*\)/g, "<color>");
|
||
return { inset: style.inset, border: style.borderWidth, radius: style.borderRadius, background: normalizeColors(style.backgroundImage), shadow: normalizeColors(style.boxShadow), filter: normalizeColors(style.filter), mask: style.maskImage || style.webkitMaskImage };
|
||
});
|
||
const { shadow: mythicAuraShadow, ...mythicAuraBaseShape } = mythicAuraBase;
|
||
const { shadow: legendaryAuraShadow, ...legendaryAuraBaseShape } = legendaryAuraBase;
|
||
expect(mythicAuraBaseShape).toEqual(legendaryAuraBaseShape);
|
||
expect(legendaryAuraShadow).toContain("28px");
|
||
expect(mythicAuraShadow).toBe("none");
|
||
await expect(mythicSurface).toHaveAttribute("data-aura-palette", "true");
|
||
await expect(mythicSurface.locator(".nebula-card-tilt-surface")).toHaveCSS("filter", "none");
|
||
const crownGlowVisual = await mythicSurface.locator(":scope > .nebula-card-opening-glow-palette").evaluate((element) => {
|
||
const style = globalThis.getComputedStyle(element);
|
||
const inner = element.firstElementChild;
|
||
const near = globalThis.getComputedStyle(inner, "::before");
|
||
const far = globalThis.getComputedStyle(inner, "::after");
|
||
return { display: style.display, animation: style.animationName, duration: style.animationDuration, mask: style.maskImage || style.webkitMaskImage, nearBackground: near.backgroundImage, nearFilter: near.filter, nearOpacity: near.opacity, farFilter: far.filter, farOpacity: far.opacity };
|
||
});
|
||
expect(crownGlowVisual).toMatchObject({ display: "block", animation: "nebula-opening-aura", duration: "0.45s", nearOpacity: "0.78", farOpacity: "0.48" });
|
||
expect(crownGlowVisual.mask).toContain("svg");
|
||
expect(crownGlowVisual.nearBackground).toContain("conic-gradient");
|
||
expect(crownGlowVisual.nearFilter).toContain("blur(14px)");
|
||
expect(crownGlowVisual.farFilter).toContain("blur(32px)");
|
||
const cardGlowVisual = await mythicSurface.locator(".nebula-card-glow-palette").evaluateAll((elements) => elements.map((element) => {
|
||
const style = globalThis.getComputedStyle(element);
|
||
return { side: element.dataset.side, display: style.display, backface: style.backfaceVisibility, background: globalThis.getComputedStyle(element, "::before").backgroundImage, animation: style.animationName };
|
||
}));
|
||
expect(cardGlowVisual.map(({ side }) => side)).toEqual(["back", "face"]);
|
||
for (const glow of cardGlowVisual) expect(glow).toMatchObject({ display: "block", backface: "hidden", animation: "nebula-opening-card-glow-palette-in" });
|
||
for (const glow of cardGlowVisual) expect(glow.background).toContain("conic-gradient");
|
||
// La couronne et la lueur ne colorent que le contour : sans cette exclusion, qu'un minifieur peut retirer, l'aura remplit toute la zone.
|
||
const maskComposites = await mythicSurface.locator(":scope > .nebula-card-opening-crown-palette, :scope > .nebula-card-opening-glow-palette").evaluateAll((elements) => elements.map((element) => globalThis.getComputedStyle(element).maskComposite));
|
||
expect(maskComposites).toHaveLength(2);
|
||
for (const composite of maskComposites) expect(composite).toMatch(/^exclude\b/);
|
||
const mythicAuraPalettes = mythicSurface.locator(":scope > .nebula-card-opening-aura-palette, :scope > .nebula-card-opening-crown-palette");
|
||
await expect(mythicAuraPalettes).toHaveCount(2);
|
||
const auraPaletteVisual = await mythicSurface.locator(":scope > .nebula-card-opening-aura-palette").evaluate((element) => {
|
||
const style = globalThis.getComputedStyle(element);
|
||
return { background: style.backgroundImage, mask: style.maskImage || style.webkitMaskImage, animation: style.animationName, duration: style.animationDuration, filter: style.filter, zIndex: style.zIndex };
|
||
});
|
||
const crownPaletteVisual = await mythicSurface.locator(":scope > .nebula-card-opening-crown-palette").evaluate((element) => {
|
||
const style = globalThis.getComputedStyle(element);
|
||
return { background: style.backgroundImage, mask: style.maskImage || style.webkitMaskImage, animation: style.animationName, duration: style.animationDuration, filter: style.filter, zIndex: style.zIndex };
|
||
});
|
||
expect(auraPaletteVisual.background).toContain("conic-gradient");
|
||
expect(auraPaletteVisual.mask).toContain("radial-gradient");
|
||
expect(crownPaletteVisual.background).toContain("conic-gradient");
|
||
expect(crownPaletteVisual.mask).toContain("linear-gradient");
|
||
expect(auraPaletteVisual.animation).toBe("nebula-opening-aura");
|
||
expect(crownPaletteVisual.animation).toBe("nebula-opening-aura");
|
||
expect(auraPaletteVisual.duration).toBe("0.45s");
|
||
expect(crownPaletteVisual.duration).toBe("0.45s");
|
||
expect(auraPaletteVisual.filter).toBe(crownPaletteVisual.filter);
|
||
expect(auraPaletteVisual.zIndex).toBe("1");
|
||
expect(crownPaletteVisual.zIndex).toBe("1");
|
||
await expect(mythicSurface.locator(".nebula-card-tilt-surface")).toHaveCSS("z-index", "2");
|
||
await page.clock.runFor(450);
|
||
await expect(mythicSurface.locator(".nebula-card-particles i")).toHaveCount(48);
|
||
const mythicBurstGeometry = await mythicSurface.locator(".nebula-card-particles").evaluate((element) => {
|
||
const styles = element.ownerDocument.defaultView;
|
||
const normalizeColors = (value) => value.replace(/rgba?\([^)]*\)/g, "<color>");
|
||
const before = styles.getComputedStyle(element, "::before");
|
||
const after = styles.getComputedStyle(element, "::after");
|
||
const particle = styles.getComputedStyle(element.querySelector("i"));
|
||
return {
|
||
ring: { width: before.width, height: before.height, border: before.borderWidth, radius: before.borderRadius, shadow: normalizeColors(before.boxShadow), animation: before.animationName, duration: before.animationDuration, easing: before.animationTimingFunction },
|
||
rays: { width: after.width, height: after.height, radius: after.borderRadius, filter: normalizeColors(after.filter), animation: after.animationName, duration: after.animationDuration, easing: after.animationTimingFunction },
|
||
particle: { width: particle.width, height: particle.height, radius: particle.borderRadius, clipPath: particle.clipPath, animation: particle.animationName, duration: particle.animationDuration, easing: particle.animationTimingFunction, x: particle.getPropertyValue("--x"), y: particle.getPropertyValue("--y") },
|
||
particleSizes: [...element.querySelectorAll("i")].map((item) => `${styles.getComputedStyle(item).width}x${styles.getComputedStyle(item).height}`).join(" ")
|
||
};
|
||
});
|
||
const { shadow: mythicRingShadow, ...mythicRingGeometry } = mythicBurstGeometry.ring;
|
||
const { shadow: legendaryRingShadow, ...legendaryRingGeometry } = legendaryBurstVisual.geometry.ring;
|
||
expect(legendaryRingShadow).not.toBe("none");
|
||
expect(mythicRingShadow).toBe("none");
|
||
const { width: mythicParticleWidth, height: mythicParticleHeight, ...mythicParticleMotion } = mythicBurstGeometry.particle;
|
||
const { width: legendaryParticleWidth, height: legendaryParticleHeight, ...legendaryParticleMotion } = legendaryBurstVisual.geometry.particle;
|
||
const { particleSizes: mythicParticleSizes, ...mythicBurstShared } = mythicBurstGeometry;
|
||
const { particleSizes: legendaryParticleSizes, ...legendaryBurstShared } = legendaryBurstVisual.geometry;
|
||
expect({ ...mythicBurstShared, ring: mythicRingGeometry, particle: mythicParticleMotion }).toEqual({ ...legendaryBurstShared, ring: legendaryRingGeometry, particle: legendaryParticleMotion });
|
||
expect([legendaryParticleWidth, legendaryParticleHeight]).toEqual(["12px", "12px"]);
|
||
expect([mythicParticleWidth, mythicParticleHeight]).toEqual(["16px", "16px"]);
|
||
expect(legendaryParticleSizes.split(" ").slice(0, 3)).toEqual(["12pxx12px", "12pxx12px", "7pxx18px"]);
|
||
expect(mythicParticleSizes.split(" ").slice(0, 3)).toEqual(["16pxx16px", "16pxx16px", "9pxx24px"]);
|
||
expect(mythicParticleSizes.split(" ")).toHaveLength(48);
|
||
const mythicRingBackground = await mythicSurface.locator(".nebula-card-particles").evaluate((element) => globalThis.getComputedStyle(element, "::before").backgroundImage);
|
||
expect(mythicRingBackground).toContain("conic-gradient");
|
||
expect(mythicRingBackground).toContain("rgb(255, 59, 48)");
|
||
const mythicRingGlow = await mythicSurface.locator(".nebula-card-particle-ring-glow").evaluateAll((elements) => elements.map((element) => {
|
||
const style = globalThis.getComputedStyle(element);
|
||
return { glow: element.dataset.glow, background: globalThis.getComputedStyle(element.firstElementChild.firstElementChild).backgroundImage, filter: globalThis.getComputedStyle(element.firstElementChild).filter, animation: style.animationName, duration: style.animationDuration };
|
||
}));
|
||
expect(mythicRingGlow.map(({ glow }) => glow)).toEqual(["outer", "inner"]);
|
||
for (const glow of mythicRingGlow) {
|
||
expect(glow.background).toContain("conic-gradient");
|
||
expect(glow.filter).toBe("blur(9px)");
|
||
expect(glow.animation).toBe("nebula-particle-ring");
|
||
expect(glow.duration).toBe("1.2s");
|
||
}
|
||
await expectMythicRingSilhouetteToMatchLegendary(page);
|
||
const mythicRayBackground = await mythicSurface.locator(".nebula-card-particles").evaluate((element) => globalThis.getComputedStyle(element, "::after").backgroundImage);
|
||
expect(mythicRayBackground).toContain("conic-gradient");
|
||
expect(mythicRayBackground).toContain("rgb(255, 59, 48)");
|
||
expect(mythicRayBackground).toContain("rgb(52, 199, 89)");
|
||
const mythicParticleColors = await mythicSurface.locator(".nebula-card-particles i").evaluateAll((particles) => [...new Set(particles.map((particle) => globalThis.getComputedStyle(particle).color))]);
|
||
expect(mythicParticleColors.length).toBe(7);
|
||
await page.clock.resume();
|
||
await expect(mythicPreview.getByRole("button", { name: "Remettre la carte Mythique face cachée", exact: true })).toHaveAttribute("data-reveal-phase", "revealed");
|
||
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
await noOverflow();
|
||
|
||
await expandSections(page, "Sections de l’administration");
|
||
await navigation.getByRole("link", { name: "Collections" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/collections$/);
|
||
const recharge = page.getByRole("complementary", { name: "Recharge des ouvertures" });
|
||
await expect(recharge.locator(".nebula-admin-recharge-current")).toHaveText("1 ouverture toutes les heures · réserve de 5");
|
||
await expect(recharge.getByLabel("Délai en minutes")).toHaveValue("60");
|
||
await expect(recharge.getByRole("status")).toHaveText("1 h · 24 ouvertures par jour · réserve vide remplie en 5 h");
|
||
await expect(recharge.getByRole("combobox")).toHaveCount(0);
|
||
const applyRecharge = recharge.getByRole("button", { name: "Appliquer", exact: true });
|
||
await expect(applyRecharge).toBeDisabled();
|
||
// La réserve se règle à côté du délai ; le serveur de test est partagé : elle reste à 5 pour les autres scénarios.
|
||
const reserveInput = recharge.getByLabel("Réserve maximale");
|
||
await expect(reserveInput).toHaveValue("5");
|
||
await reserveInput.fill("51");
|
||
await expect(recharge.getByRole("status")).toHaveText("Réserve : entre 1 et 50 ouvertures.");
|
||
await expect(applyRecharge).toBeDisabled();
|
||
await reserveInput.fill("8");
|
||
await expect(recharge.getByRole("status")).toHaveText("1 h · 24 ouvertures par jour · réserve vide remplie en 8 h");
|
||
await expect(applyRecharge).toBeEnabled();
|
||
await reserveInput.fill("5");
|
||
await recharge.getByLabel("Délai en minutes").fill("30");
|
||
await expect(recharge.getByRole("status")).toHaveText("30 min · 48 ouvertures par jour · réserve vide remplie en 2 h 30 min");
|
||
await applyRecharge.click();
|
||
await page.getByRole("dialog", { name: "Passer à 1 ouverture toutes les 30 min ?" }).getByRole("button", { name: "Appliquer la recharge" }).click();
|
||
await expect(recharge.locator(".nebula-admin-recharge-current")).toHaveText("1 ouverture toutes les 30 min · réserve de 5");
|
||
await expect(recharge.getByRole("button", { name: "Appliquer", exact: true })).toBeDisabled();
|
||
|
||
// L'historique d'administration garde cette modification, lisible et attribuée, et s'actualise sans recharger la page.
|
||
await expandSections(page, "Sections de l’administration");
|
||
await page.getByRole("navigation", { name: "Sections de l’administration" }).getByRole("link", { name: "Historique", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/history$/);
|
||
const latestAdminAction = page.locator(".nebula-history-list > li").first();
|
||
await expect(latestAdminAction).toContainText("Recharge modifiée");
|
||
await expect(latestAdminAction).toContainText(/1\s*h → 30\s*min/);
|
||
await expect(latestAdminAction).toContainText("par Version développement");
|
||
await page.goBack();
|
||
|
||
// Ouverture aux joueurs et taux de tirage se règlent sur la page de la collection.
|
||
await page.getByRole("link", { name: "Ouvrir la collection Genèse Astrale" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/collections\/astral-genesis$/);
|
||
const genesisCard = page.locator(".nebula-admin-collection-card");
|
||
const packSwitch = genesisCard.getByRole("button", { name: "Ouvrir Genèse Astrale aux joueurs" });
|
||
await expect(packSwitch).toHaveAttribute("aria-pressed", "true");
|
||
const genesisPack = page.locator(".nebula-admin-drop-rates");
|
||
await expect(genesisPack.getByRole("heading", { name: "Taux de tirage" })).toBeVisible();
|
||
await expect(genesisPack.locator("tbody tr td strong")).toHaveText(["64 %", "24 %", "8 %", "3 %", "1 %"]);
|
||
await expect(genesisPack.locator('tbody tr[data-rarity="mythic"] td').nth(2)).toHaveText("1");
|
||
await expect(genesisPack.locator('tbody tr[data-rarity="mythic"] td').nth(3)).toHaveText("1 %");
|
||
const applyButton = genesisPack.getByRole("button", { name: "Appliquer", exact: true });
|
||
const recommendedButton = genesisPack.getByRole("button", { name: "Taux recommandés" });
|
||
await expect(recommendedButton).toBeDisabled();
|
||
await expect(applyButton).toBeDisabled();
|
||
await genesisPack.getByLabel("Poids Commun").fill("63");
|
||
await genesisPack.getByLabel("Poids Mythique").fill("2");
|
||
await expect(genesisPack.locator('tbody tr[data-rarity="mythic"] td strong')).toHaveText("2 %");
|
||
await expect(genesisPack.locator('tbody tr[data-rarity="mythic"] td small')).toHaveText("avant 1 %");
|
||
await genesisPack.getByLabel("Poids Rare").fill("-1");
|
||
await expect(genesisPack.getByRole("alert")).toContainText("entier positif ou nul");
|
||
await expect(applyButton).toBeDisabled();
|
||
await genesisPack.getByLabel("Poids Rare").fill("24");
|
||
await applyButton.click();
|
||
await page.getByRole("dialog", { name: "Appliquer les nouveaux taux de Genèse Astrale ?" }).getByRole("button", { name: "Appliquer les taux" }).click();
|
||
await expect(applyButton).toBeDisabled();
|
||
await expect(genesisPack.locator('tbody tr[data-rarity="mythic"] td strong')).toHaveText("2 %");
|
||
// « Taux recommandés » préremplit le tableau sans rien enregistrer.
|
||
await recommendedButton.click();
|
||
await expect(genesisPack.getByLabel("Poids Mythique")).toHaveValue("1");
|
||
await expect(genesisPack.getByLabel("Poids Commun")).toHaveValue("64");
|
||
await expect(recommendedButton).toBeDisabled();
|
||
await expect(applyButton).toBeEnabled();
|
||
await genesisPack.getByRole("button", { name: "Annuler les modifications" }).click();
|
||
await expect(genesisPack.getByLabel("Poids Mythique")).toHaveValue("2");
|
||
await packSwitch.click();
|
||
await page.getByRole("dialog", { name: "Fermer Genèse Astrale ?" }).getByRole("button", { name: "Fermer le paquet" }).click();
|
||
await expect(packSwitch).toHaveAttribute("aria-pressed", "false");
|
||
await expect(genesisCard).toContainText("Fermé aux joueurs");
|
||
// Une collection temporaire fermée sans carte possédée disparaît de la page Collection du joueur.
|
||
const closedCollectionAdminUrl = page.url();
|
||
await page.goto("/#/cards/collection");
|
||
await expect(page.locator(".nebula-album-group").first()).toBeVisible();
|
||
await expect(page.locator(".nebula-album-group", { hasText: "Genèse Astrale" })).toHaveCount(0);
|
||
await page.locator(".nebula-album-filters").getByRole("button", { name: "Collection", exact: true }).click();
|
||
await expect(page.locator(".nebula-album-filters").getByRole("checkbox", { name: "Genèse Astrale" })).toHaveCount(0);
|
||
await page.keyboard.press("Escape");
|
||
await page.goto(closedCollectionAdminUrl);
|
||
await expect(genesisCard).toContainText("Fermé aux joueurs");
|
||
await expect(genesisCard.locator(".nebula-admin-collection-badges .nds-badge").nth(1)).toHaveText("Fermée");
|
||
await packSwitch.click();
|
||
await expect(packSwitch).toHaveAttribute("aria-pressed", "true");
|
||
await noOverflow();
|
||
await page.goto("/#/cards/admin/packs");
|
||
await expect(selectTrigger(page, "Sections de l’administration")).toHaveText("Sections de l’administration : Collections");
|
||
|
||
await expandSections(page, "Sections de l’administration");
|
||
await navigation.getByRole("link", { name: "Boutique" }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/shop$/);
|
||
const recyclingForm = page.getByRole("region", { name: "Recyclage des doublons" });
|
||
const articlesForm = page.getByRole("region", { name: "Articles de la boutique" });
|
||
await expect(recyclingForm.getByLabel("Mythique", { exact: true })).toHaveValue("150");
|
||
await expect(recyclingForm.getByRole("button", { name: "Appliquer" })).toBeDisabled();
|
||
await expect(articlesForm.getByRole("button", { name: "Appliquer" })).toBeDisabled();
|
||
// Mêmes illustrations que la boutique des joueurs.
|
||
await expect(articlesForm.locator('.nebula-shop-item[data-item="pack"] .nebula-collection-back')).toBeVisible();
|
||
await expect(articlesForm.locator('.nebula-shop-item[data-item="opening"] img')).toHaveAttribute("src", "/static/img/cards/shop/pack.webp");
|
||
// Appliquer les prix conserve le brouillon du barème, et ne l'envoie pas.
|
||
await recyclingForm.getByLabel("Commun", { exact: true }).fill("2");
|
||
await articlesForm.getByLabel("Prix d’une ouverture de paquet").fill("45");
|
||
await expect(articlesForm.getByRole("status")).toHaveText("Une ouverture = 45 doublons communs recyclés.");
|
||
await articlesForm.getByRole("button", { name: "Appliquer" }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Appliquer" }).click();
|
||
await expect(articlesForm.getByLabel("Prix d’une ouverture de paquet")).toHaveValue("45");
|
||
await expect(articlesForm.getByRole("button", { name: "Appliquer" })).toBeDisabled();
|
||
await expect(recyclingForm.getByLabel("Commun", { exact: true })).toHaveValue("2");
|
||
await recyclingForm.getByRole("button", { name: "Annuler les modifications" }).click();
|
||
await expect(recyclingForm.getByLabel("Commun", { exact: true })).toHaveValue("1");
|
||
// Le prix d'un Éclat (Pont des Veilleurs) se règle avec les autres articles, même Expéditions fermées.
|
||
const eclatsArticle = articlesForm.locator('.nebula-shop-item[data-item="eclats"]');
|
||
await expect(eclatsArticle).toContainText("Fermé aux joueurs");
|
||
const eclatPrice = eclatsArticle.getByLabel("Prix d’un Éclat d’étoile");
|
||
await expect(eclatPrice).toHaveValue("3");
|
||
// Machine lente simulée : les champs restent verrouillés de l'enregistrement au rechargement des données, sinon le formulaire
|
||
// recréé à son arrivée efface une saisie commencée entre les deux.
|
||
const slowRequests = /\/api\/cards\/admin\/(dashboard|expeditions\/settings)$/;
|
||
await page.route(slowRequests, async (route) => {
|
||
await new Promise((resolve) => globalThis.setTimeout(resolve, 600));
|
||
await route.continue();
|
||
});
|
||
for (const price of ["4", "3"]) {
|
||
await eclatPrice.fill(price);
|
||
await articlesForm.getByRole("button", { name: "Appliquer" }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Appliquer" }).click();
|
||
await expect(eclatPrice).toHaveValue(price);
|
||
await expect(articlesForm.getByRole("button", { name: "Appliquer" })).toBeDisabled();
|
||
}
|
||
await expect(eclatPrice).toBeEnabled();
|
||
await page.unroute(slowRequests);
|
||
await expect(eclatsArticle).toContainText("Premier niveau d’une légendaire (70 Éclats) = 210 poussières.");
|
||
await noOverflow();
|
||
|
||
await expandSections(page, "Sections de l’administration");
|
||
await navigation.getByRole("link", { name: "Codes cadeaux" }).click();
|
||
// La liste d'abord : le formulaire s'ouvre à la demande.
|
||
await expect(page.getByText("Aucune campagne pour l’instant.", { exact: true })).toBeVisible();
|
||
const campaignForm = page.locator(".nebula-admin-campaign-form");
|
||
await expect(campaignForm).toHaveCount(0);
|
||
const newCampaign = page.getByRole("button", { name: "+ Nouvelle campagne" });
|
||
await newCampaign.click();
|
||
await campaignForm.getByRole("button", { name: "Annuler" }).click();
|
||
await expect(campaignForm).toHaveCount(0);
|
||
await newCampaign.click();
|
||
await expect(page.getByRole("heading", { name: "Nouvelle campagne" })).toBeVisible();
|
||
const createButton = campaignForm.getByRole("button", { name: "Créer la campagne" });
|
||
await expect(createButton).toBeDisabled();
|
||
await expect(campaignForm.locator(".nebula-admin-reward-item")).toHaveCount(0);
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toHaveText("Ajoutez des cartes ou un paquet pour voir le récapitulatif.");
|
||
await expect(campaignForm.getByRole("group", { name: "Cartes à offrir" })).toHaveCount(0);
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-missing")).toHaveText("Pour créer la campagne, il manque : le nom de la campagne ; au moins une carte ou un paquet ; un code de 4 à 24 caractères (lettres, chiffres, tirets).");
|
||
|
||
// Carte offerte, codes uniques.
|
||
await campaignForm.getByLabel("Nom de la campagne, visible par les joueurs").fill("Cadeau dragon");
|
||
await campaignForm.getByRole("button", { name: "+ Ajouter des cartes" }).click();
|
||
const cardPicker = campaignForm.getByRole("group", { name: "Cartes à offrir" });
|
||
await expect(cardPicker.getByRole("status")).toHaveText("Aucune carte cochée.");
|
||
await expect(cardPicker.locator('.nebula-card[data-card-size="sm"]').first()).toBeVisible();
|
||
await cardPicker.getByRole("radio", { name: "Mythique" }).click();
|
||
await cardPicker.getByRole("searchbox").fill("dragon");
|
||
await expect(cardPicker.locator(".nebula-admin-card-picker-item")).toHaveCount(2);
|
||
const auroraDragon = cardPicker.getByRole("button", { name: "Sélectionner Dragon du Néant Étoilé — Mythique · Prisme spectral — Aurore" });
|
||
const otherDragon = cardPicker.locator(".nebula-admin-card-picker-item button").nth(1);
|
||
await auroraDragon.click();
|
||
await otherDragon.click();
|
||
await expect(auroraDragon).toHaveAttribute("aria-pressed", "true");
|
||
await expect(cardPicker.getByRole("status")).toHaveText("2 cartes cochées");
|
||
// Un second clic décoche la carte.
|
||
await otherDragon.click();
|
||
await expect(otherDragon).toHaveAttribute("aria-pressed", "false");
|
||
const checkedCards = campaignForm.getByRole("list", { name: "Cartes cochées" });
|
||
await expect(checkedCards.getByRole("listitem")).toHaveCount(1);
|
||
await expect(checkedCards).toContainText("Dragon du Néant Étoilé — Mythique · Prisme spectral — Aurore");
|
||
// Par défaut : sans limite d'utilisations, sans date d'expiration.
|
||
await expect(campaignForm.getByLabel("Sans limite d’utilisations")).toBeChecked();
|
||
await expect(campaignForm.getByLabel("Utilisations maximum")).toHaveCount(0);
|
||
await expect(campaignForm.getByLabel("Sans date d’expiration")).toBeChecked();
|
||
await expect(campaignForm.getByLabel("Valable jusqu’au")).toHaveCount(0);
|
||
await campaignForm.getByRole("button", { name: "Générer" }).click();
|
||
await expect(campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)")).toHaveValue(/^[2-9A-HJKMNP-Z]{4}-[2-9A-HJKMNP-Z]{4}$/);
|
||
await campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)").fill("dragon-01");
|
||
await campaignForm.getByLabel("Sans limite d’utilisations").uncheck();
|
||
await campaignForm.getByLabel("Utilisations maximum").fill("1");
|
||
await campaignForm.getByLabel("Sans date d’expiration").uncheck();
|
||
await expect(campaignForm.getByLabel("Valable jusqu’au")).toBeVisible();
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Carte Dragon du Néant Étoilé (Mythique · Prisme spectral — Aurore)");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Le code DRAGON-01, utilisable 1 fois, jusqu’au");
|
||
await createButton.click();
|
||
const generated = page.locator(".nebula-admin-generated");
|
||
await expect(generated.getByRole("heading", { name: "Campagne « Cadeau dragon » créée" })).toBeVisible();
|
||
await expect(generated).toContainText("Code à annoncer : DRAGON");
|
||
await expect(campaignForm).toHaveCount(0);
|
||
await generated.getByRole("button", { name: "Fermer" }).click();
|
||
await newCampaign.click();
|
||
|
||
// Récompense composée : une carte et deux paquets avec garantie, code partagé sans limite.
|
||
await campaignForm.getByLabel("Nom de la campagne, visible par les joueurs").fill("Live de lancement");
|
||
await expect(campaignForm.locator(".nebula-admin-reward-item")).toHaveCount(0);
|
||
await expect(cardPicker).toHaveCount(0);
|
||
await campaignForm.getByRole("button", { name: "+ Ajouter des cartes" }).click();
|
||
await chooseOption(campaignForm, "Collection affichée", "Genèse Astrale");
|
||
await cardPicker.getByRole("button", { name: "Sélectionner Paquet Astral — Commun" }).click();
|
||
await campaignForm.getByRole("button", { name: "+ Ajouter un paquet" }).click();
|
||
const packItem = campaignForm.getByRole("group", { name: "Paquet 1" });
|
||
await chooseOption(packItem, "Collection", "Genèse Astrale");
|
||
await packItem.getByLabel("Quantité").fill("2");
|
||
await packItem.getByRole("radio", { name: "Une rareté minimum" }).click();
|
||
await chooseOption(packItem, "Rareté garantie", "Légendaire");
|
||
await campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)").fill("e2e live");
|
||
await expect(campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)")).toHaveValue("E2E-LIVE");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-missing")).toHaveCount(0);
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("+ 2 × Paquet Genèse Astrale · au moins 1 carte légendaire ou mieux garantie");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Le code E2E-LIVE, utilisable sans limite, sans date d’expiration.");
|
||
await createButton.click();
|
||
await expect(generated).toContainText("E2E-LIVE");
|
||
|
||
const campaigns = page.locator(".nebula-campaign-card");
|
||
await expect(campaigns).toHaveCount(2);
|
||
const dragonCampaign = page.getByRole("article", { name: "Cadeau dragon" });
|
||
await dragonCampaign.getByRole("button", { name: "Détails" }).click();
|
||
await expect(dragonCampaign).toContainText("Code DRAGON");
|
||
await expect(dragonCampaign).toContainText("0 / 1 utilisés");
|
||
await expect(dragonCampaign).toContainText("Personne n’a encore utilisé ce code.");
|
||
await noOverflow();
|
||
// À 768 px, la prolongation (date, heure, case, bouton) passe à la ligne au lieu de sortir de la carte.
|
||
await page.setViewportSize({ width: 768, height: 1000 });
|
||
await expect(dragonCampaign.getByRole("button", { name: "Changer l’expiration" })).toBeVisible();
|
||
expect(await dragonCampaign.evaluate((element) => element.scrollWidth - element.clientWidth)).toBeLessThanOrEqual(0);
|
||
|
||
// Le filtre sépare les campagnes en cours des campagnes terminées (révoquées, expirées ou épuisées).
|
||
const campaignFilter = page.getByRole("group", { name: "Afficher les campagnes" });
|
||
await campaignFilter.getByRole("button", { name: "Terminées (0)" }).click();
|
||
await expect(campaigns).toHaveCount(0);
|
||
await expect(page.getByText("Aucune campagne terminée.")).toBeVisible();
|
||
await campaignFilter.getByRole("button", { name: "En cours (2)" }).click();
|
||
await expect(campaigns).toHaveCount(2);
|
||
await campaignFilter.getByRole("button", { name: "Toutes (2)" }).click();
|
||
|
||
// Dupliquer reprend la récompense et les réglages ; seul le code reste à choisir.
|
||
await page.getByRole("button", { name: "Dupliquer Live de lancement" }).click();
|
||
await expect(campaignForm.getByRole("heading", { name: "Copie de « Live de lancement »" })).toBeVisible();
|
||
await expect(campaignForm.getByLabel("Nom de la campagne, visible par les joueurs")).toHaveValue("Live de lancement");
|
||
await expect(campaignForm.getByLabel("Code à annoncer (8 à 24 caractères)")).toHaveValue("");
|
||
await expect(campaignForm.getByRole("group", { name: "Paquet 1" }).getByLabel("Quantité")).toHaveValue("2");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-missing")).toHaveText("Pour créer la campagne, il manque : un code de 4 à 24 caractères (lettres, chiffres, tirets).");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("Carte Paquet Astral");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("+ 2 × Paquet Genèse Astrale · au moins 1 carte légendaire ou mieux garantie");
|
||
await expect(campaignForm.locator(".nebula-admin-campaign-summary")).toContainText("utilisable sans limite, sans date d’expiration.");
|
||
await noOverflow();
|
||
await campaignForm.getByRole("button", { name: "Annuler" }).click();
|
||
await expect(campaignForm).toHaveCount(0);
|
||
|
||
// Le joueur utilise le code partagé dans l'onglet Paquets et ouvre le paquet offert.
|
||
await page.goto("/#/cards");
|
||
await expandSections(page, "Sections de Sokko TCG");
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: /^Paquets/ }).click();
|
||
await page.getByRole("textbox", { name: "Utiliser un code" }).fill("e2e-live");
|
||
await page.getByRole("button", { name: "Utiliser le code" }).click();
|
||
await expect(page.locator(".nebula-redeem [role=\"status\"]")).toContainText("Code utilisé, vous recevez : Carte Paquet Astral");
|
||
await expect(page.locator(".nebula-redeem [role=\"status\"]")).toContainText("2 × Paquet Genèse Astrale · au moins 1 carte légendaire ou mieux garantie");
|
||
const giftPack = page.locator(".nebula-gift-pack");
|
||
await expect(giftPack).toHaveCount(2);
|
||
await expect(giftPack.first()).toContainText("Live de lancement");
|
||
await giftPack.first().click();
|
||
await expect(page.getByRole("heading", { name: "Révélez vos trois cartes" })).toBeVisible();
|
||
await expect(page.locator(".nebula-opening-odds")).toContainText("au moins 1 carte légendaire ou mieux garantie");
|
||
await page.getByRole("button", { name: "Tout révéler" }).click();
|
||
await expect(page.locator(".nebula-opening-cards .nebula-card[data-rarity=\"legendary\"], .nebula-opening-cards .nebula-card[data-rarity=\"mythic\"]").first()).toBeAttached();
|
||
// Le paquet offert n'a consommé aucune ouverture : il ne propose pas d'en dépenser une pour continuer.
|
||
await expect(page.getByRole("button", { name: "Retour", exact: true })).toBeVisible({ timeout: 30_000 });
|
||
await expect(page.getByRole("button", { name: "Ouvrir un autre paquet de la même collection", exact: true })).toHaveCount(0);
|
||
});
|
||
|
||
test("administration stays within a phone screen", async ({ page }) => {
|
||
await page.setViewportSize({ width: 390, height: 844 });
|
||
await page.goto("/#/cards/admin/history");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Historique", exact: true })).toBeVisible();
|
||
// Un ancêtre masque ce qui dépasse : scrollWidth ne le voit pas, seule la position des éléments le révèle.
|
||
const clipped = await page.locator(".nebula-dashboard :is(a, button, h1)").evaluateAll((elements) => elements
|
||
.filter((element) => element.getBoundingClientRect().right > element.ownerDocument.defaultView.innerWidth + 0.5)
|
||
.map((element) => element.textContent));
|
||
expect(clipped).toEqual([]);
|
||
});
|
||
|
||
test("players give cards and answer trade proposals from two accounts", async ({ browser, page }) => {
|
||
test.setTimeout(90_000);
|
||
const nav = (scope) => scope.getByRole("navigation", { name: "Sections de Sokko TCG" });
|
||
const noOverflow = async (scope) => expect(await scope.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await page.goto("/#/cards/transfers");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Échanges et dons", exact: true })).toBeVisible();
|
||
|
||
const { token } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-partner.json"), "utf8"));
|
||
const partnerContext = await browser.newContext({ baseURL: "http://127.0.0.1:4180" });
|
||
await partnerContext.addCookies([{ name: "__Host-sokkog_cards_session", value: token, domain: "127.0.0.1", path: "/", secure: true, httpOnly: true, sameSite: "Lax" }]);
|
||
const partner = await partnerContext.newPage();
|
||
await partner.goto("/#/cards/transfers");
|
||
|
||
// Don : deux envois du même doublon, sans code ni confirmation du destinataire.
|
||
async function give() {
|
||
await partner.getByRole("button", { name: "Faire un don", exact: true }).click();
|
||
const dialog = partner.getByRole("dialog");
|
||
await chooseOption(dialog, "Joueur", /Version développement/);
|
||
await dialog.getByRole("button", { name: /Vous donnez : Loup des Aurores/ }).click();
|
||
await dialog.getByRole("button", { name: /^Donner Loup des Aurores à Version développement/ }).click();
|
||
await expect(partner.getByRole("status")).toContainText("Loup des Aurores a été donnée à Version développement.");
|
||
}
|
||
await give();
|
||
await give();
|
||
await page.reload();
|
||
await nav(page).getByRole("link", { name: "Collection", exact: true }).waitFor();
|
||
await expect(nav(page).getByRole("link", { name: "Échanges et dons", exact: true })).toBeVisible();
|
||
await page.getByRole("button", { name: /Terminées \(\d+\)/ }).click();
|
||
await expect(page.locator(".nebula-transfers-finished .nebula-transfer-card").first()).toContainText("Don de Partenaire E2E");
|
||
await expect(page.locator(".nebula-transfers-finished .nebula-transfer-card").first()).toContainText("Loup des Aurores");
|
||
|
||
// Échange : le partenaire voit le doublon de l'autre joueur et demande une carte précise.
|
||
async function propose() {
|
||
await partner.reload();
|
||
await partner.getByRole("button", { name: "Proposer un échange", exact: true }).click();
|
||
const dialog = partner.getByRole("dialog");
|
||
await expect(dialog.getByRole("button", { name: "Envoyer la proposition" })).toBeDisabled();
|
||
await chooseOption(dialog, "Joueur", /Version développement/);
|
||
await dialog.getByRole("button", { name: /Vous donnez : Dragon du Néant Étoilé/ }).click();
|
||
await dialog.getByRole("button", { name: /Vous recevez : Loup des Aurores/ }).click();
|
||
await noOverflow(partner);
|
||
// Dans le groupe Échange / Don, le texte ne touche pas les bords de son option.
|
||
expect(await dialog.locator(".nds-radio-button-group button").evaluateAll((buttons) => buttons.every((button) => {
|
||
const range = button.ownerDocument.createRange();
|
||
range.selectNodeContents(button);
|
||
const text = range.getBoundingClientRect();
|
||
const box = button.getBoundingClientRect();
|
||
return text.left - box.left >= 6 && box.right - text.right >= 6;
|
||
}))).toBe(true);
|
||
await dialog.getByRole("button", { name: "Envoyer la proposition" }).click();
|
||
await expect(partner.getByRole("status")).toContainText("Proposition envoyée à Version développement.");
|
||
}
|
||
await propose();
|
||
await expect(partner.getByRole("heading", { name: /Envoyées/ })).toBeVisible();
|
||
await expect(partner.locator(".nebula-transfer-card").first()).toContainText(/Expire dans/);
|
||
|
||
// Le compteur du menu apparaît au retour sur la page, sans recharger.
|
||
await page.evaluate(() => globalThis.dispatchEvent(new globalThis.Event("focus")));
|
||
await expect(nav(page).getByRole("link", { name: /Échanges et dons/ }).locator(".nds-badge")).toHaveText("1");
|
||
const inbox = page.locator(".nebula-transfer-card", { hasText: "Échange avec Partenaire E2E" }).first();
|
||
await expect(inbox.locator(".nebula-card")).toHaveCount(2);
|
||
await inbox.getByRole("button", { name: "Refuser" }).click();
|
||
await expect(page.getByRole("status")).toContainText("Proposition refusée.");
|
||
await expect(nav(page).getByRole("link", { name: "Échanges et dons", exact: true })).toBeVisible();
|
||
|
||
// Le partenaire propose de nouveau, annule, puis propose encore : l'autre joueur accepte.
|
||
await propose();
|
||
await partner.getByRole("button", { name: "Annuler", exact: true }).click();
|
||
await expect(partner.getByRole("status")).toContainText("Proposition annulée");
|
||
await propose();
|
||
await page.evaluate(() => globalThis.dispatchEvent(new globalThis.Event("focus")));
|
||
await page.locator(".nebula-transfer-card", { hasText: "Échange avec Partenaire E2E" }).first().getByRole("button", { name: "Accepter" }).click();
|
||
await expect(page.getByRole("status")).toContainText("Échange terminé");
|
||
await page.goto("/#/cards/history");
|
||
await expect(page.locator(".nebula-history-list")).toContainText("Reçue : Dragon du Néant Étoilé");
|
||
|
||
// La fiche d'une carte en double ouvre directement le formulaire.
|
||
await partner.goto("/#/cards/collection");
|
||
await partner.locator(".nebula-album-entry:not([data-missing]) button").first().click();
|
||
await partner.getByRole("dialog").getByRole("button", { name: "Donner", exact: true }).click();
|
||
await expect(partner.getByRole("dialog").getByRole("heading", { name: "Faire un don" })).toBeVisible();
|
||
await expect(partner.getByRole("dialog").locator('[data-selected]')).toHaveCount(1);
|
||
await partner.getByRole("dialog").getByRole("button", { name: "Fermer", exact: true }).click();
|
||
|
||
// Le paquet de la boutique s'achète en poussière, s'ouvre aussitôt dans la boutique et n'est jamais proposé dans Paquets.
|
||
await partner.goto("/#/cards/packs");
|
||
await expect(partner.locator(".nebula-pack")).toHaveCount(2);
|
||
await partner.goto("/#/cards/shop");
|
||
const packItem = partner.locator('.nebula-shop-item[data-item="pack"]');
|
||
await packItem.getByRole("button", { name: "Acheter et ouvrir" }).click();
|
||
await expect(partner.getByRole("heading", { name: "Révélez vos trois cartes" })).toBeVisible();
|
||
await expect(partner).toHaveURL(/#\/cards\/shop$/);
|
||
await expect(partner.getByRole("heading", { name: "Révélez vos trois cartes" })).toBeVisible();
|
||
await expect(partner.locator(".nebula-card-back img").first()).toHaveAttribute("src", "/static/img/cards/stardust/back.webp");
|
||
await expect(partner.locator(".nebula-opening-odds")).toContainText("50 % des légendaires et mythiques tirées viennent de Poussières d'étoiles");
|
||
await partner.getByRole("button", { name: "Tout révéler" }).click();
|
||
await expect(partner.getByRole("button", { name: "Retour", exact: true })).toBeVisible({ timeout: 30_000 });
|
||
// Ce paquet se paie en poussière : il ne propose pas de continuer sur une ouverture.
|
||
await expect(partner.getByRole("button", { name: "Ouvrir un autre paquet de la même collection", exact: true })).toHaveCount(0);
|
||
await partner.getByRole("button", { name: "Retour", exact: true }).click({ timeout: 30_000 });
|
||
// « Retour » ramène aux articles de la boutique, sans passer par Paquets.
|
||
await expect(partner).toHaveURL(/#\/cards\/shop$/);
|
||
await expect(packItem).toBeVisible();
|
||
await expect(partner.locator(".nebula-shop-wallet")).toContainText("440");
|
||
// Plusieurs ouvertures d'un coup : le maximum suit la poussière (440 au prix affiché), la saisie y est ramenée.
|
||
const openingItem = partner.locator('.nebula-shop-item[data-item="opening"]');
|
||
const openingPrice = Number((await openingItem.locator(".nebula-shop-item-rate .nebula-stardust").textContent()).replace(/\D/g, ""));
|
||
const openingMax = Math.floor(440 / openingPrice);
|
||
expect(openingMax).toBeGreaterThan(2);
|
||
const openingCount = openingItem.getByRole("spinbutton", { name: "Ouvertures à acheter", exact: true });
|
||
// Vide au départ, le maximum en indication ; vide, il vaut un seul achat.
|
||
await expect(openingCount).toHaveValue("");
|
||
await expect(openingCount).toHaveAttribute("placeholder", `max. ${openingMax}`);
|
||
await expect(openingItem.getByRole("button", { name: `Acheter · ${openingPrice} poussières`, exact: true })).toBeVisible();
|
||
await openingCount.fill("500");
|
||
await expect(openingCount).toHaveValue(String(openingMax));
|
||
await openingCount.fill("2");
|
||
await openingItem.getByRole("button", { name: `Acheter · ${2 * openingPrice} poussières`, exact: true }).click();
|
||
await expect(partner.getByRole("status").filter({ hasText: "2 ouvertures achetées" })).toBeVisible();
|
||
await expect(partner.locator(".nebula-shop-wallet")).toContainText(String(440 - 2 * openingPrice));
|
||
await expect(openingCount).toHaveAttribute("placeholder", `max. ${Math.floor((440 - 2 * openingPrice) / openingPrice)}`);
|
||
await expect(openingCount).toHaveValue("");
|
||
await partnerContext.close();
|
||
});
|
||
|
||
test("administrator previews the mythic opening from a base without any mythic variation", async ({ page }) => {
|
||
await page.route("**/api/cards/config*", async (route) => {
|
||
const response = await route.fetch();
|
||
const json = await response.json();
|
||
json.catalog.editions = json.catalog.editions.filter((edition) => edition.rarity !== "mythic");
|
||
await route.fulfill({ response, json });
|
||
});
|
||
await page.goto("/#/cards/admin");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await page.getByRole("link", { name: "Atelier visuel" }).click();
|
||
const mythicPreview = page.locator(".nebula-admin-opening-effect-card").filter({ has: page.getByRole("heading", { name: "Mythique", exact: true }) });
|
||
await expect(mythicPreview.locator(".nebula-admin-style-preview > span")).toHaveText(/^Aperçu · .+ — Prisme spectral — /);
|
||
await mythicPreview.getByRole("button", { name: "Révéler la carte Mythique", exact: true }).click();
|
||
await expect(mythicPreview.locator(".nebula-card-particles i").first()).toBeAttached();
|
||
});
|
||
|
||
test("a player reads the privacy notice and deletes the account for good", async ({ browser, page }) => {
|
||
test.setTimeout(60_000);
|
||
const cachedSnapshots = () => page.evaluate(() => new Promise((resolve, reject) => {
|
||
const request = globalThis.indexedDB.open("sokkog-nebula-cards", 1);
|
||
request.onerror = () => reject(request.error);
|
||
request.onsuccess = () => {
|
||
const count = request.result.transaction("snapshots").objectStore("snapshots").count();
|
||
count.onsuccess = () => { request.result.close(); resolve(count.result); };
|
||
count.onerror = () => reject(count.error);
|
||
};
|
||
}));
|
||
const login = page.getByRole("button", { name: "Version développement", exact: true });
|
||
await page.goto("/#/cards");
|
||
// Le lien est hors du panneau de connexion, centré sous lui ; déplié, la notice a son propre panneau en dessous.
|
||
const privacyToggle = page.getByRole("button", { name: "Confidentialité de Sokko TCG", exact: true });
|
||
await expect(page.locator(".nebula-login .nebula-privacy-toggle")).toHaveCount(0);
|
||
const loginBox = await page.locator(".nebula-login").boundingBox();
|
||
const toggleBox = await privacyToggle.boundingBox();
|
||
expect(toggleBox.y).toBeGreaterThanOrEqual(loginBox.y + loginBox.height);
|
||
expect(toggleBox.x + toggleBox.width / 2).toBeCloseTo(loginBox.x + loginBox.width / 2, 0);
|
||
const privacyPanel = page.locator(".nebula-login-privacy");
|
||
await expect(privacyToggle).toHaveAttribute("aria-expanded", "false");
|
||
await expect(privacyPanel).toHaveCount(0);
|
||
// Au survol, seul le texte s'éclaircit : il ne reprend pas le fond des boutons du site.
|
||
await privacyToggle.hover();
|
||
await expect(privacyToggle).toHaveCSS("background-image", "none");
|
||
await expect(privacyToggle).toHaveCSS("box-shadow", "none");
|
||
await privacyToggle.click();
|
||
await expect(privacyToggle).toHaveAttribute("aria-expanded", "true");
|
||
await expect(page.locator(".nebula-login .nebula-privacy-notice")).toHaveCount(0);
|
||
await expect(privacyPanel.getByRole("link", { name: "privacy@example.invalid" })).toHaveAttribute("href", "mailto:privacy@example.invalid");
|
||
await expect(privacyPanel).toContainText("Exploitant E2E");
|
||
await expect(privacyPanel).toContainText("24 mois");
|
||
// Le panneau suit le lien et ne passe pas sous la barre du haut quand la page défile jusqu'à lui.
|
||
const panelBox = await privacyPanel.boundingBox();
|
||
const openToggleBox = await privacyToggle.boundingBox();
|
||
expect(panelBox.y).toBeGreaterThan(openToggleBox.y);
|
||
expect(panelBox.y).toBeGreaterThanOrEqual((await page.locator(".topbar").boundingBox()).height);
|
||
await privacyToggle.click();
|
||
await expect(privacyPanel).toHaveCount(0);
|
||
await login.click();
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Compte", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Compte", exact: true })).toBeVisible();
|
||
await expect(page.locator(".nebula-account-summary dd").first()).toHaveText("Version développement");
|
||
await expect(page.locator(".nebula-account").getByRole("link", { name: "privacy@example.invalid" })).toBeVisible();
|
||
await expect.poll(cachedSnapshots).toBe(1);
|
||
|
||
const deleteButton = page.getByRole("button", { name: "Supprimer mon compte", exact: true });
|
||
await deleteButton.click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Annuler", exact: true }).click();
|
||
await expect(page.getByRole("dialog")).toHaveCount(0);
|
||
await expect(page.getByRole("heading", { name: "Compte", exact: true })).toBeVisible();
|
||
await deleteButton.click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Supprimer définitivement", exact: true }).click();
|
||
await expect(page.getByRole("status")).toContainText("Votre compte a bien été supprimé.");
|
||
await expect(page).toHaveURL(/#\/cards$/);
|
||
await expect(login).toBeVisible();
|
||
expect(await cachedSnapshots()).toBe(0);
|
||
|
||
const { token } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-partner.json"), "utf8"));
|
||
const partnerContext = await browser.newContext({ baseURL: "http://127.0.0.1:4180" });
|
||
await partnerContext.addCookies([{ name: "__Host-sokkog_cards_session", value: token, domain: "127.0.0.1", path: "/", secure: true, httpOnly: true, sameSite: "Lax" }]);
|
||
const partnerPage = await partnerContext.newPage();
|
||
await partnerPage.goto("http://127.0.0.1:4180/");
|
||
const { traders } = await partnerPage.evaluate(() => globalThis.fetch("/api/cards/traders").then((response) => response.json()));
|
||
expect(traders.map((trader) => trader.displayName)).not.toContain("Version développement");
|
||
await partnerContext.close();
|
||
|
||
// Une nouvelle connexion repart d'un compte neuf, et la déconnexion ne laisse aucune copie dans le navigateur.
|
||
await login.click();
|
||
await expect(page.locator('.nebula-opening-reserve[aria-label="Ouvertures disponibles"] .nebula-opening-reserve-value')).toContainText("3/ 5");
|
||
await expect.poll(cachedSnapshots).toBe(1);
|
||
await page.getByRole("button", { name: "Déconnexion", exact: true }).click();
|
||
await expect(login).toBeVisible();
|
||
expect(await cachedSnapshots()).toBe(0);
|
||
});
|
||
|
||
test("the about page mentions the game while it is enabled", async ({ page }) => {
|
||
await page.goto("/#/about");
|
||
await expect(page.locator(".about-page .nds-page-hero")).toContainText("Seul le mini-jeu Sokko TCG utilise un compte Discord");
|
||
});
|
||
|
||
test("the shop pack rates count the cards it draws from the other collections", async ({ page }) => {
|
||
await page.goto("/#/cards/admin/collections/stardust");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
const rates = page.locator(".nebula-admin-drop-table");
|
||
await expect(rates).toBeVisible();
|
||
await expect(rates.locator("[role=status]")).toHaveCount(0);
|
||
const commonRow = rates.locator('tr[data-rarity="common"]');
|
||
await expect(commonRow.locator("td").nth(2)).not.toHaveText("0");
|
||
await expect(commonRow.locator("td").nth(3)).toHaveText("—");
|
||
// Sa page rappelle d'où il tire ses cartes et règle la part de ses propres légendaires et mythiques.
|
||
const content = page.getByRole("region", { name: "Contenu du paquet", exact: true });
|
||
await expect(content).toContainText("Collections ouvertes");
|
||
await expect(content).toContainText(/\d+ légendaires? et \d+ mythiques?/);
|
||
await expect(content.getByRole("spinbutton", { name: "Part de ses cartes parmi les légendaires et mythiques (%)" })).toHaveValue("50");
|
||
});
|
||
|
||
test("a player chains packs of the same collection while openings remain", async ({ page }) => {
|
||
test.setTimeout(60_000);
|
||
const openAnother = page.getByRole("button", { name: "Ouvrir un autre paquet de la même collection", exact: true });
|
||
const revealAll = page.getByRole("button", { name: "Tout révéler" });
|
||
const back = page.getByRole("button", { name: "Retour", exact: true });
|
||
const pendingCollection = () => page.evaluate(async () => (await globalThis.fetch("/api/cards/state")).json().then((state) => state.pendingOpening?.collectionId ?? null));
|
||
// Fait croire au client que le solde a changé à la fin de l'ouverture : le compte de développement a une réserve figée.
|
||
const stubBalance = (openingsBalance, purchasedOpenings) => page.route("**/api/cards/openings/*/complete", async (route) => {
|
||
const response = await route.fetch();
|
||
const state = await response.json();
|
||
await route.fulfill({ response, json: { ...state, recharge: { ...state.recharge, openingsBalance }, wallet: { ...state.wallet, purchasedOpenings } } });
|
||
});
|
||
|
||
await page.goto("/#/cards/packs");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await page.getByRole("button", { name: "Ouvrir ce paquet : Genèse Astrale", exact: true }).click();
|
||
await expect(revealAll).toBeVisible();
|
||
await expect(openAnother).toHaveCount(0);
|
||
// L'étape rappelle ce qu'il reste à ouvrir, en séparant la recharge automatique des ouvertures achetées.
|
||
const balances = await page.evaluate(async () => (await globalThis.fetch("/api/cards/state")).json().then((state) => [state.recharge.openingsBalance, state.wallet.purchasedOpenings]));
|
||
const remaining = page.getByRole("definition");
|
||
await expect(page.getByRole("term")).toHaveText(["Recharge auto", "À l’unité"]);
|
||
await expect(remaining).toHaveText(balances.map(String));
|
||
await revealAll.click();
|
||
await expect(openAnother).toBeEnabled();
|
||
await expect.poll(pendingCollection).toBeNull();
|
||
// Le libellé long tient à la largeur minimale, à côté de « Retour ».
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
await expect(openAnother).toBeVisible();
|
||
expect(await page.evaluate(() => globalThis.document.documentElement.scrollWidth <= globalThis.document.documentElement.clientWidth)).toBe(true);
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
|
||
// Le nouveau paquet vient de la même collection, et le clavier reprend sur « Tout révéler ».
|
||
await openAnother.click();
|
||
await expect(page.getByRole("button", { name: "Révéler la carte" })).toHaveCount(3);
|
||
await expect(page.locator('.nebula-card-back img[src="/static/img/cards/astral-genesis/back.webp"]')).toHaveCount(3);
|
||
await expect.poll(pendingCollection).toBe("astral-genesis");
|
||
await expect(revealAll).toBeFocused();
|
||
|
||
// Réserve vide mais ouverture achetée : l'enchaînement utilise l'achetée ; le refus du serveur laisse les cartes et l'action en place.
|
||
await stubBalance(0, 1);
|
||
const openRequest = page.waitForRequest((request) => request.method() === "POST" && request.url().endsWith("/api/cards/openings"));
|
||
await revealAll.click();
|
||
await expect(openAnother).toBeEnabled();
|
||
await expect(remaining).toHaveText(["0", "1"]);
|
||
await openAnother.click();
|
||
expect((await openRequest).postDataJSON()).toEqual({ collectionId: "astral-genesis", purchased: true });
|
||
await expect(page.getByRole("alert")).toContainText("aucune ouverture achetée");
|
||
await expect(page.locator('.nebula-opening-cards .nebula-card[data-card-size="lg"]')).toHaveCount(3);
|
||
await expect(openAnother).toBeEnabled();
|
||
|
||
// Plus aucune ouverture : seul le retour reste proposé.
|
||
await page.unroute("**/api/cards/openings/*/complete");
|
||
await back.click();
|
||
await page.reload();
|
||
await page.getByRole("button", { name: "Ouvrir ce paquet : Genèse Astrale", exact: true }).click();
|
||
await stubBalance(0, 0);
|
||
await revealAll.click();
|
||
await expect(back).toBeEnabled();
|
||
await expect(openAnother).toHaveCount(0);
|
||
});
|
||
|
||
// Une relecture partie au retour sur la page peut répondre après une mutation : l'état plus ancien qu'elle décrit ne doit pas
|
||
// remplacer celui de la mutation à l'écran.
|
||
test("a late state reload does not undo a favourite already confirmed", async ({ page }) => {
|
||
await page.goto("/#/cards/collection");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await page.locator(".nebula-album-entry:not([data-missing]) button").first().click();
|
||
const dialog = page.getByRole("dialog");
|
||
const add = dialog.getByRole("button", { name: "Ajouter aux favoris" });
|
||
const remove = dialog.getByRole("button", { name: "Retirer des favoris" });
|
||
if (await remove.isVisible()) await remove.click();
|
||
await expect(add).toBeEnabled();
|
||
|
||
let reloads = 0;
|
||
let releaseReload;
|
||
const reloadHeld = new Promise((resolvePromise) => { releaseReload = resolvePromise; });
|
||
await page.route("**/api/cards/state", async (route) => {
|
||
reloads += 1;
|
||
const response = await route.fetch();
|
||
await reloadHeld;
|
||
await route.fulfill({ response });
|
||
});
|
||
// Le focus et visibilitychange arrivent ensemble au retour sur l'onglet : une seule lecture part.
|
||
await page.evaluate(() => {
|
||
globalThis.dispatchEvent(new globalThis.Event("focus"));
|
||
globalThis.document.dispatchEvent(new globalThis.Event("visibilitychange"));
|
||
});
|
||
await expect.poll(() => reloads).toBe(1);
|
||
|
||
await add.click();
|
||
await expect(remove).toHaveAttribute("aria-pressed", "true");
|
||
releaseReload();
|
||
await page.waitForResponse("**/api/cards/state");
|
||
await page.unroute("**/api/cards/state");
|
||
await expect(remove).toHaveAttribute("aria-pressed", "true");
|
||
expect(reloads).toBe(1);
|
||
|
||
await remove.click();
|
||
await expect(add).toHaveAttribute("aria-pressed", "false");
|
||
});
|
||
|
||
test("the Sokko TCG menu entry shows a count while the opening reserve is full", async ({ page }) => {
|
||
const cardsLink = page.getByRole("navigation", { name: "Navigation principale" }).getByRole("link", { name: /^Sokko TCG/ });
|
||
const count = cardsLink.locator(".nav-icon-count");
|
||
// Visiteur sans compte : aucune pastille.
|
||
await page.goto("/#/toolboxes");
|
||
await expect(cardsLink).toHaveAccessibleName("Sokko TCG");
|
||
await expect(count).toHaveCount(0);
|
||
|
||
await page.goto("/#/cards");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await expect(page.getByRole("heading", { name: "Sokko TCG", exact: true })).toBeVisible();
|
||
// Le compte de développement garde une réserve juste sous le maximum : la route est simulée pleine.
|
||
await page.route("**/api/cards/reserve", (route) => route.fulfill({ json: { recharge: { openingsBalance: 5, rechargeAnchor: null, nextOpeningAt: null } } }));
|
||
await page.goto("/#/toolboxes");
|
||
await page.reload();
|
||
await expect(count).toHaveText("5");
|
||
await expect(cardsLink).toHaveAccessibleName("Sokko TCG (réserve d’ouvertures pleine)");
|
||
const [icon, badge] = await Promise.all([cardsLink.locator(".nav-icon").boundingBox(), count.boundingBox()]);
|
||
expect(badge.x).toBeGreaterThan(icon.x + icon.width / 2);
|
||
expect(badge.y).toBeLessThan(icon.y + icon.height / 2);
|
||
// En sidebar compacte, la pastille reste sur l'icône seule.
|
||
await page.setViewportSize({ width: 900, height: 800 });
|
||
await expect(count).toBeVisible();
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
|
||
// Sur la page de jeu, l'état réel (réserve non pleine) remplace aussitôt la valeur relue par le menu.
|
||
await page.getByRole("navigation", { name: "Navigation principale" }).getByRole("link", { name: /^Sokko TCG/ }).click();
|
||
await expect(page.locator(".nebula-opening-reserve")).toBeVisible();
|
||
await expect(count).toHaveCount(0);
|
||
await expect(cardsLink).toHaveAccessibleName("Sokko TCG");
|
||
});
|
||
|
||
// En dernier : une victoire crédite la poussière du compte de développement, dont les parcours précédents vérifient le solde.
|
||
test("a player finds the daily card with hints and copies the result", async ({ context, page }) => {
|
||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||
await page.goto("/#/cards");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
// La Guilde des Veilleurs a son entrée de menu, avec le nombre de quêtes en attente, et son bandeau sur l'Accueil, entièrement visible en 1280 × 720.
|
||
const sections = page.getByRole("navigation", { name: "Sections de Sokko TCG" });
|
||
await expect(sections.getByRole("link")).toHaveText(["Accueil", "Guilde1", "Paquets", "Collection", "Boutique", "Échanges et dons", "Historique", "Compte"]);
|
||
await expect(sections.getByRole("link", { name: /^Guilde/ })).toHaveAttribute("href", "#/cards/guild");
|
||
await expect(sections.locator('a[href="#/cards/daily"]')).toHaveCount(0);
|
||
const guildBanner = page.getByRole("region", { name: "Guilde des Veilleurs", exact: true });
|
||
await expect(guildBanner).toBeInViewport({ ratio: 1 });
|
||
await expect(guildBanner).toContainText("1 quête vous attend.");
|
||
await guildBanner.getByRole("link", { name: "Accéder aux missions", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/guild$/);
|
||
await expect(page.getByRole("heading", { name: "Guilde des Veilleurs", exact: true })).toBeVisible();
|
||
await expect(sections.getByRole("link", { name: /^Guilde/ })).toHaveAttribute("aria-current", "page");
|
||
const quest = page.getByRole("article", { name: "Carte du jour" });
|
||
// La tuile n'écrit pas son état : à faire, pas de pancarte et le bouton « Jouer ».
|
||
await expect(quest.locator('.nebula-quest-sign[data-kind="done"]')).toHaveCount(0);
|
||
await quest.getByRole("link", { name: "Jouer", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/daily$/);
|
||
await expect(sections.getByRole("link", { name: /^Guilde/ })).toHaveAttribute("aria-current", "page");
|
||
await expect(page.getByRole("link", { name: "Retour à la Guilde", exact: true })).toHaveAttribute("href", "#/cards/guild");
|
||
|
||
// L'illustration arrive en blob, sans adresse qui nommerait la carte : seulement la zone visible, recadrée et agrandie par
|
||
// le serveur (720 px de large), sans agrandissement CSS à défaire.
|
||
const image = page.getByRole("img", { name: "Illustration de la Carte du jour, agrandie" });
|
||
await expect(image).toHaveAttribute("src", /^blob:/);
|
||
await expect.poll(() => image.evaluate((element) => element.naturalWidth)).toBe(720);
|
||
await expect(image).toHaveCSS("transform", "none");
|
||
const firstCrop = await image.getAttribute("src");
|
||
|
||
// Chaque joueur a sa propre carte, que l'API ne donne qu'en fin de partie : le parcours la lit dans la base du serveur E2E.
|
||
const { path: databasePath } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-db.json"), "utf8"));
|
||
const database = new DatabaseSync(databasePath, { readOnly: true });
|
||
const { card_id: answerId } = database.prepare("SELECT attempt.card_id FROM daily_attempts AS attempt JOIN players ON players.id = attempt.player_id WHERE players.discord_id = 'dev-admin' ORDER BY attempt.day DESC LIMIT 1").get();
|
||
database.close();
|
||
const { answer, wrong } = await page.evaluate(async (answerCardId) => {
|
||
const [config, daily] = await Promise.all(["/api/cards/config", "/api/cards/daily"].map(async (path) => (await globalThis.fetch(path)).json()));
|
||
const cards = config.catalog.cards;
|
||
const answerCard = cards.find((card) => card.id === answerCardId);
|
||
const wrongCard = cards.find((card) => card.id !== answerCard.id && card.id !== "starlit-ice-penguin" && daily.collectionIds.includes(card.collectionId));
|
||
return { answer: answerCard.name, wrong: wrongCard.name };
|
||
}, answerId);
|
||
|
||
// Aucun indice avant le premier essai raté.
|
||
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: "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" })).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");
|
||
// 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-track li[data-result="${close ? "close" : "miss"}"]`)).toHaveCount(1);
|
||
|
||
// 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-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);
|
||
// 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();
|
||
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 propose.click();
|
||
const result = page.locator(".nebula-daily-result");
|
||
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();
|
||
const copied = await page.evaluate(() => globalThis.navigator.clipboard.readText());
|
||
expect(copied).toBe(`Sokko TCG · Carte du jour #1 · 2/6 · 💡1\n${close ? "🟨" : "⬛"}🟩\nhttp://127.0.0.1:4180/#/cards/daily`);
|
||
|
||
// En demi-écran, la page passe sur une colonne sans défilement horizontal ; le menu replié nomme la Guilde, la quête étant terminée.
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-half.png"), fullPage: true });
|
||
await expect(selectTrigger(page, "Sections de Sokko TCG")).toHaveText("Sections de Sokko TCG : Guilde");
|
||
const overflow = await page.evaluate(() => [".nebula-dashboard-menu", ".nebula-daily"].map((selector) => {
|
||
const element = globalThis.document.querySelector(selector);
|
||
return element.scrollWidth - element.clientWidth;
|
||
}));
|
||
expect(overflow).toEqual([0, 0]);
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
|
||
// L'administration règle la récompense dans sa section Guilde, avec la partie du jour.
|
||
await page.goto("/#/cards/admin/guild");
|
||
const dailySettings = page.getByRole("region", { name: "Carte du jour", exact: true });
|
||
await expect(dailySettings).toContainText("1 gagnant sur 1 joueur aujourd’hui.");
|
||
await expect(dailySettings.getByRole("spinbutton", { name: "Récompense d’une victoire" })).toHaveValue("10");
|
||
await page.goto("/#/cards");
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Historique", exact: true }).click();
|
||
await expect(page.locator(".nebula-history-list li").filter({ hasText: "Carte du jour trouvée" })).toContainText("· 2/6 · +10 poussières d’étoiles");
|
||
// La quête terminée n'attend plus : le bandeau l'annonce, et la tuile de la Guilde porte la pancarte « Fait ».
|
||
await page.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Accueil", exact: true }).click();
|
||
await expect(guildBanner).toContainText("Aucune quête ne vous attend pour le moment.");
|
||
await guildBanner.getByRole("link", { name: "Accéder aux missions", exact: true }).click();
|
||
await expect(quest.locator('.nebula-quest-sign[data-kind="done"]')).toHaveText(/Fait$/);
|
||
await expect(quest.locator(".nebula-quest-status")).toHaveCount(0);
|
||
await expect(quest.locator(".nebula-quest-media .nds-badge")).toHaveText("Série : 1 jour");
|
||
await expect(quest.getByRole("link", { name: "Voir le résultat", exact: true })).toBeVisible();
|
||
});
|
||
|
||
// Dernier parcours : il ouvre les Expéditions et décale l'horloge du serveur, deux réglages globaux qu'il remet en place à la fin.
|
||
test("an administrator opens expeditions and a player leaves alone, follows the journey, then claims its loot", async ({ browser, page }) => {
|
||
// Le suivi d'un groupe depuis un second écran, puis par son créateur quand un joueur rejoint, attend les relectures périodiques de
|
||
// la vue (jusqu'à 20 s chacune).
|
||
test.setTimeout(180_000);
|
||
const clockFile = join(tmpdir(), "sokkog-cards-e2e-clock.json");
|
||
const setServerClock = (offsetMs) => writeFile(clockFile, JSON.stringify({ offsetMs }));
|
||
await setServerClock(0);
|
||
await page.goto("/#/cards");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
// La Guilde range ses quêtes en onglets ; les Expéditions s'ouvrent depuis leur bandeau d'état, sans passer par le brouillon.
|
||
await page.goto("/#/cards/admin/guild");
|
||
await page.getByRole("tab", { name: "Expéditions", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/admin\/guild\/expeditions$/);
|
||
const status = page.getByRole("region", { name: /^Expéditions (Ouvertes|Fermées) aux joueurs$/ });
|
||
await expect(status).toContainText("Fermées aux joueurs");
|
||
await status.getByRole("button", { name: "Ouvrir les Expéditions", exact: true }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Ouvrir", exact: true }).click();
|
||
await expect(status).toContainText("Ouvertes aux joueurs");
|
||
const adminDestinations = page.getByRole("region", { name: "Destinations", exact: true });
|
||
await expect(adminDestinations.getByRole("listitem")).toHaveCount(18);
|
||
await expect(adminDestinations.getByText("Le Grand Salon Astral", { exact: true })).toBeVisible();
|
||
// Le prix d'un Éclat n'est plus dans les réglages des Expéditions : il se règle dans la Boutique.
|
||
await page.getByRole("tab", { name: "Cartes", exact: true }).click();
|
||
await expect(page.getByRole("region", { name: "Améliorations", exact: true })).not.toContainText("Éclat d’étoile en boutique");
|
||
await page.getByRole("tab", { name: "Déroulement", exact: true }).click();
|
||
// Un réglage touché s'annonce dans son onglet et dans la barre commune, qui l'annule.
|
||
const perDay = page.getByRole("region", { name: "Général", exact: true }).getByRole("spinbutton", { name: "Destinations proposées par jour", exact: true });
|
||
await perDay.fill("5");
|
||
await expect(page.getByRole("tab", { name: "Déroulement (1)", exact: true })).toBeVisible();
|
||
const applyBar = page.getByRole("region", { name: "Modifications en attente", exact: true });
|
||
await expect(applyBar).toContainText("1 réglage modifié");
|
||
await applyBar.getByRole("button", { name: "Annuler les modifications", exact: true }).click();
|
||
await expect(applyBar).toHaveCount(0);
|
||
await expect(perDay).toHaveValue("4");
|
||
|
||
// Le partenaire possède deux légendaires distinctes : une suffit pour partir.
|
||
const { token } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-partner.json"), "utf8"));
|
||
const partnerContext = await browser.newContext({ baseURL: "http://127.0.0.1:4180", viewport: { width: 1280, height: 900 } });
|
||
await partnerContext.addCookies([{ name: "__Host-sokkog_cards_session", value: token, domain: "127.0.0.1", path: "/", secure: true, httpOnly: true, sameSite: "Lax" }]);
|
||
const partner = await partnerContext.newPage();
|
||
await partner.goto("/#/cards/guild");
|
||
const quest = partner.getByRole("article", { name: "Expéditions" });
|
||
await expect(quest).toContainText("De nouvelles destinations vous attendent.");
|
||
await quest.getByRole("link", { name: "Préparer", exact: true }).click();
|
||
await expect(partner).toHaveURL(/#\/cards\/expeditions$/);
|
||
await expect(partner.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: /^Guilde/ })).toHaveAttribute("aria-current", "page");
|
||
|
||
const destinations = partner.getByRole("region", { name: "1. Destination du jour" }).getByRole("button");
|
||
await expect(destinations).toHaveCount(4);
|
||
await expect(destinations.first()).toHaveAttribute("aria-pressed", "true");
|
||
// La difficulté est tirée avec les destinations : une de chaque niveau, 1 à 4 étoiles, seul ou en groupe. On prend la plus facile.
|
||
for (const stars of ["1 étoile", "2 étoiles", "3 étoiles", "4 étoiles"]) await expect(destinations.filter({ has: partner.getByRole("img", { name: `Difficulté : ${stars}`, exact: true }) })).toHaveCount(1);
|
||
const easiest = destinations.filter({ has: partner.getByRole("img", { name: "Difficulté : 1 étoile", exact: true }) });
|
||
await easiest.click();
|
||
// Chaque destination montre ses exigences pour une carte seule, une étoile sur la stat principale.
|
||
await expect(easiest.locator(".nebula-destination-requirement[data-main] .nebula-main-stat-mark")).toHaveCount(1);
|
||
await expect(easiest.locator(".nebula-destination-requirement[data-met]")).toHaveCount(0);
|
||
// Une seule carte, avec son rôle ; plus de choix entre solo et groupe.
|
||
await expect(partner.getByRole("group", { name: "Mode" })).toHaveCount(0);
|
||
const team = partner.getByRole("region", { name: "2. Votre explorateur" });
|
||
// La carte se choisit dans une fenêtre, depuis l'emplacement vide du cadre.
|
||
await team.getByRole("button", { name: "Choisir un explorateur", exact: true }).click();
|
||
const picker = partner.getByRole("dialog", { name: "Choisir l’explorateur" });
|
||
await picker.getByRole("group", { name: "Trier par" }).getByRole("button", { name: "Puissance", exact: true }).click();
|
||
await picker.getByRole("button", { name: /^Choisir Loup des Aurores$/ }).click();
|
||
await expect(picker).toHaveCount(0);
|
||
// La carte choisie : ses stats pour l'expédition et son équipement ; les exigences se colorent selon elle.
|
||
await expect(team.locator(".nebula-expedition-loadout")).toContainText("Loup des Aurores");
|
||
await expect(team.locator(".nebula-expedition-loadout").getByRole("list", { name: "Équipements", exact: true }).getByRole("listitem")).toHaveCount(3);
|
||
await expect(easiest.locator(".nebula-destination-requirement[data-met]")).toHaveCount(1);
|
||
const settings = partner.getByRole("region", { name: "3. Durée et départ" });
|
||
await settings.getByRole("button", { name: "2 h", exact: true }).click();
|
||
await expect(settings.locator(".nebula-expected-loot")).toContainText(/≈ [\d,]+ Éclats/);
|
||
await expect(settings.locator(".nebula-expedition-preview .nds-badge").first()).toHaveText(/^(Retour difficile|Réussite|Triomphe)$/);
|
||
await settings.getByRole("button", { name: "Partir seul maintenant", exact: true }).click();
|
||
await expect(partner.getByRole("status").filter({ hasText: "Expédition partie !" })).toBeVisible();
|
||
// En route : la préparation laisse place au voyage, avec sa barre de progression et les cartes parties.
|
||
const journey = partner.locator(".nebula-expedition-journey");
|
||
await expect(journey).toContainText(/En route, retour dans (1 h|2 h)/);
|
||
await expect(journey.getByRole("progressbar", { name: "Progression du voyage" })).toBeVisible();
|
||
await expect(journey.locator(".nebula-expedition-caravan li")).toHaveCount(1);
|
||
await expect(partner.getByRole("region", { name: "1. Destination du jour" })).toHaveCount(0);
|
||
|
||
// En demi-écran, la page reste sans défilement horizontal.
|
||
await partner.setViewportSize({ width: 768, height: 900 });
|
||
expect(await partner.locator(".nebula-expeditions").evaluate((element) => element.scrollWidth - element.clientWidth)).toBe(0);
|
||
await partner.setViewportSize({ width: 1280, height: 900 });
|
||
// Dans la Guilde, le bouton de la tuile suit l'expédition : « En cours » tant qu'elle est en route.
|
||
await partner.goto("/#/cards/guild");
|
||
await expect(quest.getByRole("link")).toHaveText("En cours");
|
||
|
||
// Trois heures plus tard pour le serveur : l'expédition est revenue, la tuile mène au butin. Il s'affiche sur place, sans rappel
|
||
// du résultat, et se récupère d'un clic, qui retire la carte et confirme par un avis.
|
||
await setServerClock(3 * 3_600_000);
|
||
await partner.reload();
|
||
await quest.getByRole("link", { name: "Récupérer le butin", exact: true }).click();
|
||
await expect(partner).toHaveURL(/#\/cards\/expeditions$/);
|
||
const report = partner.locator(".nebula-expedition-return").first();
|
||
await expect(report).toContainText("De retour ! Le butin vous attend.");
|
||
await expect(report.getByRole("definition")).toHaveCount(0);
|
||
const loot = report.getByRole("region", { name: "Butin rapporté", exact: true });
|
||
await expect(loot.getByRole("listitem").filter({ hasText: /^\+[\d\s]+ Éclats$/ })).toBeVisible();
|
||
await report.getByRole("button", { name: "Récupérer le butin", exact: true }).click();
|
||
await expect(partner.locator(".nebula-expeditions > .nds-inline-notice[role=status]")).toHaveText("Butin récupéré : il est dans votre collection.");
|
||
await expect(partner.locator(".nebula-expedition-return")).toHaveCount(0);
|
||
await expect(partner.locator(".nebula-expeditions .nds-section-heading .nds-badge")).not.toHaveText("0 Éclats d’étoile");
|
||
// L'expédition terminée passe au Journal.
|
||
await partner.getByRole("tab", { name: "Journal (1)", exact: true }).click();
|
||
await expect(partner.getByRole("region", { name: "Expéditions terminées", exact: true }).locator(".nebula-expedition-report")).toContainText("Butin récupéré.");
|
||
await expect(partner.getByRole("region", { name: /^Grimoire/ })).toHaveCount(0);
|
||
await partner.getByRole("tab", { name: "Préparer", exact: true }).click();
|
||
|
||
// Ouverte au groupe, l'expédition attend d'autres joueurs, avec son lien d'invitation ; son créateur peut l'annuler.
|
||
await partner.getByRole("region", { name: "2. Votre explorateur" }).getByRole("button", { name: "Choisir un explorateur", exact: true }).click();
|
||
await partner.getByRole("dialog", { name: "Choisir l’explorateur" }).getByRole("button", { name: /^Choisir Loup des Aurores$/ }).click();
|
||
await expect(partner.getByRole("region", { name: "3. Durée et départ" })).toContainText(/≈ [\d,]+ Éclats/);
|
||
await partner.getByRole("button", { name: "Ouvrir au groupe", exact: true }).click();
|
||
await expect(partner.getByRole("status").filter({ hasText: "Expédition ouverte !" })).toBeVisible();
|
||
const mine = partner.getByRole("region", { name: "Votre expédition en préparation" });
|
||
const groupCard = mine.locator(".nebula-expedition-group");
|
||
await expect(groupCard).toContainText("ouvert par vous");
|
||
await expect(groupCard.locator(".nebula-expedition-group-free")).toHaveCount(3);
|
||
await expect(groupCard.getByRole("textbox", { name: /^Lien d’invitation/ })).toHaveValue(/#\/cards\/expeditions\/[\w-]+$/);
|
||
// Un second écran sur la même page suit le groupe sans être rechargé : il voit l'annulation, puis un nouveau groupe et son départ.
|
||
// Son premier chargement échoue : l'erreur propose « Réessayer », qui rétablit la page.
|
||
const watcher = await partnerContext.newPage();
|
||
let failures = 1;
|
||
await watcher.route("**/api/cards/expeditions", (route) => (route.request().method() === "GET" && failures-- > 0
|
||
? route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ error: { code: "UNAVAILABLE", message: "Service indisponible." } }) })
|
||
: route.continue()));
|
||
await watcher.goto("/#/cards/expeditions");
|
||
await expect(watcher.getByRole("alert")).toContainText("Service indisponible.");
|
||
await watcher.getByRole("button", { name: "Réessayer", exact: true }).click();
|
||
const watched = watcher.getByRole("region", { name: "Votre expédition en préparation" });
|
||
await expect(watched).toBeVisible();
|
||
await groupCard.getByRole("button", { name: "Annuler l’expédition", exact: true }).click();
|
||
await expect(mine).toHaveCount(0);
|
||
await expect(partner.getByRole("region", { name: "1. Destination du jour" })).toBeVisible();
|
||
await expect(watched).toHaveCount(0, { timeout: 15_000 });
|
||
await partner.getByRole("region", { name: "2. Votre explorateur" }).getByRole("button", { name: "Choisir un explorateur", exact: true }).click();
|
||
await partner.getByRole("dialog", { name: "Choisir l’explorateur" }).getByRole("button", { name: /^Choisir Loup des Aurores$/ }).click();
|
||
await partner.getByRole("button", { name: "Ouvrir au groupe", exact: true }).click();
|
||
await expect(watched).toBeVisible({ timeout: 30_000 });
|
||
// Un autre joueur rejoint : il choisit sa carte dans le même cadre que la préparation, avec ses équipements, puis se dit prêt ; le
|
||
// créateur voit son état passer de « En préparation » à « Prêt ».
|
||
const { path: groupDatabasePath } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-db.json"), "utf8"));
|
||
const groupDatabase = new DatabaseSync(groupDatabasePath);
|
||
groupDatabase.prepare(`INSERT INTO collection_cards(player_id, edition_id, quantity, acquired_at) SELECT id, 'crimson-moon-kitsune-standard', 1, 0 FROM players WHERE discord_id = 'dev-admin'
|
||
ON CONFLICT(player_id, edition_id) DO NOTHING`).run();
|
||
groupDatabase.prepare("INSERT INTO player_items(player_id, item_id, quantity) SELECT id, 'guideStar', 1 FROM players WHERE discord_id = 'dev-admin'").run();
|
||
groupDatabase.close();
|
||
await page.goto("/#/cards/expeditions");
|
||
// Première visite de ce joueur : la Guilde lui offre d'abord sa carte de destination de départ.
|
||
await page.getByRole("dialog").getByRole("button", { name: "Préparer mon expédition", exact: true }).click();
|
||
// Une Étoile guide dans le Sac : un cadre pointillé sous les destinations propose de l'utiliser ; un clic ajoute la destination.
|
||
const offers = page.getByRole("list", { name: "Destinations à ajouter avec vos objets", exact: true });
|
||
const guideStarOffer = offers.getByRole("button", { name: /^Utiliser une Étoile guide pour ajouter une destination/ });
|
||
await expect(guideStarOffer).toBeVisible();
|
||
await expect(offers.getByRole("button")).toHaveCount(1);
|
||
await page.locator(".nebula-expedition-step").first().screenshot({ path: join(tmpdir(), "sokkog-cards-bonus-offers.png") });
|
||
const dailyDestinations = await page.locator(".nebula-expedition-destination").count();
|
||
await guideStarOffer.click();
|
||
await expect(page.getByRole("status").filter({ hasText: "Une nouvelle destination s’ajoute à votre journée." })).toBeVisible();
|
||
await expect(page.locator(".nebula-expedition-destination")).toHaveCount(dailyDestinations + 1);
|
||
await expect(offers).toHaveCount(0);
|
||
const openGroups = page.getByRole("region", { name: "Rejoindre une expédition", exact: true });
|
||
// Avant de rejoindre, les exigences sont déjà celles du groupe avec ce joueur ; elles restent sous les yeux dans le choix de la carte,
|
||
// puis comptent la carte choisie.
|
||
await expect(openGroups.getByRole("region", { name: "Exigences si vous rejoignez (2 joueurs)", exact: true })).toBeVisible();
|
||
// Le temps de choisir sa carte pour rejoindre, la préparation d'une expédition est cachée ; « Annuler » la fait revenir.
|
||
const planHeading = page.getByRole("heading", { name: "Préparer mon expédition", exact: true });
|
||
await expect(planHeading).toBeVisible();
|
||
await openGroups.getByRole("button", { name: "Rejoindre", exact: true }).click();
|
||
await expect(planHeading).toBeHidden();
|
||
await openGroups.getByRole("button", { name: "Annuler", exact: true }).click();
|
||
await expect(planHeading).toBeVisible();
|
||
await openGroups.getByRole("button", { name: "Rejoindre", exact: true }).click();
|
||
await expect(planHeading).toBeHidden();
|
||
const joinLoadout = openGroups.getByRole("region", { name: "Votre explorateur pour cette expédition", exact: true });
|
||
await expect(joinLoadout.getByRole("region", { name: "Équipements", exact: true })).toBeVisible();
|
||
await expect(joinLoadout.getByRole("button", { name: "Valider et se mettre en prêt", exact: true })).toBeDisabled();
|
||
await joinLoadout.getByRole("button", { name: "Choisir un explorateur", exact: true }).click();
|
||
const joinPicker = page.getByRole("dialog", { name: "Choisir l’explorateur" });
|
||
await expect(joinPicker.getByRole("region", { name: "Exigences si vous rejoignez (2 joueurs), sans votre explorateur", exact: true })).toBeVisible();
|
||
await joinPicker.screenshot({ path: join(tmpdir(), "sokkog-cards-group-join-picker.png") });
|
||
await joinPicker.getByRole("button", { name: /^Choisir Kitsune/ }).click();
|
||
await expect(joinLoadout.getByRole("region", { name: "Exigences du groupe avec votre explorateur (2 joueurs)", exact: true })).toBeVisible();
|
||
await expect(openGroups).toContainText("Résultat prévu avec votre explorateur (2 joueurs)");
|
||
await openGroups.screenshot({ path: join(tmpdir(), "sokkog-cards-group-join.png") });
|
||
await expect(joinLoadout.getByRole("button", { name: "Améliorer la carte", exact: true })).toBeVisible();
|
||
// « Valider et se mettre en prêt » : le joueur rejoint, prêt d'emblée ; il peut ensuite modifier sa préparation, puis se redire prêt.
|
||
await joinLoadout.getByRole("button", { name: "Valider et se mettre en prêt", exact: true }).click();
|
||
await expect(page.getByRole("status").filter({ hasText: "Vous avez rejoint l’expédition et vous êtes prêt." })).toBeVisible();
|
||
const joinedGroup = page.getByRole("region", { name: "Votre expédition en préparation" });
|
||
const ownLoadout = joinedGroup.getByRole("region", { name: "Votre explorateur pour cette expédition", exact: true });
|
||
// Prêt : seule la liste des membres le dit, sans bloc de carte en plus.
|
||
await expect(ownLoadout).toHaveCount(0);
|
||
await expect(joinedGroup.getByRole("region", { name: "Membres du groupe", exact: true })).not.toContainText("En préparation");
|
||
await expect(joinedGroup.getByRole("button", { name: "Partir maintenant", exact: true })).toHaveCount(0);
|
||
// « Modifier ma préparation » est avec « Quitter l’expédition », dans les actions du groupe.
|
||
await joinedGroup.getByRole("button", { name: "Modifier ma préparation", exact: true }).click();
|
||
await expect(ownLoadout.getByRole("region", { name: "Équipements", exact: true })).toBeVisible();
|
||
const creatorMembers = groupCard.getByRole("region", { name: "Membres du groupe", exact: true });
|
||
await expect(creatorMembers).toContainText("En préparation", { timeout: 15_000 });
|
||
await groupCard.screenshot({ path: join(tmpdir(), "sokkog-cards-group-preparing.png") });
|
||
await ownLoadout.screenshot({ path: join(tmpdir(), "sokkog-cards-group-own-loadout.png") });
|
||
await ownLoadout.getByRole("button", { name: "Valider et se mettre en prêt", exact: true }).click();
|
||
await expect(page.getByRole("status").filter({ hasText: "Le groupe sait que vous êtes prêt." })).toBeVisible();
|
||
await expect(ownLoadout).toHaveCount(0);
|
||
await expect(creatorMembers).not.toContainText("En préparation", { timeout: 15_000 });
|
||
await expect(groupCard).toContainText("Prêts : 2 sur 2.");
|
||
await mine.getByRole("button", { name: "Partir maintenant", exact: true }).click();
|
||
await expect(watcher.locator(".nebula-expedition-journey")).toBeVisible({ timeout: 15_000 });
|
||
await expect(watched).toHaveCount(0);
|
||
await watcher.close();
|
||
|
||
// Pont des Veilleurs, en boutique : 3 poussières pour 1 Éclat ; la fiche de carte montre le niveau, la Puissance et l'expérience gagnée au retour.
|
||
// Le Sac du Veilleur n'apparaît que s'il contient des objets.
|
||
const bag = partner.getByRole("region", { name: "Sac du Veilleur", exact: true });
|
||
if (await bag.count()) await expect(bag.getByRole("listitem").first()).toBeVisible();
|
||
await expect(partner.getByRole("form", { name: "Éclats d’étoile" })).toHaveCount(0);
|
||
await partner.goto("/#/cards/shop");
|
||
const bridge = partner.getByRole("form", { name: "Éclats d’étoile" });
|
||
await expect(bridge).toContainText("L’échange est définitif.");
|
||
await bridge.getByRole("spinbutton", { name: "Éclats à obtenir" }).fill("2");
|
||
// Le bouton pleine largeur porte le coût total.
|
||
await bridge.getByRole("button", { name: "Convertir · 6 poussières", exact: true }).click();
|
||
await expect(partner.getByRole("status").filter({ hasText: "+2 Éclats d’étoile !" })).toBeVisible();
|
||
await expect(partner.locator(".nebula-shop-wallet")).toContainText("Vos Éclats d’étoile");
|
||
// Un achat d'un autre article fait baisser le maximum : la quantité d'Éclats saisie y est ramenée.
|
||
const eclatsItem = partner.locator('.nebula-shop-item[data-item="eclats"]');
|
||
const eclatsCount = eclatsItem.getByRole("spinbutton", { name: "Éclats à obtenir", exact: true });
|
||
const maxOf = async (item) => Number((await item.getByRole("spinbutton").getAttribute("placeholder")).replace(/\D/g, ""));
|
||
await eclatsCount.fill("100000");
|
||
const eclatsMax = await maxOf(eclatsItem);
|
||
await expect(eclatsCount).toHaveValue(String(eclatsMax));
|
||
await partner.locator('.nebula-shop-item[data-item="opening"]').getByRole("button", { name: /^Acheter · / }).click();
|
||
await expect(partner.getByRole("status").filter({ hasText: "Ouverture achetée" })).toBeVisible();
|
||
const eclatsMaxAfter = await maxOf(eclatsItem);
|
||
expect(eclatsMaxAfter).toBeLessThan(eclatsMax);
|
||
await expect(eclatsCount).toHaveValue(String(eclatsMaxAfter));
|
||
await partner.goto("/#/cards/collection");
|
||
await partner.getByRole("button", { name: "Voir Loup des Aurores", exact: true }).first().click();
|
||
// La fiche résume la carte pour les Expéditions (Puissance, niveau, expérience, stats), puis l'amélioration et le plan ;
|
||
// l'équipement se règle depuis les Expéditions.
|
||
// Depuis la collection, la fiche s'ouvre sur « La carte » ; l'amélioration est dans son second onglet.
|
||
const sheet = partner.getByRole("dialog");
|
||
await expect(sheet.getByRole("tab", { name: "La carte", exact: true })).toHaveAttribute("aria-selected", "true");
|
||
await expect(sheet.getByRole("tabpanel")).toContainText("Exemplaires possédés");
|
||
await sheet.getByRole("tab", { name: "Amélioration", exact: true }).click();
|
||
const summary = sheet.getByRole("region", { name: "Récapitulatif pour les Expéditions", exact: true });
|
||
await expect(summary).toContainText("Niveau 0 / 6");
|
||
await expect(summary.locator(".nebula-card-summary-power strong")).toHaveText("70");
|
||
await expect(summary.getByRole("progressbar", { name: "Expérience", exact: true })).toHaveAttribute("aria-valuenow", "10");
|
||
await expect(summary.getByRole("list", { name: "Stats", exact: true }).getByRole("listitem")).toHaveCount(4);
|
||
await expect(sheet.getByRole("region", { name: "Améliorer", exact: true }).getByRole("button", { name: /^Améliorer · 70 Éclats$/ })).toBeVisible();
|
||
await expect(sheet.getByRole("heading", { name: "Équipements", exact: true })).toHaveCount(0);
|
||
// Les Éclats et les doublons libres se lisent sous la carte, seulement dans « Amélioration ».
|
||
const resources = sheet.getByRole("list", { name: "Vos ressources pour améliorer cette carte", exact: true });
|
||
await expect(resources.getByRole("listitem")).toHaveCount(2);
|
||
await expect(resources.getByRole("listitem").filter({ hasText: "Éclats" }).locator("strong")).toHaveText(/^\d+$/);
|
||
await expect(resources.getByRole("listitem").filter({ hasText: "Doublons" }).locator("strong")).toHaveText(/^\d+$/);
|
||
await sheet.screenshot({ path: join(tmpdir(), "sokkog-cards-upgrade-resources.png") });
|
||
// Une légendaire franchit ses paliers d'Éveil à 85 puis 100 : l'amélioration annonce le prochain et les doublons à garder.
|
||
await expect(sheet.getByRole("region", { name: "Améliorer", exact: true })).toContainText("Améliorez de préférence avec les Éclats : vos doublons pourront servir à l’Éveil de votre carte (prochain Éveil : Puissance\u00a085). Gardez 2 doublons de cette carte pour faire tous les Éveils restants.");
|
||
await sheet.getByRole("region", { name: "Améliorer", exact: true }).screenshot({ path: join(tmpdir(), "sokkog-cards-upgrade-tip.png") });
|
||
await partner.keyboard.press("Escape");
|
||
// Devant le palier (Puissance 80), l'Éveil remplace l'amélioration aux Éclats : le joueur a un doublon du Loup, qui l'éveillerait.
|
||
const { path: progressDatabasePath } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-db.json"), "utf8"));
|
||
const setWolfLevel = (level) => {
|
||
const progressDatabase = new DatabaseSync(progressDatabasePath);
|
||
progressDatabase.prepare("UPDATE card_progress SET level = ? WHERE edition_id = 'aurora-wolf-standard' AND player_id = (SELECT id FROM players WHERE discord_id = 'e2e-partner')").run(level);
|
||
progressDatabase.close();
|
||
};
|
||
setWolfLevel(2);
|
||
await partner.reload();
|
||
await partner.getByRole("button", { name: "Voir Loup des Aurores", exact: true }).first().click();
|
||
await sheet.getByRole("tab", { name: "Amélioration", exact: true }).click();
|
||
await expect(summary).toContainText("Éveil nécessaire pour atteindre la Puissance\u00a085");
|
||
const awakening = sheet.getByRole("region", { name: "Éveil · Puissance\u00a085", exact: true });
|
||
await expect(awakening.getByRole("button", { name: "Éveiller avec un doublon", exact: true })).toBeEnabled();
|
||
await expect(awakening).toContainText(/Doublons légendaires de .+ disponibles : 1 sur 1\./);
|
||
await expect(sheet.getByRole("region", { name: "Améliorer", exact: true })).toHaveCount(0);
|
||
await awakening.screenshot({ path: join(tmpdir(), "sokkog-cards-awakening.png") });
|
||
// Les doublons de la collection se choisissent en cartes illustrées, comme à l'atelier ; rien n'est utilisé avant « Éveiller ».
|
||
await awakening.getByRole("button", { name: "Choisir 1 doublon légendaire", exact: true }).click();
|
||
const awakeningPicker = partner.getByRole("dialog", { name: /^Éveil de Loup des Aurores/ });
|
||
const awakenButton = awakeningPicker.getByRole("button", { name: "Éveiller", exact: true });
|
||
await expect(awakeningPicker.getByRole("heading", { name: "Votre sélection (0/1)", exact: true })).toBeVisible();
|
||
await expect(awakenButton).toBeDisabled();
|
||
const candidates = awakeningPicker.getByRole("list", { name: "Vos doublons utilisables", exact: true }).getByRole("listitem");
|
||
await expect(candidates).toHaveCount(1);
|
||
await candidates.first().getByRole("button", { name: /^Ajouter .+ à la sélection$/ }).click();
|
||
await expect(awakeningPicker.getByRole("heading", { name: "Votre sélection (1/1)", exact: true })).toBeVisible();
|
||
await expect(awakenButton).toBeEnabled();
|
||
await awakeningPicker.screenshot({ path: join(tmpdir(), "sokkog-cards-awakening-picker.png") });
|
||
await awakeningPicker.getByRole("button", { name: "Annuler", exact: true }).click();
|
||
await expect(awakeningPicker).toHaveCount(0);
|
||
await partner.keyboard.press("Escape");
|
||
// La suite du parcours reprend le Loup au niveau 0.
|
||
setWolfLevel(0);
|
||
await partner.reload();
|
||
// Le recyclage en masse s'arrête à une rareté choisie : son menu, sous l'intitulé, s'ouvre en entier au-dessus de l'album.
|
||
const recycleBox = partner.getByRole("region", { name: "Recyclage des doublons", exact: true });
|
||
const rarityTrigger = selectTrigger(recycleBox, "Jusqu’à la rareté");
|
||
await expect(rarityTrigger).toHaveText("Commun");
|
||
const [labelBox, triggerBox] = await Promise.all([recycleBox.locator(".nds-select-field > span").boundingBox(), rarityTrigger.boundingBox()]);
|
||
expect(triggerBox.y).toBeGreaterThan(labelBox.y + labelBox.height - 1);
|
||
await rarityTrigger.click();
|
||
await expectOpenMenuVisible(partner, ".nebula-recycle-box .nds-select-menu");
|
||
// Ouvert vers le bas, sur le texte et les boutons de l'encart : chaque option reste devant eux.
|
||
await partner.keyboard.press("Escape");
|
||
await partner.setViewportSize({ width: 1280, height: 1500 });
|
||
await rarityTrigger.click();
|
||
await expectOpenOptionsOnTop(partner, ".nebula-recycle-box .nds-select-menu");
|
||
await partner.screenshot({ path: join(tmpdir(), "sokkog-cards-recycle-rarity.png") });
|
||
await recycleBox.getByRole("option", { name: "Légendaire", exact: true }).click();
|
||
await expect(rarityTrigger).toHaveText("Légendaire");
|
||
// La confirmation nomme les raretés recyclées et ne montre que leur valeur.
|
||
await recycleBox.getByRole("button", { name: "Recycler", exact: true }).click();
|
||
const recycleConfirm = partner.getByRole("dialog", { name: /^Recycler \d+ doublons? \?$/ });
|
||
await expect(recycleConfirm).toContainText(/Vos doublons communs, rares, épiques et légendaires deviennent \d+ poussières? d’étoiles\./);
|
||
await expect(recycleConfirm.locator(".nds-inline-notice[data-variant=warning]")).toHaveText("Vos doublons rares, épiques et légendaires servent aussi à éveiller vos cartes : gardez ceux dont vous aurez besoin.");
|
||
await expect(recycleConfirm.getByRole("list", { name: "Poussière gagnée par doublon", exact: true }).getByRole("listitem")).toHaveText([/^Commun/, /^Rare/, /^Épique/, /^Légendaire/]);
|
||
await recycleConfirm.screenshot({ path: join(tmpdir(), "sokkog-cards-recycle-confirm.png") });
|
||
await recycleConfirm.getByRole("button", { name: "Annuler", exact: true }).click();
|
||
await partner.setViewportSize({ width: 1280, height: 720 });
|
||
// L'Accueil donne une astuce du jour, chiffres compris, puis les suivantes à la demande.
|
||
await partner.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Accueil", exact: true }).click();
|
||
const tip = partner.getByRole("region", { name: "Astuce du jour", exact: true });
|
||
const tipText = tip.locator(".nebula-home-tip-text");
|
||
await expect(tipText).not.toHaveText("");
|
||
const firstTip = await tipText.textContent();
|
||
expect(firstTip).not.toMatch(/[{}]/);
|
||
await expect(tip.locator(".nds-badge")).toHaveText(/^(Paquets|Collection|Échanges et dons|Carte du jour|Expéditions)$/);
|
||
await tip.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-tip.png") });
|
||
await tip.getByRole("button", { name: "Astuce suivante", exact: true }).click();
|
||
await expect(tipText).not.toHaveText(firstTip);
|
||
await expect(tipText).not.toHaveText(/[{}]/);
|
||
await tip.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-tip-next.png") });
|
||
await partner.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Historique", exact: true }).click();
|
||
await expect(partner.locator(".nebula-history-list li").filter({ hasText: "Expédition terminée" })).toContainText("★ · 2 h");
|
||
// Alertes Discord : désactivées tant que le joueur ne les active pas, une par une.
|
||
await partner.getByRole("navigation", { name: "Sections de Sokko TCG" }).getByRole("link", { name: "Compte", exact: true }).click();
|
||
const alerts = partner.getByRole("region", { name: "Alertes Discord", exact: true });
|
||
const returnAlert = alerts.getByRole("button", { name: "Une de mes expéditions est de retour", exact: true });
|
||
await expect(returnAlert).toHaveAttribute("aria-pressed", "false");
|
||
await returnAlert.click();
|
||
await expect(returnAlert).toHaveAttribute("aria-pressed", "true");
|
||
await expect(alerts.getByRole("button", { name: "Un joueur ouvre un groupe d’expédition", exact: true })).toHaveAttribute("aria-pressed", "false");
|
||
await partnerContext.close();
|
||
|
||
// L'historique d'administration détaille le réglage ; on referme les Expéditions et on remet l'horloge.
|
||
await page.goto("/#/cards/admin/history");
|
||
await expect(page.locator(".nds-list-row").filter({ hasText: "Expéditions modifiées" }).first()).toContainText("Expéditions ouvertes aux joueurs : non → oui");
|
||
await page.goto("/#/cards/admin/guild/expeditions");
|
||
await status.getByRole("button", { name: "Fermer les Expéditions", exact: true }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Fermer", exact: true }).click();
|
||
await expect(status).toContainText("Fermées aux joueurs");
|
||
await setServerClock(0);
|
||
});
|
||
|
||
test("an administrator opens the broken mirror and a player rebuilds the easy and normal pictures, then starts the shared hard one", async ({ page }) => {
|
||
test.setTimeout(120_000);
|
||
await page.goto("/#/cards");
|
||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||
await page.goto("/#/cards/admin/guild/mirror");
|
||
const status = page.getByRole("region", { name: /^Miroir brisé (Ouvert|Fermé) aux joueurs$/ });
|
||
await expect(status).toContainText("Fermé aux joueurs");
|
||
await status.getByRole("button", { name: "Ouvrir le Miroir", exact: true }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Ouvrir", exact: true }).click();
|
||
await expect(status).toContainText("Ouvert aux joueurs");
|
||
await expect(page.getByRole("region", { name: "Gains", exact: true }).getByRole("spinbutton", { name: "Normal, base", exact: true })).toHaveValue("10");
|
||
|
||
await page.goto("/#/cards/guild");
|
||
await page.reload();
|
||
const quest = page.getByRole("article", { name: "Miroir brisé" });
|
||
await expect(quest.getByRole("link", { name: "Jouer", exact: true })).toBeVisible();
|
||
await quest.getByRole("link", { name: "Jouer", exact: true }).click();
|
||
await expect(page).toHaveURL(/#\/cards\/mirror$/);
|
||
// Trois cartes : le Facile à jouer, le Normal et le Difficile verrouillés tant que le miroir précédent n'est pas terminé.
|
||
const easyCard = page.getByRole("article", { name: "Facile", exact: true });
|
||
const normalCard = page.getByRole("article", { name: "Normal", exact: true });
|
||
const hardCard = page.getByRole("article", { name: "Difficile", exact: true });
|
||
await expect(easyCard).toContainText("16 morceaux");
|
||
await expect(normalCard).toContainText("Terminez d’abord le Facile du jour.");
|
||
await expect(hardCard).toContainText("Terminez d’abord le Normal du jour.");
|
||
await expect(hardCard.getByRole("button", { name: "Jouer", exact: true })).toBeDisabled();
|
||
await easyCard.getByRole("button", { name: "Jouer", exact: true }).click();
|
||
|
||
// 16 morceaux, une image mélangée en blob ; en Facile, n'importe quels morceaux s'échangent.
|
||
const board = page.getByRole("group", { name: "Morceaux de l’illustration" });
|
||
const pieces = board.getByRole("button");
|
||
await expect(pieces).toHaveCount(16);
|
||
await expect.poll(() => pieces.first().evaluate((element) => element.style.backgroundImage)).toMatch(/^url\("blob:/);
|
||
await pieces.nth(0).click();
|
||
await expect(pieces.nth(5)).toHaveAttribute("data-legal", "true");
|
||
await pieces.nth(0).click();
|
||
|
||
// La place des morceaux ne sort pas du serveur : le parcours la lit en base, comme la réponse de la Carte du jour.
|
||
const { path: databasePath } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-db.json"), "utf8"));
|
||
const { solve } = await import("../services/cards/mirror-rules.js");
|
||
const nextMove = (mode) => {
|
||
const database = new DatabaseSync(databasePath, { readOnly: true });
|
||
const row = database.prepare("SELECT g.status, g.state_json FROM mirror_games AS g JOIN players ON players.id = g.player_id WHERE players.discord_id = 'dev-admin' AND g.mode = ? ORDER BY g.day DESC LIMIT 1").get(mode);
|
||
database.close();
|
||
if (row.status !== "playing") return null;
|
||
const { pos } = JSON.parse(row.state_json);
|
||
if (mode !== "easy") return solve(pos, 4).first;
|
||
const piece = pos.findIndex((cell, index) => cell !== index);
|
||
return [pos[piece], piece];
|
||
};
|
||
const left = page.locator(".nebula-mirror-left strong");
|
||
const rebuild = async (mode) => {
|
||
const startLeft = Number(await left.textContent());
|
||
let swaps = 0;
|
||
for (let move = nextMove(mode); move; move = nextMove(mode)) {
|
||
await pieces.nth(move[0]).click();
|
||
await pieces.nth(move[1]).click();
|
||
swaps += 1;
|
||
// Chaque échange compte : le nombre restant baisse, jusqu'au résultat.
|
||
await expect(page.locator(`.nebula-mirror-left strong:text-is("${startLeft - swaps}"), .nebula-mirror-result`).first()).toBeVisible();
|
||
}
|
||
return startLeft - swaps;
|
||
};
|
||
const result = page.getByRole("region", { name: "Image reconstituée !" });
|
||
const easyLeft = await rebuild("easy");
|
||
await expect(result).toContainText(`+${5 + easyLeft} poussière`);
|
||
|
||
// Le Normal s'ouvre ensuite : on n'échange que dans la même rangée ou la même colonne.
|
||
await page.getByRole("button", { name: "Jouer le Normal", exact: true }).click();
|
||
await expect(pieces).toHaveCount(16);
|
||
await expect.poll(() => pieces.first().evaluate((element) => element.style.backgroundImage)).toMatch(/^url\("blob:/);
|
||
await pieces.nth(0).click();
|
||
await expect(pieces.nth(5)).toHaveAttribute("data-off", "true");
|
||
await expect(pieces.nth(3)).toHaveAttribute("data-legal", "true");
|
||
await pieces.nth(0).click();
|
||
const normalLeft = await rebuild("normal");
|
||
await expect(result).toContainText(`+${10 + normalLeft} poussière`);
|
||
await expect(result).toContainText("Illustration :");
|
||
|
||
// Le Difficile s'ouvre ensuite : 35 morceaux, le contour vert seulement au survol.
|
||
await page.getByRole("button", { name: "Jouer le Difficile", exact: true }).click();
|
||
await expect(pieces).toHaveCount(35);
|
||
await expect(board).toHaveAttribute("data-placed-hover", "true");
|
||
await page.setViewportSize({ width: 768, height: 900 });
|
||
expect(await page.locator("html").evaluate((element) => element.scrollWidth > element.clientWidth)).toBe(false);
|
||
await page.setViewportSize({ width: 1280, height: 720 });
|
||
// « Changer de miroir » ramène aux deux cartes, avec l'état de chaque partie.
|
||
await page.getByRole("button", { name: "Changer de miroir", exact: true }).click();
|
||
await expect(easyCard).toContainText("Reconstituée");
|
||
await expect(normalCard).toContainText("Reconstituée");
|
||
await expect(hardCard.getByRole("button", { name: "Reprendre", exact: true })).toBeVisible();
|
||
|
||
// Le Miroir se referme pour les parcours suivants.
|
||
await page.goto("/#/cards/admin/guild/mirror");
|
||
await status.getByRole("button", { name: "Fermer le Miroir", exact: true }).click();
|
||
await page.getByRole("dialog").getByRole("button", { name: "Fermer", exact: true }).click();
|
||
await expect(status).toContainText("Fermé aux joueurs");
|
||
});
|