Let players finish a daily quest game started before midnight instead of being sent back to the start
Some checks failed
Validate and deploy Sokko G / validate (push) Failing after 19m48s
Validate and deploy Sokko G / deploy (push) Has been skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-12-04 10:12:45 +01:00
parent c3e494b8a6
commit 4a44306e30
24 changed files with 327 additions and 81 deletions

View file

@ -2626,6 +2626,8 @@ test("an administrator opens expeditions and a player leaves alone, follows the
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);
// L'horloge de la page avance seule ; elle saute ensuite à minuit avec celle du serveur.
await page.clock.install();
await page.goto("/#/cards");
await page.getByRole("button", { name: "Version développement", exact: true }).click();
await page.goto("/#/cards/admin/guild/mirror");
@ -2720,6 +2722,30 @@ test("an administrator opens the broken mirror and a player rebuilds the easy an
await expect(normalCard).toContainText("Reconstituée");
await expect(hardCard.getByRole("button", { name: "Reprendre", exact: true })).toBeVisible();
// Minuit passe pendant le Difficile : la partie se termine sur son jour, sans retour au choix des miroirs.
await hardCard.getByRole("button", { name: "Reprendre", exact: true }).click();
await expect.poll(() => pieces.first().evaluate((element) => element.style.backgroundImage)).toMatch(/^url\("blob:/);
const hardLeft = Number(await left.textContent());
const setServerClock = (offsetMs) => writeFile(join(tmpdir(), "sokkog-cards-e2e-clock.json"), JSON.stringify({ offsetMs }));
const serverMirror = () => page.evaluate(async () => (await (await globalThis.fetch("/api/cards/mirror", { credentials: "same-origin" })).json()).mirror);
const { day: hardDay, nextAt } = await serverMirror();
const toMidnight = nextAt - await page.evaluate(() => Date.now()) + 60_000;
await setServerClock(toMidnight);
await page.clock.fastForward(toMidnight);
// Le coup suivant part bien après minuit côté serveur.
await expect.poll(async () => (await serverMirror()).day).not.toBe(hardDay);
await expect(page.getByRole("status").filter({ hasText: "Minuit est passé : terminez cette partie" })).toBeVisible();
await pieces.nth(0).click();
await pieces.nth(1).click();
await expect(left).toHaveText(String(hardLeft - 1));
await expect(pieces).toHaveCount(35);
// En quittant la partie, le bandeau propose les miroirs du nouveau jour, tout neufs.
await page.getByRole("button", { name: "Changer de miroir", exact: true }).click();
await page.getByRole("button", { name: "Voir les miroirs du jour", exact: true }).click();
await expect(easyCard.getByRole("button", { name: "Jouer", exact: true })).toBeEnabled();
await expect(normalCard).toContainText("Terminez d’abord le Facile du jour.");
await setServerClock(0);
// 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();