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
99 lines
8.6 KiB
JavaScript
99 lines
8.6 KiB
JavaScript
// Small UI states that were broken or missing on phones: toasts under reduced motion (touch-5, visual-6), toasts hidden behind
|
|
// the build bar (visual-5), the static low-integrity cue, the paused state (visual-18), the tappable room chip (visual-4).
|
|
module.exports = async function ({ browser, url: URL, out: OUT }) {
|
|
const failures = [];
|
|
const assert = (c, m) => { if (!c) { failures.push(m); console.log('FAIL -', m); } else console.log('ok -', m); }; // collect every failure (the old code fails several)
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
const errors = [];
|
|
const phone = { viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true };
|
|
const start = async (opts) => {
|
|
const ctx = await browser.newContext(opts);
|
|
const page = await ctx.newPage();
|
|
page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
|
|
page.on('console', (m) => { if (m.type() === 'error') errors.push('console.error: ' + m.text()); });
|
|
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(150);
|
|
return { ctx, page };
|
|
};
|
|
const tryTap = (page, sel) => page.tap(sel, { timeout: 3000 }).then(() => true, () => false); // (the old UI has no such button: fail fast instead of waiting 30 s)
|
|
const rect = (page, sel) => page.evaluate((s) => { const r = document.querySelector(s).getBoundingClientRect(); return { l: r.left, t: r.top, r: r.right, b: r.bottom }; }, sel);
|
|
const overlap = (a, b) => !(a.r <= b.l || a.l >= b.r || a.b <= b.t || a.t >= b.b);
|
|
|
|
// ---- reduced motion: the toast text stays visible, the low-integrity cue is static, and the build bar never hides the toast
|
|
for (const half of ['upper', 'lower']) {
|
|
const { ctx, page } = await start({ ...phone, reducedMotion: 'reduce' });
|
|
await page.evaluate(() => { NW.app.ctrl.sim.gold = 0; });
|
|
await page.evaluate(() => document.querySelector('.tbtn[data-type="filter"]').click());
|
|
const board = await page.locator('#board').boundingBox();
|
|
const cell = await page.evaluate((h) => NW.app.renderer.cellToScreen(h === 'upper' ? 12 : 12, h === 'upper' ? 2 : 13), half);
|
|
await page.touchscreen.tap(board.x + cell.x, board.y + cell.y); await sleep(200); // first tap: preview + build bar
|
|
await tryTap(page, '#btnConfirmBuild'); await sleep(250); // not enough credits -> toast
|
|
const t = await page.evaluate(() => { const e = document.querySelector('.toast'); if (!e) return null; const cs = getComputedStyle(e), r = e.getBoundingClientRect(); return { text: e.textContent, opacity: +cs.opacity, l: r.left, t: r.top, r: r.right, b: r.bottom }; });
|
|
assert(t && /credits/i.test(t.text), `reduced motion (${half} half): toast exists "${t && t.text}"`);
|
|
assert(t && t.opacity > 0.9, `reduced motion (${half} half): toast is visible (opacity ${t && t.opacity})`);
|
|
const bar = await rect(page, '#confirm');
|
|
assert(t && !overlap(t, bar), `${half} half: the toast does not overlap the build bar`);
|
|
// the server (core) stays clear of the toast
|
|
const core = await page.evaluate(() => { const b = NW.app.ctrl.board, p = NW.app.renderer.cellToScreen(b.core.x, b.core.y), bb = document.getElementById('board').getBoundingClientRect(), s = NW.app.renderer.cellSizePx() * 0.6; return { l: bb.left + p.x - s, r: bb.left + p.x + s, t: bb.top + p.y - s, b: bb.top + p.y + s }; });
|
|
assert(t && !overlap(t, core), `${half} half: the toast does not cover the server`);
|
|
if (half === 'upper') {
|
|
await page.evaluate(() => { NW.app.ctrl.sim.lives = 3; }); await sleep(300);
|
|
const low = await page.evaluate(() => { const e = document.getElementById('statLives'), cs = getComputedStyle(e); return { cls: e.classList.contains('low'), border: cs.borderTopColor, shadow: cs.boxShadow, anim: cs.animationName }; });
|
|
assert(low.cls && low.border === 'rgb(255, 92, 122)' && low.shadow !== 'none', 'reduced motion: low integrity shows a static red border + glow: ' + JSON.stringify(low));
|
|
}
|
|
await page.screenshot({ path: OUT + `ui-states-toast-${half}.png` });
|
|
await ctx.close();
|
|
}
|
|
|
|
// ---- paused: dimmed board, a resume pill that works, and a pause button that is not a second play triangle
|
|
{
|
|
const { ctx, page } = await start(phone);
|
|
await page.tap('#btnPause'); await sleep(250);
|
|
const p = await page.evaluate(() => ({ paused: NW.app.ctrl.view.paused, tag: !document.getElementById('pausedTag').hidden, tagText: document.getElementById('pausedTag').innerText, stage: document.getElementById('stage').classList.contains('paused'), dim: getComputedStyle(document.getElementById('stage'), '::after').backgroundColor, pressed: document.getElementById('btnPause').getAttribute('aria-pressed'), icon: document.querySelector('#btnPause use').getAttribute('href') }));
|
|
assert(p.paused && p.tag && p.stage && p.pressed === 'true', 'paused: pill shown, stage marked, button pressed ' + JSON.stringify(p));
|
|
assert(/resume/i.test(p.tagText) && p.dim !== 'rgba(0, 0, 0, 0)', 'paused: the board is dimmed and the pill says how to resume');
|
|
assert(p.icon === '#i-pause', 'paused: the pause button keeps its pause icon (the Wave button owns the play triangle)');
|
|
await page.screenshot({ path: OUT + 'ui-states-paused.png' });
|
|
const tapped = await tryTap(page, '#pausedTag'); await sleep(250);
|
|
assert(tapped && await page.evaluate(() => !NW.app.ctrl.view.paused && document.getElementById('pausedTag').hidden), 'tapping the pill resumes');
|
|
await ctx.close();
|
|
}
|
|
|
|
// ---- reconnecting: the whole HUD looks dead (not only the board), apart from the menu and the room chip
|
|
{
|
|
const { ctx, page } = await start(phone);
|
|
await page.evaluate(() => { document.getElementById('reconnect').hidden = false; }); await sleep(250);
|
|
const o = await page.evaluate(() => { const g = (id) => { const cs = getComputedStyle(document.getElementById(id)); return { op: +cs.opacity, pe: cs.pointerEvents }; }; return { app: document.getElementById('app').classList.contains('offline'), wave: g('btnWave'), pause: g('btnPause'), palette: g('side'), menu: g('btnMenu') }; });
|
|
assert(o.app && o.wave.pe === 'none' && o.wave.op < 0.6 && o.palette.pe === 'none' && o.menu.pe !== 'none', 'reconnecting: HUD dims and stops taking taps, the menu stays usable ' + JSON.stringify(o));
|
|
await page.screenshot({ path: OUT + 'ui-states-offline.png' });
|
|
await ctx.close();
|
|
}
|
|
|
|
// ---- the room chip: shows the code, pulses while alone, copies / shares the invite link when tapped
|
|
{
|
|
const ctx = await browser.newContext({ ...phone, permissions: ['clipboard-read', 'clipboard-write'] });
|
|
const page = await ctx.newPage();
|
|
page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
|
|
await page.goto(URL); await sleep(300);
|
|
await page.evaluate(() => document.getElementById('btnCoop').click()); await sleep(100);
|
|
await page.evaluate(() => document.getElementById('btnCreate').click());
|
|
for (let i = 0; i < 60 && !(await page.evaluate(() => NW.app.inGame && NW.app.ctrl.status === 'joined')); i++) await sleep(100);
|
|
await sleep(300);
|
|
const room = await page.evaluate(() => NW.app.ctrl.room);
|
|
const chip = await page.evaluate(() => { const e = document.getElementById('netChip'), r = e.getBoundingClientRect(); return { text: e.innerText, waiting: e.classList.contains('waiting'), w: r.width, h: r.height, inView: r.left >= 0 && r.right <= innerWidth && r.top >= 0 && r.bottom <= innerHeight }; });
|
|
assert(chip.text.includes(room) && chip.inView && chip.h >= 43.5, `room chip shows ${room}, is on screen and 44px tall (${JSON.stringify(chip)})`);
|
|
assert(chip.waiting, 'room chip pulses while waiting for a partner');
|
|
await page.evaluate(() => { navigator.share = undefined; });
|
|
await tryTap(page, '#netChip'); await sleep(400);
|
|
const toast = await page.evaluate(() => [...document.querySelectorAll('.toast')].map((t) => t.textContent).join('|'));
|
|
assert(/copied/i.test(toast), 'tapping the chip copies the invite link: "' + toast + '"');
|
|
const clip = await page.evaluate(() => navigator.clipboard.readText()).catch(() => '');
|
|
assert(clip.includes('?room=' + room), 'the clipboard holds the invite link: ' + clip);
|
|
await page.evaluate(() => { try { NW.app.ctrl.close(); } catch (e) { /* ignore */ } });
|
|
await ctx.close();
|
|
}
|
|
if (errors.length) throw new Error('console errors:\n' + errors.join('\n'));
|
|
if (failures.length) throw new Error(failures.length + ' UI state checks failed:\n - ' + failures.join('\n - '));
|
|
console.log('no console errors');
|
|
};
|