gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0573eed30573eed3usage: notes + tickets on MdEditor (md-editor.js retired), gitoria on theme dbe3de7, tracker theme oldermre0573eed3/tests/walk.mjs

5.7 KB

  1. // tests/walk.mjs — walk every page of the showcase in an ALREADY RUNNING real Chrome (lisbeth's LLM test Chrome through an ssh
  2. // tunnel) and write the display audit + screenshots. ONE existing tab is reused (navigated); nothing is opened or closed, the
  3. // system clipboard is not used.
  4. // 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]
  5. import { writeFileSync, mkdirSync } from 'node:fs';
  6. import { join } from 'node:path';
  7. import { launchBrowser, Page, sleep } from './cdp.mjs';
  8. import { AUDIT } from './taps-audit.mjs';
  9. import { DISPLAY } from './display-audit.mjs';
  10. const [BASE, OUT, TAB] = process.argv.slice(2);
  11. mkdirSync(OUT, { recursive: true });
  12. 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'];
  13. const browser = await launchBrowser();
  14. let id = TAB;
  15. 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; }
  16. if (!id) throw new Error('no existing page tab to reuse');
  17. const { sessionId } = await browser.conn.send('Target.attachToTarget', { targetId: id, flatten: true });
  18. const page = new Page(browser, id, sessionId);
  19. await page._init();
  20. const size = (w) => page.send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });
  21. 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); };
  22. 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); };
  23. const slug = (p) => (p === '/' ? 'home' : p.slice(1).replace(/\//g, '_'));
  24. const results = [];
  25. const audit = async (label, w) => {
  26. const d = await page.evaluate(DISPLAY);
  27. const t = w < 600 ? await page.evaluate(AUDIT) : null;
  28. results.push({ label, w, d, taps: t ? t.taps.filter(x => !x.inline) : [], inputs: t ? t.inputs : [] });
  29. };
  30. for (const w of [390, 1280]) {
  31. await size(w);
  32. for (const p of PAGES) {
  33. await open(p);
  34. await page.evaluate('window.scrollTo(0,0)');
  35. await shot(`${slug(p)}-${w}`);
  36. await audit(p, w);
  37. for (const [name, sel] of [['sidebar', 'application-header .menu-toggle'], ['search', 'application-header .search-toggle'], ['user', 'user-menu .user-toggle']]) {
  38. const vis = await page.evaluate(`(() => { const e = document.querySelector(${JSON.stringify(sel)}); return !!e && getComputedStyle(e).display !== 'none' && e.getBoundingClientRect().width > 0; })()`);
  39. if (!vis) continue;
  40. await page.click(sel);
  41. await sleep(350);
  42. await shot(`${slug(p)}-${w}-${name}`);
  43. await audit(`${p} [${name} open]`, w);
  44. await page.send('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });
  45. await page.send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });
  46. await sleep(200);
  47. }
  48. }
  49. }
  50. // the modal dialog and the page's own opened states
  51. for (const w of [390, 1280]) {
  52. await size(w);
  53. await open('/components/modal');
  54. 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(); })()`);
  55. if (btn) { await page.click('[data-walk="1"]'); await sleep(500); await shot(`modal-open-${w}`); await audit('/components/modal [dialog open]', w); }
  56. }
  57. writeFileSync(join(OUT, 'audit.json'), JSON.stringify(results, null, 1));
  58. let n = 0;
  59. for (const r of results) {
  60. const d = r.d, bits = [];
  61. if (d.hscroll) bits.push(`hscroll sw=${d.sw}`);
  62. if (d.wide.length) bits.push(`wide:${d.wide.length} e.g. ${JSON.stringify(d.wide[0])}`);
  63. const clip = d.clipped.filter(c => !c.ellipsis); if (clip.length) bits.push(`clipped:${clip.length} e.g. ${JSON.stringify(clip[0])}`);
  64. if (d.overlaps.length) bits.push(`overlaps:${d.overlaps.length} e.g. ${JSON.stringify(d.overlaps[0])}`);
  65. if (d.covered.length) bits.push(`covered:${d.covered.length} e.g. ${JSON.stringify(d.covered[0])}`);
  66. if (d.contrast.length) bits.push(`contrast:${d.contrast.length} e.g. ${JSON.stringify(d.contrast[0])}`);
  67. if (d.spill.length) bits.push(`spill:${d.spill.length} e.g. ${JSON.stringify(d.spill[0])}`);
  68. if (d.stray.length) bits.push(`stray popovers:${d.stray.length} e.g. ${JSON.stringify(d.stray[0])}`);
  69. if (d.underHeader) bits.push('underHeader ' + JSON.stringify(d.underHeader));
  70. if (r.taps.length) bits.push(`taps<44:${r.taps.length} e.g. ${JSON.stringify(r.taps[0])}`);
  71. if (r.inputs.length) bits.push(`input<16px:${r.inputs.length}`);
  72. if (bits.length) { n++; console.log(`${r.w} ${r.label}: ${bits.join(' ; ')}`); }
  73. }
  74. console.log(`${results.length} audits, ${n} with findings`);
  75. try { await page.send('Emulation.clearDeviceMetricsOverride'); } catch {}
  76. browser.conn.close();

Branches

Latest commits

  • 0573eed3usage: notes + tickets on MdEditor (md-editor.js retired), gitoria on theme dbe3de7, tracker theme oldermre
  • 78478f6eSync showcase to components.hybriel 1442e58: pick-mode page, comments attach, md-editor rows/files off; gates 285/0mre
  • dbe3de79Display bugs from a real Chrome walk (mission 007): Settings page and in-shell doc reader instead of raw .md links, closed phone search hidden whatever a page says, /elements form rules scoped, three-pane danger contrast; display audit gate (132 -> 244 checks), walk + Settings e2e toolsmre
  • 1875a051Theme: 44 px tap targets mobile first (layoutTap), 16 px fields, desktop denser only in @media 60rem; 390 px tap audit + gate checks (mission 006)mre
  • 3d4f8e19Sync showcase to components.hybriel 9db927d: comments and files-upload pages, pagination onPage, md-editor readonly, gate 99 checksmre
  • 64d635acmission brief 005mre
  • 0d0fef25paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • 2dbe0df5Re-vendor Hybriel to the shared static build 0f396652 (plugins; bin/ is git-ignored), compose cache volume + tmpfs /tmp, gate wait 120 s, report 004mre
  • 0adc551emission brief 004mre
  • 1376e905deploy.sh: wait up to DEPLOY_URL_WAIT (120 s) for 200 after the restart, as the other apps (cold compile, hybriel#148)mre
  • c0fdbf6cdocker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • ecf70665usage: layouts on components a567b57mre
  • 315731efcomponents re-synced to components.hybriel a567b57 (md-editor tables)mre
  • b59e2ee9docs/usage.md + tools/usage.sh: which app carries which component/theme/tokens copy, and whether it matches the sourcemre
  • 0222f67ctheme: two corner radii only (radiusSmall 5px, radiusLarge 10px); check-theme flags any other radius; gate 76/0mre
  • 877b63acdesign rules: two radii only (5px small, 10px large)mre
  • 635234dfcomponents re-synced to components.hybriel 5a98d77 (#15 black/white base look); gate 73/0, check-theme 0, screenshots unchangedmre
  • 876b2064docs: workaround note for hybriel#130 (slot marker mid-line)mre
  • 85b56541layouts mission 002 3/3: same-output tests, letcount, shots ports, docs, reportmre
  • 0f325d3blayouts mission 002 2/3: code rules — styles.hl -> components/styles.hl, the one never-reassigned let dropped; gate 73/0, same outputmre