diff --git a/test/e2e/coop.e2e.mjs b/test/e2e/coop.e2e.mjs index 1a0471db..d346f71a 100644 --- a/test/e2e/coop.e2e.mjs +++ b/test/e2e/coop.e2e.mjs @@ -600,7 +600,8 @@ async function ready(c, { key = false } = {}) { if (!(await c.isEditable())) return; const s = await c.st(); if (!s.canReady) { c.note(`temp not empty (${s.temp}) — ready blocked`); return; } - if (key) { await c.page.mouse.click(c.w / 2, c.h * 0.3); await c.page.keyboard.press('Space'); } else await c.click('.readybtn'); + // Space asks about leftover funds like the button does (剩余资金, DESIGN §23.11); the button path confirms inside c.click + if (key) { await c.page.mouse.click(c.w / 2, c.h * 0.3); await c.page.keyboard.press('Space'); await c.confirmFundsLeft(); } else await c.click('.readybtn'); await c.waitFor((x) => x.ready || x.phase !== 'PREP', 'ready', 8000); } diff --git a/test/ui/real.e2e.test.js b/test/ui/real.e2e.test.js index 75957074..5d9d2155 100644 --- a/test/ui/real.e2e.test.js +++ b/test/ui/real.e2e.test.js @@ -413,14 +413,18 @@ class Client { async ready() { if (!(await this.isEditable())) return; await this.click('.readybtn'); - // 准备 with funds left asks first (剩余资金, DESIGN §23.11): confirm it, as a player who means to start the fight does + await this.confirmFundsLeft(); + await this.waitFor((s) => s.ready || s.phase !== 'PREP', 'ready', 8000); + } + + /** 准备 with funds left asks first (剩余资金, DESIGN §23.11): confirm it, as a player who means to start the fight does. */ + async confirmFundsLeft() { await sleep(250); const asked = await this.page.evaluate(() => { const t = document.querySelector('.modal__title'); return !!(t && t.textContent.includes('剩余资金')); }); if (asked) await this.click('.modal__actions button', '准备就绪', { timeout: 4000 }); - await this.waitFor((s) => s.ready || s.phase !== 'PREP', 'ready', 8000); } } @@ -542,7 +546,7 @@ describe('real server + real browsers', { skip: !ENABLED && 'set SP_REAL_E2E=1 ( await c.deployFromHand(2); const s2 = await c.st(); if (s2.temp > 0) c.note(`temp not empty (${s2.temp}) — ready blocked`); - if (c === guest) { await c.page.keyboard.press('Space'); await c.waitFor((x) => x.ready || x.phase !== 'PREP', 'ready (Space)', 8000); } else await c.ready(); + if (c === guest) { await c.page.keyboard.press('Space'); await c.confirmFundsLeft(); await c.waitFor((x) => x.ready || x.phase !== 'PREP', 'ready (Space)', 8000); } else await c.ready(); } } else if (hs.phase === 'SP_DRAFT') { for (const c of both) {