Offer to open another pack of the same collection after a reveal

Players had to go back to the pack list between two openings. Once the cards
are revealed, a button now reopens the same collection while an opening
remains, using the reserve first and then purchased openings. Gift and shop
packs do not offer it, since they spend no opening themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-06 23:46:55 +01:00
parent fd95e4ccff
commit 8c7a6a3e91
5 changed files with 105 additions and 14 deletions

View file

@ -1364,6 +1364,9 @@ test("administrator navigates sections, manages mythic content and previews visu
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 }) => {
@ -1474,6 +1477,9 @@ test("players give cards and answer trade proposals from two accounts", async ({
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 });
await partner.goto("/#/cards/shop");
await expect(partner.locator(".nebula-shop-wallet")).toContainText("440");
@ -1588,3 +1594,59 @@ test("the shop pack rates count the cards it draws from the other collections",
await expect(commonRow.locator("td").nth(2)).not.toHaveText("0");
await expect(commonRow.locator("td").nth(3)).toHaveText("—");
});
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);
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 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);
});