Show a full reserve count on the Sokko TCG menu icon and remaining openings while opening a pack

A gold count now sits on the Sokko TCG menu icon while the opening reserve is
full, so players notice it from any page. A light reserve route keeps it up to
date outside the game, and the game page updates it with every state it gets.
The opening stage also lists the remaining openings, apart for the automatic
recharge and for openings bought one at a time, since the sidebar reserve is
hidden there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-07 23:16:47 +01:00
parent 2231bf05e1
commit 498e171bc3
14 changed files with 186 additions and 4 deletions

View file

@ -1613,6 +1613,11 @@ test("a player chains packs of the same collection while openings remain", async
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();
@ -1634,6 +1639,7 @@ test("a player chains packs of the same collection while openings remain", async
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");
@ -1650,3 +1656,35 @@ test("a player chains packs of the same collection while openings remain", async
await expect(back).toBeEnabled();
await expect(openAnother).toHaveCount(0);
});
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");
});