- Stock: fixed trait gifts (缪尔赛思 / 变形者集群 变形同构体, 耶拉 不融冰, 蜜蜡 / 卡涅利安 迅捷作战粮, 诗怀雅 盟约之币) still occupy stock but are granted past the cap; an operator card already shown in the shop or a reward can be taken after the pool runs out and overdraws (GitHub #498, the owner's decision); item buys and item rewards keep the stock check. 洛洛 / 焰尾 sub-pools use the measured weights (PR #497 by @2321Robin; the occupancy idea of PR #496 by @2321Robin re-implemented differently). - Boss pairs are drawn at random once per match and fixed to battle start; the Hidden Core reuses them; a leaver does not split a full pair (the owner's decision). - 阿戈尔 in 联防 no longer re-applies the opening devour HP loss or a false revive; Touch's team medic stays for the match after its holder leaves (owner-approved, official lifetime unverified). - Auto-skill ranges: 司霆惊蛰 S2, 斩业星熊 S3 against air, 予愿安洁莉娜 S3; 自在's post-rebirth invulnerability is also untargetable (#510); Horn / Clementia / catapult / 忍冬 first hit (PR #502 by @Xinglan233); 不融冰 / tear gas trigger on real damage. - Bond layer-up sound in round start / draft / prep / battle (#482): one channel, a new cue replaces the old, no extra cooldown; a prep update that adds layers and activates a bond plays one cue. - Client: multi-swing fix (#506), refresh single-flight (PR #507 by @robll-v1), LP tower keeps the settled value with a −N tick (PR #504 by @robll-v1), export with only 潜能 / 练度 changes (PR #503 by @Xinglan233), spectator rosters list DIY members (PR #505 by @Xinglan233), banned members beside bond tooltips (PR #494 by @YuriRestia), recovery action above the away overlay (PR #511 by @RainoutOvO), the /dev/sim-check.html consistency page (PR #492 by @Cloudnyco), Korean (PR #490 by @D-Roote) and English Victoria wording (PR #499 by @YuriRestia). - golden: 45 of 287 scenarios move against 0.2.4 (roster 17, bonds 3, fields 6, matches 17, standins 2), each attributed in docs/history/0.2.5.md §30.9 / §30.16.
88 lines
4.3 KiB
JavaScript
88 lines
4.3 KiB
JavaScript
// test/ui/refresh-tap.test.js — GitHub #501 (single-ptilopsis): 高延迟下连按「刷新」会重复扣费. The intent layer now
|
|
// single-flights it (ui/gameActions.js): a tap while the previous g.refresh is still on the wire is dropped — the
|
|
// button dims through onRefreshBusy (game.js → ui/shopBar.js) and the R hotkey (the same actions.refresh) stays inert
|
|
// until the reply lands. The browser run of the same case is test/ui/refresh-tap.e2e.test.js (SP_E2E=1).
|
|
|
|
import { test, describe } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
const read = (p) => readFileSync(path.join(ROOT, p), 'utf8');
|
|
|
|
const { net } = await import('../../public/js/net.js');
|
|
const { actions, onRefreshBusy } = await import('../../public/js/ui/gameActions.js');
|
|
|
|
describe('the shop refresh single-flights (GitHub #501)', () => {
|
|
test('a refresh while the previous one is on the wire sends nothing; the busy signal brackets the request; a later one sends again', async () => {
|
|
const sent = [];
|
|
let release;
|
|
const prev = net.request;
|
|
net.request = (t) => { sent.push(t); return new Promise((r) => { release = () => r({ ok: true }); }); };
|
|
const seen = [];
|
|
const off = onRefreshBusy((b) => seen.push(b));
|
|
try {
|
|
assert.deepEqual(seen, [false], 'subscribing fires once with the current (idle) state');
|
|
const first = actions.refresh();
|
|
assert.equal(sent.length, 1);
|
|
assert.equal(seen.at(-1), true, 'busy from the moment of the send');
|
|
assert.equal(await actions.refresh(), false, 'the duplicate resolves false without waiting');
|
|
assert.equal(sent.length, 1, 'and never reaches the socket');
|
|
release();
|
|
assert.equal(await first, true);
|
|
assert.deepEqual(seen, [false, true, false], 'the reply clears the busy state');
|
|
const again = actions.refresh();
|
|
assert.equal(sent.length, 2, 'a refresh after the reply is sent again');
|
|
release();
|
|
assert.equal(await again, true);
|
|
assert.deepEqual(seen, [false, true, false, true, false]);
|
|
} finally {
|
|
off();
|
|
net.request = prev;
|
|
}
|
|
});
|
|
|
|
test('an unsubscribe stops updates, and a remount receives the in-flight state', async () => {
|
|
const seen = [];
|
|
const off = onRefreshBusy((b) => seen.push(b));
|
|
off();
|
|
const prev = net.request;
|
|
let release;
|
|
net.request = () => new Promise(resolve => { release = resolve; });
|
|
let offNew;
|
|
try {
|
|
const pending = actions.refresh();
|
|
const remounted = [];
|
|
offNew = onRefreshBusy(b => remounted.push(b));
|
|
assert.deepEqual(remounted, [true]);
|
|
release({ ok: true }); await pending;
|
|
assert.deepEqual(remounted, [true, false]); assert.deepEqual(seen, [false]);
|
|
} finally { offNew?.(); net.request = prev; }
|
|
});
|
|
|
|
for (const code of ['OFFLINE', 'DISCONNECTED', 'TIMEOUT', 'NOT_ENOUGH_FUNDS']) test(`${code} clears the pending lock without sending the duplicate`, async () => {
|
|
const prev = net.request, states = []; let reject, sent = 0;
|
|
net.request = () => { sent++; return new Promise((_, fail) => { reject = fail; }); };
|
|
const off = onRefreshBusy(b => states.push(b));
|
|
try {
|
|
const first = actions.refresh();
|
|
assert.equal(await actions.refresh(), false); assert.equal(sent, 1);
|
|
reject(Object.assign(new Error(code), { code }));
|
|
assert.equal(await first, false); assert.deepEqual(states, [false, true, false]);
|
|
net.request = async () => { sent++; return { ok: true }; };
|
|
assert.equal(await actions.refresh(), true); assert.equal(sent, 2);
|
|
} finally { off(); net.request = prev; }
|
|
});
|
|
|
|
test('the wiring: game.js subscribes and hands the state to the bar; the button dims and says what it waits for', () => {
|
|
const game = read('public/js/screens/game.js');
|
|
assert.match(game, /onRefreshBusy\(setRefreshBusy\)/, 'the game screen subscribes');
|
|
assert.match(game, /<\$\{ShopBar\}[\s\S]*?refreshBusy=\$\{refreshBusy\}/, 'and the bar receives it');
|
|
const bar = read('public/js/ui/shopBar.js');
|
|
assert.match(bar, /disabled=\$\{!!refReason \|\| refreshBusy\}/, 'busy disables the 刷新 button');
|
|
assert.match(bar, /t\('正在刷新…'\)/, 'and its tooltip says what it is waiting for');
|
|
});
|
|
});
|