tracker
All repositories: gitoria
21.7 KB
// tests/mobile.mjs — THE PHONE GATE of tracker.worldapi.org (mission MK, the creator's rule "mobile first"; the caramboleyo's phone is an// Android Chrome of about 390 px): this app's own server on its own storage (tests/seed-show.hl + tests/seed-mobile.hl), signed in with a// session file (no ident), a real headless Chrome with TOUCH emulation at 390 × 844, device scale factor 3. Proves, per page:// - nothing scrolls sideways, every link / button is a 44 px tap target (tests/mobile-measure.js), every field is ≥ 16 px:// /my/series, /my/shows is empty-state-free here (the fixture follows series only → /my/series), /my/unwatched, /my/schedule,// /search/gate (title + person rows), a title page (the TMDB / IMDb badges), a movie page with the franchise widget (its franchise// link), a franchise page (its timeline names), the timeline editor ("New franchise …"), /login/failed ("back to tracker")// - /franchises (100 timelines without a franchise): 40 per page (a page of 1,546 was 54,000 px and 20 s on the real data), the franchises on// page 1 only, a pager that a real TOUCH tap on Next / a number works, the address /franchises/page/N, the last page the rest, an// out-of-range or bad page number = the last / the first page, and the whole page loads in under 2 s// node tests/mobile.mjs (TRACKER_GATE_PORT server, default 8700; TRACKER_GATE_CHROME "8702-8709"; TRACKER_GATE_SHOTS: screenshots)import { spawn, execFileSync } from 'node:child_process';import { checkServerExit } from './identkit.mjs';import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { createHash } from 'node:crypto';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { launchBrowser } from './cdp.mjs';if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';const HERE = dirname(fileURLToPath(import.meta.url));const APP = resolve(HERE, '..');const PORT = Number(process.env.TRACKER_GATE_PORT || 8700);const [CH_FROM, CH_TO] = (process.env.TRACKER_GATE_CHROME || '8702-8709').split('-').map(Number);const SHOTS = process.env.TRACKER_GATE_SHOTS || '';const BASE = `http://127.0.0.1:${PORT}`;const STORE = join(APP, '.scratch', 'mobile-store');const SESSIONS = join(APP, '.scratch', 'mobile-sessions');const MEASURE = readFileSync(join(HERE, 'mobile-measure.js'), 'utf8');rmSync(STORE, { recursive: true, force: true });rmSync(SESSIONS, { recursive: true, force: true });mkdirSync(SESSIONS, { recursive: true });if (SHOTS) mkdirSync(SHOTS, { recursive: true });let failures = 0, passes = 0;function check(label, ok, detail = '') {console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`);if (ok) passes++; else failures++;}const sleep = (ms) => new Promise(r => setTimeout(r, ms));let server = null, browser = null, log = '';async function stopServer() {if (server) {const s = server;try { s.kill('SIGTERM'); } catch {}await new Promise(r => { if (s.exitCode !== null || s.signalCode !== null) return r(); s.once('exit', r); setTimeout(r, 3000); });server = null;}}async function stop() {if (browser) { try { await browser.close(); } catch {} browser = null; }await stopServer();}async function main() {const MPACKDB = join(STORE, 'mpackdb');mkdirSync(MPACKDB, { recursive: true });const seedOut = execFileSync(join(APP, 'bin/hybriel'), ['tests/seed-show.hl'], { cwd: APP, env: { ...process.env, TRACKER_STORAGE: MPACKDB, TRACKER_SEED_IDENTITY: 'mobile-gate-identity' } }).toString()+ execFileSync(join(APP, 'bin/hybriel'), ['tests/seed-mobile.hl'], { cwd: APP, env: { ...process.env, TRACKER_STORAGE: MPACKDB } }).toString();check('seed: the fixture shows + a user who follows them (tests/seed-show.hl), a franchise and 100 loose timelines (tests/seed-mobile.hl)', seedOut.includes('gate-test-show') && seedOut.includes('100 loose timelines'), seedOut);// the signed-in session: a session file named by the sha256 of its id (as hl:web writes them), the user id of the seeded userconst sid = 'a1b2c3d4e5f60718293a4b5c6d7e8f90';const now = Date.now();writeFileSync(join(SESSIONS, createHash('sha256').update(sid).digest('hex')), JSON.stringify({ created: now, data: { tag: 't' }, id: sid, seen: now, user: { id: 'gateu0000000000u1' } }));server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, env: { ...process.env, TRACKER_WARM_SYNC_MS: '600000', TRACKER_PORT: String(PORT), TRACKER_SESSIONS: SESSIONS + '/', TRACKER_STORAGE: MPACKDB,TRACKER_WATCH: '0', TRACKER_URL: BASE, HL_HOST: '127.0.0.1', TRACKER_EDITORS: 'mobile-gate-identity', TRACKER_SYNC: '0', TRACKER_ART: '0', TRACKER_PHOTOS: '0', TRACKER_BACKFILL: '0', TRACKER_REPAIR: '0', TRACKER_KINDS: '0',TRACKER_CREDITS: '0', TRACKER_COLLECTIONS: '0', TRACKER_FRANCHISE_SEED: '0', TMDB_READ_TOKEN: '' }, stdio: ['ignore', 'pipe', 'pipe'] });server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);for (let i = 0; ; i++) {checkServerExit(server, 'tracker', log);try { if ((await fetch(BASE + '/')).ok) break; } catch {}if (i > 600) throw new Error('tracker did not come up (150 s; a cold start compiles the app first, hybriel#148)\n' + log);await sleep(250);}browser = await launchBrowser({ debugPortRange: [CH_FROM, CH_TO] });const page = await browser.newPage();const ev = (e) => page.evaluate(e);const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 60000, label: 'hydrated' });const shot = async (name) => { if (SHOTS) writeFileSync(join(SHOTS, name + '.png'), Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64')); };const go = async (path) => { const t = Date.now(); await page.goto(BASE + path, { timeout: 60000 }); await hydrated(); await sleep(500); return Date.now() - t; };// a real touch tap (touchStart + touchEnd at the centre of the element), as a finger doesconst tap = async (x, y) => { await page.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [{ x, y }] }); await page.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] }); await sleep(600); };const tapSel = async (sel, text) => {const r = await ev(`(() => { const all = [...document.querySelectorAll(${JSON.stringify(sel)})]; const e = ${text ? `all.find(b => b.textContent.trim() === ${JSON.stringify(text)})` : 'all[0]'}; if (!e) return null; e.scrollIntoView({ block: 'center' }); const q = e.getBoundingClientRect(); return { x: q.left + q.width / 2, y: q.top + q.height / 2 }; })()`);if (!r) return false; await tap(r.x, r.y); return true;};await page.send('Network.setCookie', { name: 'trackersid', value: sid, url: BASE });await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 3, mobile: true });await page.send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });// ==== every page: no sideways scroll, every tap target ≥ 44 px, fields ≥ 16 px ====const PAGES = [['my-series', '/my/series', 'my-show-row'], ['my-unwatched', '/my/unwatched', 'unwatched-row'], ['my-schedule', '/my/schedule', 'schedule-row'], ['search', '/search/gate', 'search-row'],['title', '/series/gate-test-show', 'show-header'], ['movie-widget', '/movies/pager-movie-01', 'a.fw-franchise'], ['franchises', '/franchises', 'a.franchise-row'], ['franchise', '/franchises/mobile-franchise', 'a.timeline-name'],['timeline-edit', '/timelines/mobile-timeline-alpha/edit', 'a.edit-new-franchise'], ['login-failed', '/login/failed', 'a#home']];for (const [name, path, must] of PAGES) {await go(path);await ev('window.__W = 390');const m = await ev(MEASURE);const there = await ev(`!!document.querySelector(${JSON.stringify(must)})`);await shot('mobile-' + name + '-390');check(`390 ${path}: the page shows what it is about (${must})`, there, JSON.stringify({ h1: await ev(`(document.querySelector('h1') || {}).innerText`) }));check(`390 ${path}: no sideways scroll, every tap target ≥ 44 px, every field ≥ 16 px`, !m.hscroll && m.tapsSmall === 0 && m.inputsSmall === 0, JSON.stringify({ sw: m.docScrollWidth, small: m.tapsSmallList, inputs: m.inputsSmallList }));}// the badges stay small to the eye (24 px pill: the 44 px tap area is transparent border, the background stops at the padding box)await go('/series/gate-test-show');const badge = await ev(`JSON.stringify(Array.from(document.querySelectorAll('a.extlink')).map(e => [e.clientHeight, getComputedStyle(e).backgroundClip, Math.round(e.getBoundingClientRect().height)]))`).then(JSON.parse);check('title: the TMDB / IMDb badges look 24 px high (padding box, background clipped to it) with a 44 px tap box', badge.length >= 2 && badge.every(b => b[0] <= 26 && b[1] === 'padding-box' && b[2] >= 44), JSON.stringify(badge));// ==== a season of 160 episodes starts closed (the real data has a soap with 1,175 in one: a 69,000 px page) ====await go('/series/mobile-soap');const soapInfo = async () => ev(`JSON.stringify({ rows: document.querySelectorAll('episode-row').length, toggles: document.querySelectorAll('button.season-toggle').length, open: document.querySelectorAll('season-row.expanded').length, h: document.documentElement.scrollHeight })`).then(JSON.parse);const so1 = await soapInfo();await shot('mobile-soap-closed-390');check('title: a season of 160 episodes starts CLOSED on a phone — its header, no episode rows, a short page', so1.toggles === 1 && so1.rows === 0 && so1.open === 0 && so1.h < 2500, JSON.stringify(so1));check('title: a real touch tap on that season\'s header opens it: its 160 episodes (and the closed season of a short series still opens as before: Gate Test Show\'s last season starts open)',await tapSel('button.season-toggle') && await page.waitFor(`document.querySelectorAll('episode-row').length >= 160`, { timeout: 20000 }).then(() => true, () => false)&& await (async () => { await go('/series/gate-test-show'); const g = await soapInfo(); return g.toggles === 2 && g.open === 1 && g.rows >= 1; })(), JSON.stringify(await soapInfo()));// ==== TP (the creator: "the episodes are too far away from each other, the season is not properly vertically aligned") ====// the season list is DENSE: two episode rows are at most 2.25rem (36 px) apart (the check keeps its 44 px tap box through a negative margin), the season's check icon// sits on the middle of the season title line (±2 px) and the episodes' checks are in the same column. At 390 AND at 1280.const seasonLook = () => ev(`(() => {const rows = Array.from(document.querySelectorAll('episode-row')).slice(0, 30), tops = rows.map(r => r.querySelector('episode-number').getBoundingClientRect().top);const pitch = tops.slice(1).map((t, i) => Math.round((t - tops[i]) * 10) / 10);const sr = document.querySelector('season-row'), rg = document.createRange(); rg.selectNodeContents(sr.querySelector('season-label'));const t = rg.getBoundingClientRect(), c = sr.querySelector('button.checkicon svg circle').getBoundingClientRect(), e = rows[0].querySelector('button.checkicon svg circle').getBoundingClientRect();const tb = rows[0].querySelector('button.checkicon').getBoundingClientRect();return JSON.stringify({ n: rows.length, maxPitch: Math.max(...pitch), minPitch: Math.min(...pitch), dy: Math.round(Math.abs((c.top + c.height / 2) - (t.top + t.height / 2)) * 10) / 10, dx: Math.round(Math.abs((c.left + c.width / 2) - (e.left + e.width / 2)) * 10) / 10, tap: Math.round(tb.height) });})()`).then(JSON.parse);for (const [w, mob] of [[390, true], [1280, false]]) {await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: 900, deviceScaleFactor: mob ? 3 : 1, mobile: mob });await go('/series/mobile-soap');await tapSel('button.season-toggle');await page.waitFor(`document.querySelectorAll('episode-row').length >= 30`, { timeout: 20000 }).catch(() => {});const sl = await seasonLook();await ev(`window.scrollTo(0, document.querySelector('season-row').getBoundingClientRect().top + scrollY - 140)`);await shot('tp-season-' + w);check(`${w}: a long season is dense — two episode rows are at most 2.25rem (36 px) apart (and not squeezed below 1.5rem), the check keeps its 44 px tap box`, sl.n >= 30 && sl.maxPitch <= 36 && sl.minPitch >= 24 && sl.tap >= 43.5, JSON.stringify(sl));check(`${w}: the season's check icon is centred on the season title line (within 2 px) and the episode checks are in the same column (within 1 px)`, sl.dy <= 2 && sl.dx <= 1, JSON.stringify(sl));}await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 3, mobile: true });// ==== TP: the theme's pills on the title page and in the lists: class `pill`, small to the eye (≤ 1.6rem), a 44 px tap box when a link ====const pillsOn = (sel) => ev(`JSON.stringify(Array.from(document.querySelectorAll(${JSON.stringify(sel)})).map(e => [e.classList.contains('pill'), e.clientHeight, Math.round(e.getBoundingClientRect().height), e.tagName === 'A', getComputedStyle(e).backgroundClip]))`).then(JSON.parse);for (const [w, mob] of [[390, true], [1280, false]]) {await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: 900, deviceScaleFactor: mob ? 3 : 1, mobile: mob });await go('/series/gate-test-show');const ps = await pillsOn('show-title .pill'), pl = await pillsOn('a.extlink'), pg = await pillsOn('a.genre-pill');await shot('tp-title-' + w);check(`${w}: the status is a theme pill (class pill) that looks small (≤ 25.6 px)`, ps.length === 1 && ps.every(p => p[0] && p[1] <= 25.6), JSON.stringify(ps));check(`${w}: the TMDB / IMDb links and the genres are theme pills, small to the eye (≤ 25.6 px, background clipped to the padding box) with a 44 px tap box`,pl.length >= 2 && pg.length >= 1 && [...pl, ...pg].every(p => p[0] && p[1] <= 25.6 && p[2] >= 43.5 && p[4] === 'padding-box'), JSON.stringify([pl, pg]));await go('/search/gate');const pk = await pillsOn('search-row .pill');await shot('tp-search-' + w);check(`${w}: the search lists the kind of a title as a theme pill (class pill), small`, pk.length >= 1 && pk.every(p => p[0] && p[1] <= 25.6), JSON.stringify(pk));await go('/franchises/mobile-franchise');const pf = await pillsOn('a.timeline-item .pill');await shot('tp-franchise-' + w);check(`${w}: a franchise's timeline rows show the kind (Series / Movie) as a theme pill (class pill), small`, pf.length >= 1 && pf.every(p => p[0] && p[1] <= 25.6), JSON.stringify(pf));}await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 3, mobile: true });// ==== /franchises: 40 timelines per page, a pager, a touch tap works ====const info = async () => ev(`JSON.stringify({ path: location.pathname, links: document.querySelectorAll('a.timeline-link').length, franchises: document.querySelectorAll('a.franchise-row').length, first: (document.querySelector('a.timeline-link timeline-link-name') || {}).textContent || null,last: (Array.from(document.querySelectorAll('a.timeline-link timeline-link-name')).pop() || {}).textContent || null, pager: !!document.querySelector('pager-box pagination'), cur: ((document.querySelector('pagination li.current') || {}).textContent || '').trim() || null,count: (document.querySelector('p.list-count') || {}).textContent || null, h: document.documentElement.scrollHeight, title: document.title })`).then(JSON.parse);const ms1 = await go('/franchises');const p1 = await info();check('franchises: the first page lists the franchise AND 40 of the 100 timelines (by name), a pager, "page 1 of 3", loaded in under 2 s (the real data\'s 1,546 took 20 s)',p1.links === 40 && p1.franchises === 1 && p1.first === 'Mobile Collection 001' && p1.last === 'Mobile Collection 040' && p1.pager && p1.cur === '1' && /100 timelines without a franchise · page 1 of 3/.test(p1.count) && ms1 < 2000, JSON.stringify({ ...p1, ms1 }));check('franchises: the page is short on a phone (40 rows, not the whole list: under 3,000 px)', p1.h < 3000, JSON.stringify(p1));check('franchises: a real touch tap on "Next" goes to /franchises/page/2: 40 more timelines, no franchise list again',await tapSel('pagination button', 'Next') && await page.waitFor(`location.pathname === '/franchises/page/2' && document.querySelectorAll('a.timeline-link').length > 0`, { timeout: 10000 }).then(() => true, () => false) && await (async () => {await sleep(500); const p2 = await info(); await shot('mobile-franchises-p2-390');return p2.links === 40 && p2.franchises === 0 && p2.first === 'Mobile Collection 041' && p2.last === 'Mobile Collection 080' && p2.cur === '2' && /page 2 of 3/.test(p2.count) && /page 2/.test(p2.title);})(), JSON.stringify(await info()));check('franchises: a real touch tap on page "3" shows the last 20, and no "No franchises yet." on a later page',await tapSel('pagination button', '3') && await page.waitFor(`location.pathname === '/franchises/page/3'`, { timeout: 10000 }).then(() => true, () => false) && await (async () => {await sleep(500); const p3 = await info();return p3.links === 20 && p3.first === 'Mobile Collection 081' && p3.last === 'Mobile Collection 100' && p3.cur === '3' && !(await ev(`document.body.innerText.includes('No franchises yet')`));})(), JSON.stringify(await info()));await go('/franchises/page/99');const p99 = await info();await go('/franchises/page/abc');const pabc = await info();check('franchises: page 99 is the last page, "abc" the first', p99.links === 20 && p99.cur === '3' && pabc.links === 40 && pabc.cur === '1' && pabc.franchises === 1, JSON.stringify({ p99, pabc }));// a timeline of the list still opensawait go('/franchises');check('franchises: a real touch tap on a timeline opens it', await tapSel('a.timeline-link') && await page.waitFor(`location.pathname === '/timelines/mobile-collection-001'`, { timeout: 10000 }).then(() => true, () => false), await ev('location.pathname'));// IW4: signed in on a narrow phone, the brand "tracker" must show whole (not "trac…"), and every header item stays inside the screen and 44 px tallfor (const W of [360, 390]) {await page.send('Emulation.setDeviceMetricsOverride', { width: W, height: 844, deviceScaleFactor: 3, mobile: true });await go('/my/series');await page.waitFor(`!!document.querySelector('application-header ident-selector') && !!document.querySelector('application-header ident-selector').shadowRoot && !!document.querySelector('application-header ident-selector').shadowRoot.querySelector('[part~="status"], [part~="button"]')`, { timeout: 10000, label: 'selector drawn' }).catch(() => {});await sleep(500);await shot('header-signedin-' + W);const hm = await ev(`JSON.stringify((() => { const h = document.querySelector('application-header'); const b = h.querySelector('a.brand');const items = [...h.children].filter(e => { const r = e.getBoundingClientRect(); return r.width > 0 && getComputedStyle(e).display !== 'none' }).map(e => { const r = e.getBoundingClientRect(); return { tag: e.tagName.toLowerCase() + (e.className ? '.' + e.className : ''), l: Math.round(r.left * 10) / 10, r: Math.round(r.right * 10) / 10, h: Math.round(r.height * 10) / 10 } });return { brandText: b.textContent, scrollW: b.scrollWidth, clientW: b.clientWidth, items, user: !!h.querySelector('button.user-toggle'), pill: (() => { const e = h.querySelector('ident-selector').shadowRoot.querySelector('[part~="status"]'); return e ? [e.scrollWidth, e.clientWidth] : null })() } })())`).then(JSON.parse);check(`IW4 ${W}px signed in: the brand shows whole (scrollWidth <= clientWidth), every header item is inside the screen and 44 px tall`,hm.user && hm.scrollW <= hm.clientW && hm.items.every(i => i.l >= 0 && i.r <= W && i.h >= 44), JSON.stringify(hm));}// IW4 proof shots (only with TRACKER_GATE_SHOTS): the header at 360, 390 and 1280, signed in and signed out, plus the size of every header control as JSONif (SHOTS) {const ctl = {};for (const [state, signedIn] of [['signedin', true], ['signedout', false]]) {if (signedIn) await page.send('Network.setCookie', { name: 'trackersid', value: sid, url: BASE });else await page.send('Network.deleteCookies', { name: 'trackersid', url: BASE });for (const W of [360, 390, 1280]) {await page.send('Emulation.setDeviceMetricsOverride', { width: W, height: 844, deviceScaleFactor: W > 800 ? 1 : 3, mobile: W < 800 });await go('/my/series');await sleep(800);await shot(`header-${state}-${W}`);ctl[`${state}-${W}`] = await ev(`JSON.stringify([...document.querySelector('application-header').querySelectorAll(':scope > *, :scope > user-menu > button, :scope > main-menu > a')].filter(e => e.getBoundingClientRect().width > 0).map(e => { const r = e.getBoundingClientRect(); const c = getComputedStyle(e); return [e.tagName.toLowerCase() + (e.className && typeof e.className === 'string' ? '.' + e.className : ''), Math.round(r.left * 10) / 10, Math.round(r.width * 10) / 10, Math.round(r.height * 10) / 10, c.fontSize, c.marginLeft + '/' + c.marginRight] }))`).then(JSON.parse);}}writeFileSync(join(SHOTS, 'header-controls.json'), JSON.stringify(ctl, null, 1));}const problems = page.problems ? page.problems() : [];check('browser: no console errors / failed requests', problems.length === 0, JSON.stringify(problems).slice(0, 2000));}try { await main(); } catch (e) {check('gate ran without throwing', false, (e && e.stack) || String(e));console.log('server log (tail):\n' + log.slice(-3000));}await stop();console.log(`\n${passes} passed, ${failures} failed`);process.exit(failures ? 1 : 0);
Branches
Latest commits
- d2e6d26bMerge branch 'records-park55' into mainTracker
- f567f025|||PR records: park #55, no Claude workers ruleTracker
- c21aff6bMerge branch 'records-hm55c' into mainTracker
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker