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
- 0bbfc553main-menu: format Style with nested rules and bare mediamre
- 7755199dlist-first: format Style with nested rules and bare mediamre
- 35199303content-first: format Style with nested rules and bare mediamre
- 00f6e698app-sidebar: format Style with nested rules and bare mediamre
- bb2f29c9app-header: format Style with nested rules and bare mediamre
- 3aca2d7fSync components from 8176eb1 with reviewed nested stylesmre
- 87e4003dRe-vendor layouts to Hybriel set day35mre
- d8628cfflayouts: a startup error prints its message before exit 1 (hybriel#247)mre
- 180fd76elayouts: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows; empty Table-button table; tickets#49, notes#5)mre
- a3eda8afRe-vendor Hybriel master 7a684920 (binary 74ab3715): plugins whole, startup fault exits 1; files-upload gate 340/0mre
- 025d5880WIP re-vendor Hybriel set-day27b (a9712e61, master f5ff97bf): plugins whole, startup fault exits 1; NOT deployable: files-upload emit refused (see .scratch/rv27-upload)mre
- 42183a71Merge sb3-standby: layouts deploys through its standbymre
- 408de1f2layouts: no jobs switch needed in the standbymre
- 0b85f57elayouts: a standby container (port 45019, profile standby); deploy hands over through standby-swap.sh without a gapmre
- 31e40b8bMerge dm3-media: range handling in the layouts media routemre
- 856dcacbLayouts media route: read suffix ranges and ignore range lists and garbage, like the components route (the layouts copy still answered 416 for the last bytes)mre
- ad5056eaMerge dm3-sync: components re-sync to c2834ddmre
- 740e2abeRe-sync the components copy to c2834dd: media player fixes (state after a queue pick, cover-less audio, accessibility labels)mre
- 7fe103bbMerge mp-player: the media player showcase pagemre
- 7db43c4eMedia route: serve the showcase's media from committed files (storage/ is not in git)mre