gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6f7bd3926f7bd392gate: the phone toolbar is two even rows (E2)mre6f7bd392/tests/e2e-197.mjs

8.3 KB

  1. // usage: TAB=<id of an existing about:blank tab> node tests/e2e-197.mjs <base url> <shot prefix> [CDP port]; mission 011: MainMenu marks the page from the route (hybriel#197), real Chrome via CDP, hold lisbeth.lock
  2. // mission 009 real-Chrome e2e (lisbeth's Chrome through CDP): ONE existing page tab (picked fresh from /json), real mouse clicks,
  3. // 390 (phone: sidebar + main menu) and 1280. The current marker moves with each page: aria-current, the bar, contrast >= 3:1 for every accent,
  4. // the count badge and current=true on the tracker demo. Leaves the tab at about:blank. Hold the lock: flock lisbeth.lock.
  5. import { writeFileSync } from 'node:fs';
  6. const [BASE, PREFIX, CDP = '9223'] = process.argv.slice(2);
  7. const SH = '/media/STORAGE/claude-scratch/atlas-evidence/L6/';
  8. const tabs = await (await fetch(`http://127.0.0.1:${CDP}/json`)).json();
  9. const tab = tabs.find(t => t.type === 'page' && t.id === process.env.TAB);
  10. if (!tab) throw new Error('no page tab');
  11. const ws = new WebSocket(tab.webSocketDebuggerUrl.replace(/ws:\/\/[^/]+/, `ws://127.0.0.1:${CDP}`));
  12. await new Promise(r => ws.onopen = r);
  13. let id = 0; const pend = new Map();
  14. ws.onmessage = (m) => { const d = JSON.parse(m.data); if (d.id && pend.has(d.id)) { pend.get(d.id)(d); pend.delete(d.id); } };
  15. const send = (method, params = {}) => new Promise((res, rej) => { const i = ++id; pend.set(i, (d) => d.error ? rej(new Error(method + ': ' + JSON.stringify(d.error))) : res(d.result)); ws.send(JSON.stringify({ id: i, method, params })); });
  16. const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  17. const ev = async (e) => { const r = await send('Runtime.evaluate', { expression: e, returnByValue: true, awaitPromise: true }); if (r.exceptionDetails) throw new Error(JSON.stringify(r.exceptionDetails).slice(0, 300)); return r.result.value; };
  18. const shot = async (n) => { const { data } = await send('Page.captureScreenshot', { format: 'png' }); writeFileSync(SH + `e2e-${PREFIX}-${n}.png`, Buffer.from(data, 'base64')); };
  19. const results = [];
  20. const check = (l, ok, d = '') => { results.push(ok); console.log((ok ? 'ok ' : 'FAIL ') + l + (ok ? '' : ' — ' + d)); };
  21. const waitFor = async (e, ms = 15000) => { const t = Date.now(); while (Date.now() - t < ms) { try { if (await ev(e)) return true; } catch {} await sleep(150); } return false; };
  22. const open = async (p) => { await send('Page.navigate', { url: BASE + p }); await sleep(600); await waitFor('document.readyState === "complete" && !!document.querySelector("application-header")', 30000); await sleep(500); };
  23. const click = async (sel) => { await ev(`document.querySelector(${JSON.stringify(sel)}).scrollIntoView({ block: 'nearest' })`); await sleep(120); const b = await ev(`(() => { const r = document.querySelector(${JSON.stringify(sel)}).getBoundingClientRect(); return [r.left + r.width / 2, r.top + r.height / 2]; })()`); for (const type of ['mouseMoved', 'mousePressed', 'mouseReleased']) await send('Input.dispatchMouseEvent', { type, x: b[0], y: b[1], button: 'left', clickCount: 1, buttons: type === 'mousePressed' ? 1 : 0 }); await sleep(150); };
  24. const waitPath = (p) => waitFor(`location.pathname === ${JSON.stringify(p)}`, 15000);
  25. const size = (w) => send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });
  26. const lum = (c) => { const v = c.map(x => { x /= 255; return x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); }); return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2]; };
  27. const ratio = (a, b) => { const x = lum(a), y = lum(b); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); };
  28. const rgbOf = (s) => (String(s).match(/rgba?\(([^)]+)\)/) || [0, '0,0,0'])[1].split(',').slice(0, 3).map(Number);
  29. const marks = (root) => ev(`[...document.querySelectorAll(${JSON.stringify(root + ' a')})].filter(a => a.getAttribute('aria-current') === 'page').map(a => a.firstChild.textContent.trim())`);
  30. const J = JSON.stringify;
  31. const style = (sel) => ev(`(() => { const a = document.querySelector(${J(sel)}); if (!a) return null; const c = getComputedStyle(a); const r = a.getBoundingClientRect(); return { color: c.color, bg: c.backgroundColor, shadow: c.boxShadow, h: r.height }; })()`);
  32. // the marker: a bar (box-shadow) that is not none, bar >= 3:1 and text >= 3:1 against the link's own background (which is the surface)
  33. const barOk = (m) => !!m && m.shadow !== 'none' && ratio(rgbOf(m.shadow), rgbOf(m.bg)) >= 3 && ratio(rgbOf(m.color), rgbOf(m.bg)) >= 3;
  34. const barCr = (m) => m ? `bar ${ratio(rgbOf(m.shadow), rgbOf(m.bg)).toFixed(2)} text ${ratio(rgbOf(m.color), rgbOf(m.bg)).toFixed(2)}` : 'none';
  35. const accentTest = async (w, sel) => {
  36. const accents = ['blue-dark', 'green-dark', 'yellow', 'orange', 'red', 'purple', 'blue-light', 'green-light'];
  37. const seen = {};
  38. for (const a of accents) {
  39. await click(`accent-switcher button[value="${a}"]`);
  40. await sleep(200);
  41. const m = await style(sel);
  42. seen[a] = barCr(m);
  43. check(`${w} accent ${a}: the marked link has a bar and contrast >= 3:1 (${seen[a]})`, barOk(m), J(m));
  44. }
  45. await click('accent-switcher button.reset'); await sleep(150);
  46. };
  47. const ssr = async (p) => { const h = await (await fetch(BASE + p)).text(); return [...h.matchAll(/<main-menu>.*?<\/main-menu>/gs)].map(m => [...m[0].matchAll(/class="current" aria-current="page">([^<]*)/g)].map(x => x[1]).join(',')); };
  48. await send('Page.bringToFront');
  49. try {
  50. console.log('tab', tab.id, 'base', BASE);
  51. for (const [p, w] of [['/shells/content-first/genre', 'Genres'], ['/shells/content-first/person', 'People'], ['/shells/content-first/show', 'Shows']]) {
  52. const g = await ssr(p);
  53. check('SSR HTML of ' + p + ' (no script run): header and sidebar menu already marked ' + w, g.length === 2 && g.every(x => x === w), J(g));
  54. }
  55. // ---- 1280 ----
  56. await size(1280);
  57. const H = 'application-header main-menu';
  58. await open('/shells/content-first/genre');
  59. check('1280 hard load of /genre: Genres marked, nothing else', J(await marks(H)) === '["Genres"]', J(await marks(H)));
  60. await shot('1280-1-genre');
  61. await click(H + ' a[href="/shells/content-first/person"]'); await waitPath('/shells/content-first/person'); await sleep(500);
  62. check('1280 real click People: marker moved to People', J(await marks(H)) === '["People"]', J(await marks(H)));
  63. await shot('1280-2-person');
  64. await click(H + ' a[href="/shells/content-first/show"]'); await waitPath('/shells/content-first/show'); await sleep(500);
  65. check('1280 real click Shows: marker moved to Shows, badge 12 still there', J(await marks(H)) === '["Shows"]' && (await ev(`document.querySelector(${J(H + ' a.current span.count')}).textContent`)) === '12', J(await marks(H)));
  66. await ev('history.back()'); await waitPath('/shells/content-first/person'); await sleep(500);
  67. check('1280 browser Back: marker follows to People', J(await marks(H)) === '["People"]', J(await marks(H)));
  68. await open('/shells/content-first');
  69. check('1280 /shells/content-first (no item path): Series by the item flag fallback', J(await marks(H)) === '["Series"]', J(await marks(H)));
  70. // ---- 390 ----
  71. await size(390);
  72. const S = '#sidebar main-menu';
  73. const openSide = async () => { await click('application-header .menu-toggle'); await waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, 8000); await sleep(300); };
  74. const closeSide = () => ev(`(() => { const s = document.querySelector('#sidebar'); if (s && s.matches(':popover-open')) s.hidePopover(); return 1; })()`);
  75. await open('/shells/content-first/genre');
  76. await openSide();
  77. check('390 hard load of /genre: phone menu has Genres marked', J(await marks(S)) === '["Genres"]', J(await marks(S)));
  78. await shot('390-1-genre');
  79. await click(S + ' a[href="/shells/content-first/movie"]'); await waitPath('/shells/content-first/movie'); await sleep(500);
  80. await openSide();
  81. check('390 real tap Movies, reopen: marker moved to Movies', J(await marks(S)) === '["Movies"]', J(await marks(S)));
  82. await shot('390-2-movie');
  83. await click(S + ' a[href="/shells/content-first/person"]'); await waitPath('/shells/content-first/person'); await sleep(500);
  84. await openSide();
  85. check('390 real tap People, reopen: marker moved to People', J(await marks(S)) === '["People"]', J(await marks(S)));
  86. await shot('390-3-person');
  87. await closeSide();
  88. } catch (e) { console.log('ERROR', e.message); results.push(false); }
  89. console.log(PREFIX, results.filter(Boolean).length, 'ok', results.filter(x => !x).length, 'FAIL');
  90. try { await send('Emulation.clearDeviceMetricsOverride'); await send('Page.navigate', { url: 'about:blank' }); } catch {}
  91. ws.close();

Branches

Latest commits

  • 6f7bd392gate: the phone toolbar is two even rows (E2)mre
  • 3049c082sync components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • b9a3f85fLOG: MLmre
  • 7979397creport ML-mobilemre
  • 85d2ed25gate: wordingmre
  • 98a311c0gate: 390 px checks for list rows, table word, edited tap target, code in titlesmre
  • 769b99d7theme: table cells keep a word whole, code in a title stays text-sized, 'edited' is a 44 px tap target on the phonemre
  • 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