layouts
All repositories: gitoria
8.9 KB
// 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)// 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.import { writeFileSync } from 'node:fs';const [TAB, BASE, PREFIX, MODE] = process.argv.slice(2); // MODE: before | afterconst SH = '/media/STORAGE/claude-scratch/atlas/S2/shots/';const ws = new WebSocket(`ws://127.0.0.1:9223/devtools/page/${TAB}`);await new Promise(r => ws.onopen = r);let id = 0; const pend = new Map();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); } };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 })); });const sleep = (ms) => new Promise(r => setTimeout(r, ms));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; };const shot = async (n) => { const { data } = await send('Page.captureScreenshot', { format: 'png' }); writeFileSync(SH + `${PREFIX}-${n}.png`, Buffer.from(data, 'base64')); };const results = [];const check = (l, ok, d = '') => { results.push(ok); console.log((ok ? 'ok ' : 'FAIL ') + l + (ok ? '' : ' — ' + d)); };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; };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); };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); };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); };const typeText = async (t) => { for (const ch of t) await key(ch, '', undefined, ch); };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 }); };const PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';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; })()`);const F = '/tmp/atlas-S2-e2e/';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)); };await send('Page.bringToFront');console.log('UA/width tab', TAB, await ev('navigator.userAgent.slice(0,60)'));for (const w of [390, 1280]) {await send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });const P = `${w}`;if (MODE === 'before') {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`)); }continue;}// ---- pick ----await open('/components/files-upload-pick');const pk = () => ev(`[...document.querySelectorAll('files-upload li.picked, files-upload li.refused')].map(li => (li.className.includes('refused') ? '!' : '') + li.querySelector('.name').textContent).join(',')`);await shot(`${P}-pick-1-empty`);await fileInput('files-upload label.choose input[type=file]', [F + 'pic.png', F + 'doc.pdf']);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());await click('#chat-text');await pasteFile('#chat-text', 'pasted.png');check(`${P} pick: paste a file → third row`, await waitFor(`document.querySelectorAll('files-upload li.picked').length === 3`), await pk());await shot(`${P}-pick-2-three`);await click('files-upload li.picked[data-i="1"] button.remove');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());await click('#chat-text'); await typeText('Hello two');await shot(`${P}-pick-3-typed`);await click('#chat-send');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`));await shot(`${P}-pick-4-sent`);await noSide(`${P} pick`);// ---- comments ----await open('/components/comments');await fileInput('comments-block files-upload label.choose input[type=file]', [F + 'pic.png', F + 'doc.pdf']);check(`${P} comments: choose 2 files → 2 waiting`, await waitFor(`document.querySelectorAll('comments-block li.picked').length === 2`));await pasteFile('comments-block form.comment-form md-editor article', 'shot.png');check(`${P} comments: paste into the editor (files=off) → 3 waiting`, await waitFor(`document.querySelectorAll('comments-block li.picked').length === 3`));await click('comments-block form.comment-form md-editor article'); await typeText('with **files**');await shot(`${P}-comments-1-attached`);await click('comments-block .comment-post, comments-block form.comment-form button[type=submit]');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`));await shot(`${P}-comments-2-posted`);await noSide(`${P} comments`);// ---- md-editor ----await open('/components/md-editor');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 }; })()`);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));await click('main form:nth-of-type(2) md-editor article'); await typeText('one line **bold**');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)`));await shot(`${P}-mdeditor-1-typed`);await noSide(`${P} md-editor`);}console.log(MODE, results.filter(Boolean).length, 'ok', results.filter(x => !x).length, 'FAIL');await send('Emulation.clearDeviceMetricsOverride');await send('Page.navigate', { url: 'about:blank' });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