From a5c31cbcb4db8fd586b206d41369d6e7a9e06e6f Mon Sep 17 00:00:00 2001 From: sganggs Date: Sun, 4 Oct 2026 22:31:55 +0800 Subject: [PATCH] feedback3: browser tests accept the leftover-funds prompt when they press ready --- test/e2e/client.mjs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/e2e/client.mjs b/test/e2e/client.mjs index 0323ba92..d425176f 100644 --- a/test/e2e/client.mjs +++ b/test/e2e/client.mjs @@ -160,13 +160,29 @@ export class Client { const t0 = Date.now(); while (Date.now() - t0 < timeout) { const pt = await this.point(sel, text, nth, any); - if (pt) { await this.page.mouse.click(pt.x, pt.y, { button }); return true; } + if (pt) { + await this.page.mouse.click(pt.x, pt.y, { button }); + // 准备 with funds left asks first (剩余资金). Accept it so a test that means "start the fight" is not stuck in PREP. + if (sel === '.readybtn') await this.confirmFundsLeft(); + return true; + } await sleep(150); } if (optional) return false; throw new Error(`${this.label}: nothing clickable for ${sel}${text ? ` "${text}"` : ''}`); } + /** If the 剩余资金 confirm is up, press 准备就绪. No dialog is a no-op. */ + async confirmFundsLeft() { + await sleep(250); + const open = await this.page.evaluate(() => { + const t = document.querySelector('.modal__title'); + return !!(t && t.textContent.includes('剩余资金')); + }); + if (!open) return false; + return this.click('.modal__actions button', '准备就绪', { timeout: 4000 }); + } + /** Centre of the nth visible, enabled (unless `any`), uncovered match (or null). */ point(sel, text = null, nth = 0, any = false) { return this.page.evaluate((sel, text, nth, any) => {