gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain4099e64aMerge branch 'font-segoe-ui' into mainAtlasmain/tests/e2e-lisbeth.mjs

8.9 KB

  1. // usage: node tests/e2e-lisbeth.mjs <tab id of ONE existing tab> <base url> <shot prefix> before|after (needs: ssh -L 9223 to lisbeth, -R for the app port, test files in lisbeth:/tmp/atlas-S2-e2e)
  2. // real-Chrome e2e through lisbeth's CDP (9223): ONE existing tab (about:blank id given), real mouse/keys, DOM.setFileInputFiles, a paste event with a file.
  3. import { writeFileSync } from 'node:fs';
  4. const [TAB, BASE, PREFIX, MODE] = process.argv.slice(2); // MODE: before | after
  5. const SH = '/media/STORAGE/claude-scratch/atlas/S2/shots/';
  6. const ws = new WebSocket(`ws://127.0.0.1:9223/devtools/page/${TAB}`);
  7. await new Promise(r => ws.onopen = r);
  8. let id = 0; const pend = new Map();
  9. 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); } };
  10. 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 })); });
  11. const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  12. 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; };
  13. const shot = async (n) => { const { data } = await send('Page.captureScreenshot', { format: 'png' }); writeFileSync(SH + `${PREFIX}-${n}.png`, Buffer.from(data, 'base64')); };
  14. const results = [];
  15. const check = (l, ok, d = '') => { results.push(ok); console.log((ok ? 'ok ' : 'FAIL ') + l + (ok ? '' : ' — ' + d)); };
  16. 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; };
  17. const open = async (p) => { await send('Page.navigate', { url: BASE + p }); await sleep(500); await waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', 30000); await sleep(400); };
  18. const click = async (sel) => { await ev(`document.querySelector(${JSON.stringify(sel)}).scrollIntoView({ block: 'center' })`); 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); };
  19. const key = async (k, code, vk, text, modifiers = 0) => { await send('Input.dispatchKeyEvent', { type: 'keyDown', key: k, code, windowsVirtualKeyCode: vk, text, modifiers }); await send('Input.dispatchKeyEvent', { type: 'keyUp', key: k, code, windowsVirtualKeyCode: vk, modifiers }); await sleep(15); };
  20. const typeText = async (t) => { for (const ch of t) await key(ch, '', undefined, ch); };
  21. const fileInput = async (sel, files) => { const { root } = await send('DOM.getDocument'); const { nodeId } = await send('DOM.querySelector', { nodeId: root.nodeId, selector: sel }); await send('DOM.setFileInputFiles', { files, nodeId }); };
  22. const PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';
  23. const pasteFile = (sel, name) => ev(`(() => { const dt = new DataTransfer(); const b = Uint8Array.from(atob('${PNG}'), c => c.charCodeAt(0)); dt.items.add(new File([b], ${JSON.stringify(name)}, { type: 'image/png' })); const t = document.querySelector(${JSON.stringify(sel)}); t.focus(); t.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return true; })()`);
  24. const F = '/tmp/atlas-S2-e2e/';
  25. const noSide = async (l) => { const o = await ev('({ sw: document.documentElement.scrollWidth, w: innerWidth })'); check(l + ': no sideways scroll', o.sw <= o.w, JSON.stringify(o)); };
  26. await send('Page.bringToFront');
  27. console.log('UA/width tab', TAB, await ev('navigator.userAgent.slice(0,60)'));
  28. for (const w of [390, 1280]) {
  29. await send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });
  30. const P = `${w}`;
  31. if (MODE === 'before') {
  32. for (const [p, n] of [['/components/files-upload-pick', 'pick'], ['/components/comments', 'comments'], ['/components/md-editor', 'mdeditor']]) { await open(p); await shot(`${P}-${n}`); console.log(w, p, 'title:', await ev('document.title'), 'status heading:', await ev(`(document.querySelector('h1')||{}).textContent`)); }
  33. continue;
  34. }
  35. // ---- pick ----
  36. await open('/components/files-upload-pick');
  37. const pk = () => ev(`[...document.querySelectorAll('files-upload li.picked, files-upload li.refused')].map(li => (li.className.includes('refused') ? '!' : '') + li.querySelector('.name').textContent).join(',')`);
  38. await shot(`${P}-pick-1-empty`);
  39. await fileInput('files-upload label.choose input[type=file]', [F + 'pic.png', F + 'doc.pdf']);
  40. check(`${P} pick: choose picture + pdf → two rows, thumbnail drawn`, await waitFor(`document.querySelectorAll('files-upload li.picked').length === 2`) && await ev(`document.querySelector('files-upload li.picked img.thumb').naturalWidth >= 0 && !!document.querySelector('files-upload li.picked img.thumb')`), await pk());
  41. await click('#chat-text');
  42. await pasteFile('#chat-text', 'pasted.png');
  43. check(`${P} pick: paste a file → third row`, await waitFor(`document.querySelectorAll('files-upload li.picked').length === 3`), await pk());
  44. await shot(`${P}-pick-2-three`);
  45. await click('files-upload li.picked[data-i="1"] button.remove');
  46. check(`${P} pick: ✕ on doc.pdf removes it`, await waitFor(`document.querySelectorAll('files-upload li.picked').length === 2`) && (await pk()) === 'pic.png,pasted.png', await pk());
  47. await click('#chat-text'); await typeText('Hello two');
  48. await shot(`${P}-pick-3-typed`);
  49. await click('#chat-send');
  50. check(`${P} pick: Send → shown "Hello two", "2 files: pic.png, pasted.png", list emptied`, await waitFor(`document.querySelectorAll('#sent li').length === 1`) && (await ev(`document.querySelector('#sent .sent-files').textContent`)) === '2 files: pic.png, pasted.png' && (await pk()) === '', await ev(`document.querySelector('#sent').textContent`));
  51. await shot(`${P}-pick-4-sent`);
  52. await noSide(`${P} pick`);
  53. // ---- comments ----
  54. await open('/components/comments');
  55. await fileInput('comments-block files-upload label.choose input[type=file]', [F + 'pic.png', F + 'doc.pdf']);
  56. check(`${P} comments: choose 2 files → 2 waiting`, await waitFor(`document.querySelectorAll('comments-block li.picked').length === 2`));
  57. await pasteFile('comments-block form.comment-form md-editor article', 'shot.png');
  58. check(`${P} comments: paste into the editor (files=off) → 3 waiting`, await waitFor(`document.querySelectorAll('comments-block li.picked').length === 3`));
  59. await click('comments-block form.comment-form md-editor article'); await typeText('with **files**');
  60. await shot(`${P}-comments-1-attached`);
  61. await click('comments-block .comment-post, comments-block form.comment-form button[type=submit]');
  62. check(`${P} comments: the Comment button posts → told "post with 3 files", the new comment shows 3 file rows`, await waitFor(`document.querySelector('#comments-told').textContent === 'post with 3 files'`) && (await ev(`document.querySelectorAll('comments-block li.comment[data-id="n1"] .comment-file').length`)) === 3, await ev(`document.querySelector('#comments-told').textContent`));
  63. await shot(`${P}-comments-2-posted`);
  64. await noSide(`${P} comments`);
  65. // ---- md-editor ----
  66. await open('/components/md-editor');
  67. const info = await ev(`(() => { const ed = [...document.querySelectorAll('md-editor')].find(e => e.querySelector('input[name=line]')); const nav = ed.querySelector('nav'); const r = ed.querySelector('article').getBoundingClientRect(); const kids = [...nav.children].filter(c => getComputedStyle(c).display !== 'none').map(c => Math.round(c.getBoundingClientRect().top)); return { h: r.height, file: getComputedStyle(ed.querySelector('button.file')).display, md: ed.classList.contains('md-empty'), rows: new Set(kids).size }; })()`);
  68. check(`${P} md-editor: one-row surface (h<48), File button hidden, class md-empty, toolbar ${w === 390 ? 'one row' : 'drawn'}`, info.h < 48 && info.file === 'none' && info.md && (w !== 390 || info.rows === 1), JSON.stringify(info));
  69. await click('main form:nth-of-type(2) md-editor article'); await typeText('one line **bold**');
  70. check(`${P} md-editor: typing in the one-row editor formats (bold) and it grows`, await ev(`/<strong>bold<\\/strong>/.test([...document.querySelectorAll('md-editor')].find(e => e.querySelector('input[name=line]')).innerHTML)`));
  71. await shot(`${P}-mdeditor-1-typed`);
  72. await noSide(`${P} md-editor`);
  73. }
  74. console.log(MODE, results.filter(Boolean).length, 'ok', results.filter(x => !x).length, 'FAIL');
  75. await send('Emulation.clearDeviceMetricsOverride');
  76. await send('Page.navigate', { url: 'about:blank' });
  77. ws.close();

Branches

Latest commits

  • 4099e64aMerge branch 'font-segoe-ui' into mainAtlas
  • e14fb795|||PR Theme font: Segoe UI first (his choice 2026-11-19)Atlas
  • 44071d2cMerge branch 'hl-standard-5' into mainAtlas
  • 5ea64202|||PR Gate: count the new-tab check's console errors tooAtlas
  • 2752ceddMerge branch 'hl-standard-4' into mainAtlas
  • ac552b81|||PR Gate: keyboard (Tab/Enter/Space) and Back/Forward/reload/new-tab checks (HL-STANDARD F5, F21)Atlas
  • 8cddcaa9Merge branch 'hl-standard-2' into mainAtlas
  • 2b480a64|||PR Type the route parameter of main-menu build (HL-STANDARD L10)Atlas
  • ab54a39dMerge branch 'hl-standard' into mainAtlas
  • 04d36fcf|||PR Type function parameters and drop unneeded let (HL-STANDARD L2, L10)Atlas
  • 220c8fa4Merge branch 'readme-audit' into mainAtlas
  • b78fb85a|||PR README matches the codemre
  • 9f351699Preserve comments and nest supported selectors without changing rendered outputmre
  • 97110ad9WIP: nest accepted layout selectors; stopped at startup parse failuremre
  • ce4a0baeKeep caller slot styles whole so minimal shell apps startmre
  • 12cd3992Re-vendor complete Hybriel plugins and runtime to day44mre
  • b05c20feBackup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 8d9ed0b8Re-vendor complete Hybriel plugins and runtime to day39mre
  • ebd00b6cNest caller slot styles in three-panemre
  • 009991efNest caller slot styles in list-firstmre