feedback4: merge master — PRs #114 #119 #127 #115 #110

This commit is contained in:
sganggs committed 2026-10-05 14:35:00 +08:00
commit 2519a23a55
24 files changed
+343 -50

No files matched your search

+10 -1
View File
@@ -30,7 +30,8 @@ describe('bgm selection', () => {
assert.equal(bgmKeyFor('game', { phase: PHASE.PREP }), 'prep');
assert.equal(bgmKeyFor('game', { phase: PHASE.SP_DRAFT }), 'prep');
assert.equal(bgmKeyFor('game', { phase: PHASE.COMBAT }), 'combat');
assert.equal(bgmKeyFor('game', { phase: PHASE.UNITE }), 'combat');
// 联防 has its own track: the official escaped_single / escaped_multi levels declare bgmEvent = corrosion
assert.equal(bgmKeyFor('game', { phase: PHASE.UNITE }), 'unite');
assert.equal(bgmKeyFor('game', { phase: PHASE.FINAL_ASSAULT, bossId: 'boss_4' }), 'boss:boss_4');
assert.equal(bgmKeyFor('game', { phase: PHASE.FINAL_ASSAULT }), 'boss');
assert.equal(bgmKeyFor('game', { phase: PHASE.HIDDEN_CORE, bossId: 'boss_1', hiddenBossId: 'boss_9' }), 'boss:boss_9');
@@ -44,6 +45,14 @@ describe('bgm selection', () => {
assert.equal(b4.loop, manifest.audio.bossBgm.boss_4.loop);
assert.equal(resolveBgm(manifest, 'boss:nope').loop, manifest.audio.bgm.boss.loop);
assert.equal(resolveBgm(manifest, 'prep').intro, manifest.audio.bgm.prep.intro ?? null);
// 联防's own track (bgm.unite = corrosion, the official escaped levels' bgmEvent), and the fallback for an older
// manifest that has no `unite` entry (the music must not go silent)
const unite = manifest.audio.bgm.unite;
assert.ok(unite && typeof unite.loop === 'string', 'the manifest carries 联防’s own track');
assert.equal(resolveBgm(manifest, 'unite').loop, unite.loop);
assert.equal(resolveBgm(manifest, 'unite').intro, unite.intro ?? null);
assert.notEqual(unite.loop, manifest.audio.bgm.combat.loop, 'not the shop / default combat loop');
assert.equal(resolveBgm({ audio: { bgm: { combat: { loop: '/shop.mp3' } } } }, 'unite').loop, '/shop.mp3');
assert.equal(resolveBgm(null, 'lobby'), null);
assert.equal(resolveBgm(manifest, null), null);
assert.equal(resolveBgm(manifest, 'nope'), null);
+24 -7
View File
@@ -18,7 +18,17 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
const OUT = path.join(ROOT, 'test/e2e/out');
const CHROME = process.env.CHROME_PATH || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const ENABLED = process.env.SP_E2E === '1' && existsSync(CHROME);
const HAS_ART = existsSync(path.join(ROOT, 'public/assets/local/emoticon/fooldoctor'));
// The official pictures reach the wheel through a two-link chain (data.js artUrls): the local-client extraction
// first (tools/local-extract → data/local-assets.json), then the copies tools/fetch-assets.mjs downloads into
// public/assets/ui/emoticon (GitHub #42). A deployment has one link or the other; the assertions below check that
// the pictures LOAD, never which link served them, so either one is enough to run the suite.
const HAS_ART = existsSync(path.join(ROOT, 'public/assets/local/emoticon/fooldoctor'))
|| existsSync(path.join(ROOT, 'public/assets/ui/emoticon/fooldoctor'));
// The WHEEL's own chrome is a different story: emoji_cell_bkg / emoji_bkg / emoji_btn come from the local client's
// ui/battle atlas (ui/emotes.js emoteUiSprite → localAsset), which tools/fetch-assets.mjs does NOT carry — no dump,
// no official cell, and the wheel draws its own. One assertion below is about that official chrome, so it asks for it
// separately instead of quietly failing on a fetch-assets-only deployment.
const HAS_UI = existsSync(path.join(ROOT, 'public/assets/local/ui/battle/emoji_cell_bkg.png'));
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (and have Chrome) to run' }, () => {
@@ -77,7 +87,7 @@ describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (an
};
}, root);
test('UI kit: pager per theme, picture-only, swipe / keys / dots, cooldown, remembered theme, 3 s bubble', { skip: !HAS_ART && 'no extracted emote art' }, async () => {
test('UI kit: pager per theme, picture-only, swipe / keys / dots, cooldown, remembered theme, 3 s bubble', { skip: !HAS_ART && 'no official emote art (neither the local extraction nor the fetched copies)' }, async () => {
const { page, problems } = await open('/dev/uikit.html');
await page.evaluate(() => localStorage.removeItem('sp.pref.emoteTheme'));
await page.reload({ waitUntil: 'networkidle0' });
@@ -160,7 +170,7 @@ describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (an
await page.close();
});
test('wheel: one trackpad swipe (momentum included) turns one page, a mouse-wheel notch turns one page', { skip: !HAS_ART && 'no extracted emote art' }, async () => {
test('wheel: one trackpad swipe (momentum included) turns one page, a mouse-wheel notch turns one page', { skip: !HAS_ART && 'no official emote art (neither the local extraction nor the fetched copies)' }, async () => {
const { page, problems } = await open('/dev/uikit.html');
await page.evaluate(() => localStorage.removeItem('sp.pref.emoteTheme'));
await page.reload({ waitUntil: 'networkidle0' });
@@ -196,12 +206,19 @@ describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (an
const hover = await page.$eval('#emo-stage .ewheel__item:nth-child(2)', (el) => ({
sprite: el.closest('.ewheel__panel').classList.contains('has-cell'), bg: getComputedStyle(el).backgroundColor, filter: getComputedStyle(el).filter,
}));
assert.deepEqual(hover, { sprite: true, bg: 'rgba(0, 0, 0, 0)', filter: 'brightness(1.35)' });
if (HAS_UI) {
assert.deepEqual(hover, { sprite: true, bg: 'rgba(0, 0, 0, 0)', filter: 'brightness(1.35)' }, 'the official emoji_cell_bkg cell');
} else {
// no local client dump: the wheel draws its own cell and the hover is a drawn fill — the pictures are what this
// test is about on such a deployment, so only pin that it is NOT pretending to be the official sprite cell
assert.equal(hover.sprite, false, 'without ui/battle/emoji_cell_bkg the cell is drawn, not the official sprite');
assert.ok(hover.bg !== '' && hover.filter !== '', `the drawn cell is still styled: ${JSON.stringify(hover)}`);
}
assert.deepEqual(problems, []);
await page.close();
});
test('the cooldown survives a remount of the wheel; a bubble mounted late resumes its timeline', { skip: !HAS_ART && 'no extracted emote art' }, async () => {
test('the cooldown survives a remount of the wheel; a bubble mounted late resumes its timeline', { skip: !HAS_ART && 'no official emote art (neither the local extraction nor the fetched copies)' }, async () => {
const { page, problems } = await open('/dev/uikit.html');
await page.waitForSelector('#emo-stage .ewheel__panel');
await page.evaluate(async () => {
@@ -251,7 +268,7 @@ describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (an
await page.close();
});
test('touch: a horizontal swipe on the pager turns the page, a tap sends', { skip: !HAS_ART && 'no extracted emote art' }, async () => {
test('touch: a horizontal swipe on the pager turns the page, a tap sends', { skip: !HAS_ART && 'no official emote art (neither the local extraction nor the fetched copies)' }, async () => {
const { page, problems } = await open('/dev/uikit.html');
await page.setViewport({ width: 1280, height: 720, hasTouch: true, isMobile: false });
await page.evaluate(() => localStorage.removeItem('sp.pref.emoteTheme'));
@@ -302,7 +319,7 @@ describe('official emotes in the browser', { skip: !ENABLED && 'set SP_E2E=1 (an
await page.close();
});
test('in-match mock: bubbles beside the senders\' avatars, wheel above 交流', { skip: !HAS_ART && 'no extracted emote art' }, async () => {
test('in-match mock: bubbles beside the senders\' avatars, wheel above 交流', { skip: !HAS_ART && 'no official emote art (neither the local extraction nor the fetched copies)' }, async () => {
const { page, problems } = await open('/dev/game-mock.html?shot=1&render=fallback&phase=PREP&variant=emote', { w: 1920, h: 1080 });
await page.waitForFunction(() => !!document.querySelector('.screen:not(.gload)'), { timeout: 15000 });
await page.waitForSelector('.team__bubble');
+15 -1
View File
@@ -494,6 +494,20 @@ describe('keyboard & settings', () => {
assert.equal(shortcutFor({ key: 'r', code: 'KeyR' }), 'refresh');
assert.equal(shortcutFor({ key: 'F', code: 'KeyF' }), 'freeze');
assert.equal(shortcutFor({ key: 'd' }), 'levelUp');
assert.equal(shortcutFor({ key: 'q', code: 'KeyQ' }), 'retreat');
assert.equal(shortcutFor({ key: 'Q' }), 'retreat');
assert.equal(shortcutFor({ code: 'KeyX' }), 'sell');
assert.equal(shortcutFor({ key: 'X' }), 'sell');
for (const key of ['q', 'x']) {
assert.equal(shortcutFor({ key, repeat: true }), null);
assert.equal(shortcutFor({ key, ctrlKey: true }), null);
assert.equal(shortcutFor({ key, metaKey: true }), null);
assert.equal(shortcutFor({ key, altKey: true }), null);
for (const tagName of ['INPUT', 'TEXTAREA', 'SELECT']) {
assert.equal(shortcutFor({ key, target: { tagName } }), null);
}
assert.equal(shortcutFor({ key, target: { isContentEditable: true } }), null);
}
assert.equal(shortcutFor({ key: ' ', code: 'Space' }), 'ready');
assert.equal(shortcutFor({ key: 'Escape' }), 'escape');
assert.equal(shortcutFor({ key: 'r', ctrlKey: true }), null);
@@ -503,7 +517,7 @@ describe('keyboard & settings', () => {
assert.equal(shortcutFor({ key: ' ', code: 'Space', target: { tagName: 'BUTTON' } }), 'ready', 'space readies even with a HUD button focused');
assert.equal(shortcutFor({ key: ' ', code: 'Space', target: { tagName: 'TEXTAREA' } }), null);
assert.equal(shortcutFor({ key: 'd', target: { tagName: 'DIV', isContentEditable: true } }), null);
assert.equal(shortcutFor({ key: 'x' }), null);
assert.equal(shortcutFor({ key: 'z' }), null);
assert.equal(shortcutFor(null), null);
});
test('sanitizeSettings', () => {
+42
View File
@@ -149,6 +149,48 @@ describe('in-match UI (mock harness, headless Chrome)', { skip: !ENABLED && 'set
await page.close();
});
test('prep: Q retreats and X sells only the selected operator', async () => {
const { page, problems } = await open('phase=PREP', { render: 'fallback' });
const initial = await mockState(page);
await page.keyboard.press('KeyQ');
await page.keyboard.press('KeyX');
assert.deepEqual(await mockState(page), initial, 'no selection means no action');
const unit = initial.board.find((piece) => piece.kind === 'chess' && !piece.golden);
await page.click(`.ff-piece[data-uid="${unit.uid}"]`);
await page.waitForSelector('.uframe__btn--retreat');
await page.evaluate(() => {
const input = document.createElement('input');
input.id = 'shortcut-test-input';
document.body.append(input);
input.focus();
});
await page.keyboard.press('KeyQ');
await page.keyboard.press('KeyX');
assert.deepEqual(await mockState(page), initial, 'typing must not retreat or sell');
await page.evaluate(() => document.getElementById('shortcut-test-input').remove());
await page.keyboard.press('KeyQ');
await page.waitForFunction((uid) => globalThis.__MOCK__.S().priv.hand.some((piece) => piece?.uid === uid), {}, unit.uid);
const retreated = await mockState(page);
assert.ok(!retreated.board.some((piece) => piece.uid === unit.uid));
assert.equal(retreated.funds, initial.funds, 'retreat does not sell');
await page.click(`.ff-piece[data-uid="${unit.uid}"]`);
await page.waitForSelector('.uframe__btn--sell');
assert.equal(await page.$('.uframe__btn--retreat'), null, 'bench operator cannot retreat');
await page.keyboard.press('KeyQ');
assert.deepEqual(await mockState(page), retreated, 'Q on the bench does nothing');
await page.keyboard.press('KeyX');
await page.waitForFunction((uid) => !globalThis.__MOCK__.S().priv.hand.some((piece) => piece?.uid === uid), {}, unit.uid);
assert.ok((await mockState(page)).funds > retreated.funds, 'X sells the selected operator');
const item = (await mockState(page)).hand.find((piece) => piece?.kind === 'item');
await page.click(`.ff-piece[data-uid="${item.uid}"]`);
await page.waitForSelector('.uframe__btn--destroy');
await page.keyboard.press('KeyX');
assert.ok((await mockState(page)).hand.some((piece) => piece?.uid === item.uid), 'X must not destroy an item');
assert.equal(await page.$('.modal'), null, 'no destroy confirmation');
assert.deepEqual(problems, []);
await page.close();
});
test('prep: drag & drop — tap-sell (no sell zone), hand → board + wheel, item → unit (equip)', async () => {
// DOM drag targets only exist in the fallback view (the Pixi engine's own drag is tested by the render module)
const { page, problems } = await open('phase=PREP', { render: 'fallback' });
+2
View File
@@ -115,6 +115,8 @@ describe('8: the detail card never covers the selected unit\'s underframe', () =
assert.doesNotMatch(css, /\.gm__bonds > \* \{ pointer-events: auto; \}/);
const dev = readFileSync(new URL('../../public/css/devices.css', import.meta.url), 'utf8');
assert.match(dev, /\.gm__hud > \.uframe \{ margin-left: calc\(-1 \* var\(--sa-l\)\); margin-top: calc\(-1 \* var\(--sa-t\)\); \}/);
const panels = readFileSync(new URL('../../public/css/screens/game-panels.css', import.meta.url), 'utf8');
assert.match(panels, /\.uframe__label\s*\{[^}]*white-space:\s*nowrap\s*;/, 'shortcut labels stay on one line');
});
test('underframeRect covers the diamond and its buttons', () => {
+1 -1
View File
@@ -35,7 +35,7 @@ describe('暂离 (AI 托管) is scoped to one match', () => {
describe('game shortcuts behind overlays', () => {
test('the 本局信息 / 敌方情报 drawer swallows R / F / D / Space, Esc still closes it', () => {
for (const act of ['refresh', 'freeze', 'levelUp', 'ready']) {
for (const act of ['refresh', 'freeze', 'levelUp', 'retreat', 'sell', 'ready']) {
assert.equal(shortcutBlocked(act, { drawer: true }), true, act);
assert.equal(shortcutBlocked(act, {}), false, act);
assert.equal(shortcutBlocked(act, { modal: true }), true, act);