layouts
All repositories: gitoria
5.7 KB
// tests/walk.mjs — walk every page of the showcase in an ALREADY RUNNING real Chrome (lisbeth's LLM test Chrome through an ssh// tunnel) and write the display audit + screenshots. ONE existing tab is reused (navigated); nothing is opened or closed, the// system clipboard is not used.// HL_CDP_URL=http://127.0.0.1:9223 node tests/walk.mjs <app base url as the browser sees it> <out dir> [tab id]import { writeFileSync, mkdirSync } from 'node:fs';import { join } from 'node:path';import { launchBrowser, Page, sleep } from './cdp.mjs';import { AUDIT } from './taps-audit.mjs';import { DISPLAY } from './display-audit.mjs';const [BASE, OUT, TAB] = process.argv.slice(2);mkdirSync(OUT, { recursive: true });export const PAGES = ['/', '/elements', '/components', '/components/month-view', '/components/date-picker', '/components/range-picker', '/components/pagination', '/components/md-editor', '/components/code-editor', '/components/file-upload', '/components/files-upload', '/components/files-upload-pick', '/components/modal', '/components/comments', '/shells', '/shells/content-first', '/shells/content-first/movie', '/shells/list-first', '/shells/list-first/trip', '/shells/three-pane', '/shells/three-pane/m2', '/docs', '/read/using-the-theme', '/read/readme-modal', '/read/layouts-app-header', '/settings', '/search/modal', '/search/zzzz'];const browser = await launchBrowser();let id = TAB;if (!id) { const list = await (await fetch(process.env.HL_CDP_URL + '/json/list')).json(); const blanks = list.filter(t => t.type === 'page' && t.url === 'about:blank'); id = (blanks[blanks.length - 1] || {}).id; }if (!id) throw new Error('no existing page tab to reuse');const { sessionId } = await browser.conn.send('Target.attachToTarget', { targetId: id, flatten: true });const page = new Page(browser, id, sessionId);await page._init();const size = (w) => page.send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });const shot = async (name) => { for (let k = 0; k < 3; k++) { try { await page.send('Page.bringToFront'); const { data } = await page.send('Page.captureScreenshot', { format: 'png', fromSurface: true }); writeFileSync(join(OUT, name + '.png'), Buffer.from(data, 'base64')); return; } catch (e) { await sleep(1500); } } console.log('NO SHOT', name); };const open = async (path) => { await page.goto(BASE + path, { timeout: 60000 }); await page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 40000, label: 'hydrated ' + path }).catch(() => {}); await sleep(500); };const slug = (p) => (p === '/' ? 'home' : p.slice(1).replace(/\//g, '_'));const results = [];const audit = async (label, w) => {const d = await page.evaluate(DISPLAY);const t = w < 600 ? await page.evaluate(AUDIT) : null;results.push({ label, w, d, taps: t ? t.taps.filter(x => !x.inline) : [], inputs: t ? t.inputs : [] });};for (const w of [390, 1280]) {await size(w);for (const p of PAGES) {await open(p);await page.evaluate('window.scrollTo(0,0)');await shot(`${slug(p)}-${w}`);await audit(p, w);for (const [name, sel] of [['sidebar', 'application-header .menu-toggle'], ['search', 'application-header .search-toggle'], ['user', 'user-menu .user-toggle']]) {const vis = await page.evaluate(`(() => { const e = document.querySelector(${JSON.stringify(sel)}); return !!e && getComputedStyle(e).display !== 'none' && e.getBoundingClientRect().width > 0; })()`);if (!vis) continue;await page.click(sel);await sleep(350);await shot(`${slug(p)}-${w}-${name}`);await audit(`${p} [${name} open]`, w);await page.send('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });await page.send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });await sleep(200);}}}// the modal dialog and the page's own opened statesfor (const w of [390, 1280]) {await size(w);await open('/components/modal');const btn = await page.evaluate(`(() => { const b = [...document.querySelectorAll('main button')].find(x => /open|show/i.test(x.textContent)); if (!b) return null; b.setAttribute('data-walk', '1'); return b.textContent.trim(); })()`);if (btn) { await page.click('[data-walk="1"]'); await sleep(500); await shot(`modal-open-${w}`); await audit('/components/modal [dialog open]', w); }}writeFileSync(join(OUT, 'audit.json'), JSON.stringify(results, null, 1));let n = 0;for (const r of results) {const d = r.d, bits = [];if (d.hscroll) bits.push(`hscroll sw=${d.sw}`);if (d.wide.length) bits.push(`wide:${d.wide.length} e.g. ${JSON.stringify(d.wide[0])}`);const clip = d.clipped.filter(c => !c.ellipsis); if (clip.length) bits.push(`clipped:${clip.length} e.g. ${JSON.stringify(clip[0])}`);if (d.overlaps.length) bits.push(`overlaps:${d.overlaps.length} e.g. ${JSON.stringify(d.overlaps[0])}`);if (d.covered.length) bits.push(`covered:${d.covered.length} e.g. ${JSON.stringify(d.covered[0])}`);if (d.contrast.length) bits.push(`contrast:${d.contrast.length} e.g. ${JSON.stringify(d.contrast[0])}`);if (d.spill.length) bits.push(`spill:${d.spill.length} e.g. ${JSON.stringify(d.spill[0])}`);if (d.stray.length) bits.push(`stray popovers:${d.stray.length} e.g. ${JSON.stringify(d.stray[0])}`);if (d.underHeader) bits.push('underHeader ' + JSON.stringify(d.underHeader));if (r.taps.length) bits.push(`taps<44:${r.taps.length} e.g. ${JSON.stringify(r.taps[0])}`);if (r.inputs.length) bits.push(`input<16px:${r.inputs.length}`);if (bits.length) { n++; console.log(`${r.w} ${r.label}: ${bits.join(' ; ')}`); }}console.log(`${results.length} audits, ${n} with findings`);try { await page.send('Emulation.clearDeviceMetricsOverride'); } catch {}browser.conn.close();
Branches
Latest commits
- c36b7595list rows (notes, mail) stack their parts full width: the date no longer a one-letter column beside the titlemre
- 02aa74aasync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
- 268b1c87sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
- c51d039fsync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre
- f4ad7eecsync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
- db258c11sync-components: copy icons/icons.hl + README (F4); testsmre
- badc1879md-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
- 867a8375md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- 5d8d2c67tests: wait for hydration before real clicks after a navigation (H2)mre
- 99db79f0re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- 30353f60tests: e2e-md-showcase Chrome range from LAYOUTS_GATE_CHROME_MD, default unchangedmre
- 16a7878cre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 6af559e8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 5599cf56deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 0bcc6294Mission 011: e2e-197, brief, report, LOGmre
- 137303c5MainMenu marks the current page from the route (hybriel#197, server-rendered); current prop/item.current stay as fallback; tracker demo drops current; gate: SSR marker; docsmre
- 9325b403Re-vendor Hybriel to master 7f13a82f (hl:web batch 2: #190 #193 #197 #194 named regions); plugins whole, bin/hybriel static build (git-ignored)mre
- b31dc74dusage: calendar (theme 76f99f6-era ContentFirst, user menu, ☰ menu) and tracker (theme 76f99f6, modal + pagination current, own current marker until hybriel#197) rowsmre
- 8a3d5d40Mission 010: brief, report, LOG, STATUSmre
- a56abf1fSync components to components.hybriel 3794c59 (MdEditor real-key fixes); showcase real-key check on the md-editor pagemre