Phone panels (reviewed + QA'd, matrix of 22 layouts with real taps/bounding boxes): - selected-tower action bar over the board (Upgrade/Sell/Target/close), info panel updated in place so taps are never lost, scrollable palette for 7+ towers, overlays with pinned footers (Help "Got it", Play solo, Join always visible), tappable room chip to invite, reduced-motion/contrast/forced-colors fixes, paused state, partner cursor labels, bigger level pips and owner flags - touch input rewritten around "pointerdown commits nothing": pinch never builds, 10px tap slop, palm-proof pinch, long-press pings with any tool armed, nudge arrows for precise placement, hotkey repeat guard, proportional wheel zoom - new e2e: select/sell, info-panel stability, UI states, touch precision; camera unit tests Proxy/server (reproduced against real nginx 1.26 with NPM v2.16 config): - Origin check works when the proxy drops a non-default port, TRUSTED_PROXIES for proxies on global IPv6/CGNAT addresses, service worker no longer serves nginx's 502 page, DEPLOY.md corrected (NPM default read timeout is 90 s, Advanced-tab limits, path-prefix, cookie size, per-IP cap behaviour) Content: - Orbital Uplink: 4-level endgame tower (450 + 500/800/1200 credits): piercing armour-ignoring beam, blast and lingering slow, ground+air, range 11-14; glyph, beam effect, sound, help text, unit tests - Maps: The Canyon, Archipelago, Fortress, Pinwheel (7 maps total) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
71 lines
5.2 KiB
JavaScript
71 lines
5.2 KiB
JavaScript
// code-2: the selected-tower panel used to be rebuilt (innerHTML) on every view.rev change. In co-op the partner's actions
|
|
// bump rev constantly, so the button under a finger was replaced between press and release and the tap was lost.
|
|
// Here a page-side timer hammers rev (a wall is built and sold every 30 ms, standing in for a busy partner) while real
|
|
// presses (down, hold 150 ms, up) land on Upgrade and Target. Every one of them must arrive, and the buttons must be the
|
|
// very same DOM nodes at the end. On the old code only a small fraction of the presses produced a click.
|
|
module.exports = async function ({ browser, url: URL }) {
|
|
const assert = (c, m) => { if (!c) throw new Error('ASSERT: ' + m); console.log('ok -', m); };
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
const errors = [];
|
|
for (const [name, opts, touch] of [
|
|
['desktop mouse', { viewport: { width: 1100, height: 700 } }, false],
|
|
['phone touch', { viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true }, true],
|
|
]) {
|
|
console.log('=== ' + name);
|
|
const ctx = await browser.newContext(opts);
|
|
const page = await ctx.newPage();
|
|
page.on('pageerror', (e) => errors.push(`[${name}] pageerror: ${e.message}`));
|
|
page.on('console', (m) => { if (m.type() === 'error') errors.push(`[${name}] console.error: ${m.text()}`); });
|
|
const cdp = touch ? await ctx.newCDPSession(page) : null;
|
|
await page.goto(URL); await sleep(300);
|
|
await page.evaluate(() => document.getElementById('btnSolo').click()); await sleep(200);
|
|
await page.evaluate(() => document.getElementById('btnHelpClose').click()); await sleep(100);
|
|
await page.evaluate(() => { const c = NW.app.ctrl; c.sim.gold = 100000; c.send({ c: 'place', type: 'filter', x: 10, y: 8 }); });
|
|
await sleep(200);
|
|
const board = await page.locator('#board').boundingBox();
|
|
const cp = await page.evaluate(() => NW.app.renderer.cellToScreen(10, 8));
|
|
if (touch) await page.touchscreen.tap(board.x + cp.x, board.y + cp.y); else await page.mouse.click(board.x + cp.x, board.y + cp.y);
|
|
await sleep(250);
|
|
assert(await page.evaluate(() => NW.app.selTower > 0), 'tower selected');
|
|
|
|
// watch: clicks that reach an action button, and any action button being removed from the DOM
|
|
await page.evaluate(() => {
|
|
window.__clicks = { up: 0, mode: 0 }; window.__removed = 0;
|
|
document.addEventListener('click', (e) => { const b = e.target.closest && e.target.closest('[data-act]'); if (b && window.__clicks[b.dataset.act] !== undefined) window.__clicks[b.dataset.act]++; }, true);
|
|
new MutationObserver((muts) => { for (const m of muts) for (const n of m.removedNodes) if (n.nodeType === 1 && (n.matches('[data-act]') || n.querySelector('[data-act]'))) window.__removed++; }).observe(document.getElementById('info'), { childList: true, subtree: true });
|
|
window.__els = { up: document.querySelector('[data-act="up"]'), mode: document.querySelector('[data-act="mode"]'), sell: document.querySelector('[data-act="sell"]') };
|
|
// the busy partner: build / sell a wall every 30 ms (each one bumps view.rev)
|
|
let i = 0;
|
|
window.__rev0 = NW.app.ctrl.view.rev;
|
|
window.__hammer = setInterval(() => {
|
|
const c = NW.app.ctrl, x = 2 + (i % 6), y = 2 + ((i >> 3) % 2), ex = c.view.towers.find((t) => t.x === x && t.y === y);
|
|
if (ex) c.send({ c: 'sell', id: ex.id }); else c.send({ c: 'place', type: 'wall', x, y });
|
|
i++;
|
|
}, 30);
|
|
});
|
|
|
|
const press = async (act) => {
|
|
const r = await page.evaluate((a) => { const e = document.querySelector(`[data-act="${a}"]`).getBoundingClientRect(); return { x: e.left + e.width / 2, y: e.top + e.height / 2 }; }, act);
|
|
if (touch) { await cdp.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [{ x: r.x, y: r.y, id: 1 }] }); await sleep(150); await cdp.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] }); }
|
|
else { await page.mouse.move(r.x, r.y); await page.mouse.down(); await sleep(150); await page.mouse.up(); }
|
|
await sleep(120);
|
|
};
|
|
for (let i = 0; i < 2; i++) await press('up');
|
|
for (let i = 0; i < 10; i++) await press('mode');
|
|
const res = await page.evaluate(() => {
|
|
clearInterval(window.__hammer);
|
|
const t = NW.app.ctrl.view.towers.find((x) => x.id === NW.app.selTower);
|
|
return { clicks: window.__clicks, removed: window.__removed, revBumps: NW.app.ctrl.view.rev - window.__rev0, level: t && t.level, mode: t && t.mode,
|
|
same: ['up', 'mode', 'sell'].every((k) => document.querySelector(`[data-act="${k}"]`) === window.__els[k]) };
|
|
});
|
|
console.log(JSON.stringify(res));
|
|
assert(res.revBumps > 40, `rev changed ${res.revBumps} times during the presses`);
|
|
assert(res.clicks.up === 2 && res.level === 3, `both Upgrade presses arrived (clicks ${res.clicks.up}, level ${res.level})`);
|
|
assert(res.clicks.mode === 10, `all 10 Target presses arrived (${res.clicks.mode})`);
|
|
assert(res.mode === 'strong', `10 Target taps cycled the mode to ${res.mode}`);
|
|
assert(res.removed === 0 && res.same, `no action button was replaced in the DOM (${res.removed} removals)`);
|
|
await ctx.close();
|
|
}
|
|
if (errors.length) throw new Error('console errors:\n' + errors.join('\n'));
|
|
console.log('no console errors');
|
|
};
|