From 13b52450d647148eb661595448696c8aef9af3fa Mon Sep 17 00:00:00 2001 From: sganggs Date: Wed, 7 Oct 2026 06:28:50 +0800 Subject: [PATCH] =?UTF-8?q?feedback5:=20the=20co-op=20browser=20test=20rea?= =?UTF-8?q?ds=20phase,=20funds,=20price,=20free=20refreshes=20and=20shop?= =?UTF-8?q?=20slots=20in=20one=20store=20snapshot=20when=20it=20checks=20t?= =?UTF-8?q?he=20R=20refresh=20=E2=80=94=20two=20page=20reads=20could=20str?= =?UTF-8?q?addle=20the=20m.private=20that=20answers=20R=20and=20pair=20the?= =?UTF-8?q?=20new=20slots=20with=20the=20old=20funds,=20failing=20"host:?= =?UTF-8?q?=20refresh=20cost=206=20!=3D=3D=205"=20under=20the=20full=20pas?= =?UTF-8?q?s's=20load=20(1=20of=204=20in=20full020c;=20the=20same=20check?= =?UTF-8?q?=20passes=20alone,=20"funds=206=20=E2=86=92=205");=20golden:=20?= =?UTF-8?q?unchanged=20(test=20only)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/coop.e2e.mjs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test/e2e/coop.e2e.mjs b/test/e2e/coop.e2e.mjs index d346f71a..bfd67e3c 100644 --- a/test/e2e/coop.e2e.mjs +++ b/test/e2e/coop.e2e.mjs @@ -193,23 +193,29 @@ async function levelUp(c, { shot = null } = {}) { } async function refreshKey(c) { - const s = await c.st(); - if (s.funds < s.refreshPrice) return false; - const shop = () => c.page.evaluate(() => { const sh = globalThis.__SP__.store.get().match.private.shop; return { ids: JSON.stringify(sh.slots.map((x) => x && x.id)), free: sh.freeRefreshes }; }); + // phase, funds, price, free counter and slots from ONE store snapshot: the m.private that answers R carries them all, + // and two separate reads could straddle it — the new slots with the old funds, a false "refresh cost" under load + const shop = () => c.page.evaluate(() => { + const st = globalThis.__SP__.store.get(); + const priv = st.match.private; + const sh = priv.shop; + return { phase: st.match.public?.phase ?? null, funds: priv.funds, price: sh.refreshPrice, free: sh.freeRefreshes, ids: JSON.stringify(sh.slots.map((x) => x && x.id)) }; + }); const before = await shop(); + if (before.funds < before.price) return false; await c.page.mouse.click(c.w / 2, c.h * 0.3); // focus the page (not a text field) await c.page.keyboard.press('KeyR'); // a free refresh (机变 补给 …) changes the free counter, a paid one the funds; the slots are rerolled either way const t0 = Date.now(); - let after = null; let now = null; + let now = null; while (Date.now() - t0 < 6000) { - after = await c.st(); now = await shop(); - if (after.phase !== 'PREP' || after.funds !== s.funds || now.free !== before.free || now.ids !== before.ids) break; + now = await shop(); + if (now.phase !== 'PREP' || now.funds !== before.funds || now.free !== before.free || now.ids !== before.ids) break; await sleep(150); } - assert.ok(after.funds !== s.funds || now.free !== before.free || now.ids !== before.ids, `${c.label}: R refreshed the shop`); - if (s.refreshPrice > 0) assert.equal(after.funds, s.funds - s.refreshPrice, `${c.label}: refresh cost`); - c.note(`refresh (R) ${s.refreshPrice ? `funds ${s.funds} → ${after.funds}` : `free (${before.free} → ${now.free})`}, slots ${before.ids === now.ids ? 'same ids' : 'rerolled'}`); + assert.ok(now.funds !== before.funds || now.free !== before.free || now.ids !== before.ids, `${c.label}: R refreshed the shop`); + if (before.price > 0) assert.equal(now.funds, before.funds - before.price, `${c.label}: refresh cost`); + c.note(`refresh (R) ${before.price ? `funds ${before.funds} → ${now.funds}` : `free (${before.free} → ${now.free})`}, slots ${before.ids === now.ids ? 'same ids' : 'rerolled'}`); return true; }