Let Cards players delete their account and read a privacy notice

Add a Compte section with a privacy notice and a confirmed deletion that
anonymises the player row, erases their possessions and cancels open trades.
The public contact comes from CARDS_PRIVACY_CONTACT, which production now
requires before enabling the game. The admin E2E no longer relies on a pull
from the previous test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-05 18:05:41 +01:00
parent 155187d01f
commit e60fbd4e9b
16 changed files with 319 additions and 10 deletions

View file

@ -282,6 +282,9 @@ test("player opens and reveals a three-card pack", async ({ page }) => {
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);
await page.getByRole("button", { name: "Tout révéler" }).click();
@ -1461,3 +1464,53 @@ test("administrator previews the mythic opening from a base without any mythic v
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");
await page.locator(".nebula-privacy-details summary").click();
await expect(page.locator(".nebula-privacy-details").getByRole("link", { name: "privacy@example.invalid" })).toHaveAttribute("href", "mailto:privacy@example.invalid");
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: "sokkog_cards_session", value: token, url: "http://127.0.0.1:4180" }]);
const { traders } = await (await partnerContext.request.get("/api/cards/traders")).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);
});