tickets
All repositories: gitoria
6.2 KB
// tests/e2e-editor-look.mjs (mission 021): the Markdown editor's LOOK in a REAL browser (lisbeth's test Chrome over CDP, ONE existing tab reused).// node tests/e2e-editor-look.mjs <old|new> <port> <sid> <out.json> <shotdir> <targetId>// App on loreana (a COPY of the data), reached from lisbeth through a reverse ssh forward at 127.0.0.1:<port>. Real mouse click into// the editor, real Input.insertText, nothing is submitted. Measures the 5 fields at 390 and 1280 px, empty and after one typed letter.import { writeFileSync } from 'node:fs';const [mode, port, sid, outFile, shotDir, tid] = process.argv.slice(2);const BASE = `http://127.0.0.1:${port}`, sleep = ms => new Promise(r => setTimeout(r, ms));const list = await (await fetch('http://127.0.0.1:9223/json/list')).json();const tgt = list.find(t => t.id === tid);const ws = new WebSocket(tgt.webSocketDebuggerUrl); 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)) { const [ok, bad] = pend.get(d.id); pend.delete(d.id); d.error ? bad(new Error(JSON.stringify(d.error))) : ok(d.result); } };const send = (method, params = {}) => new Promise((ok, bad) => { const i = ++id; pend.set(i, [ok, bad]); ws.send(JSON.stringify({ id: i, method, params })); });const ev = async x => { const r = await send('Runtime.evaluate', { expression: x, awaitPromise: true, returnByValue: true }); if (r.exceptionDetails) throw new Error(JSON.stringify(r.exceptionDetails).slice(0, 300)); return r.result.value; };const waitFor = async (x, label, t = 20000) => { for (const end = Date.now() + t; Date.now() < end;) { if (await ev(x).catch(() => false)) return true; await sleep(150); } console.log(' TIMEOUT waiting for', label); return false; };const rect = sel => ev(`(() => { const e = document.querySelector(${JSON.stringify(sel)}); if (!e) return null; e.scrollIntoView({ block: 'center' }); const r = e.getBoundingClientRect(); return { x: r.x + r.width / 2, y: r.y + r.height / 2 }; })()`);const click = async sel => { await rect(sel); await sleep(150); const r = await rect(sel); if (!r) throw new Error('no ' + sel); for (const [type, extra] of [['mouseMoved', {}], ['mousePressed', { button: 'left', clickCount: 1 }], ['mouseReleased', { button: 'left', clickCount: 1 }]]) await send('Input.dispatchMouseEvent', { type, x: r.x, y: r.y, ...extra }); };const shot = async name => { const r = await send('Page.captureScreenshot', { format: 'png' }); writeFileSync(`${shotDir}/${name}.png`, Buffer.from(r.data, 'base64')); };const MEASURE = sel => `(() => { const m = document.querySelector(${JSON.stringify(sel)}); if (!m) return null; const c = getComputedStyle(m); const art = m.querySelector('article'); const ph = m.querySelector('.placeholder'); const bs = [...m.querySelectorAll('nav button')].filter(x => getComputedStyle(x).display !== 'none').map(x => x.getBoundingClientRect()); const nav = m.querySelector('nav').getBoundingClientRect(); const ar = art.getBoundingClientRect(); const lbl = m.closest('md-field,label'); return { cls: m.className, host_h: +m.getBoundingClientRect().height.toFixed(1), host_w: +m.getBoundingClientRect().width.toFixed(1), border: c.borderTopWidth + ' ' + c.borderTopStyle, pad: c.paddingTop, nav_h: +nav.height.toFixed(1), toolbar_rows: new Set(bs.map(r => Math.round(r.top))).size, buttons: bs.length, min_tap: Math.round(Math.min(...bs.map(r => Math.min(r.width, r.height)))), file_btn: [...m.querySelectorAll('nav button.file')].some(x => getComputedStyle(x).display !== 'none'), article_h: +ar.height.toFixed(1), ph_left: ph && getComputedStyle(ph).display !== 'none' ? +ph.getBoundingClientRect().left.toFixed(1) : null, text_left: +(ar.left + parseFloat(getComputedStyle(art).paddingLeft)).toFixed(1), font: getComputedStyle(art).fontSize, color: getComputedStyle(art).color, docW: document.documentElement.scrollWidth }; })()`;const FIELDS = [{ name: 'newticket', path: '/project/hycon', sel: '#newticket md-editor', pre: `(document.querySelector('#newticket').open = true)` },{ name: 'comment', path: '/hycon/40', sel: '#commentform md-editor' },{ name: 'statenote', path: '/hycon/40', sel: '#statenote md-editor' },{ name: 'editsummary', path: '/hycon/40', sel: '#editform md-editor', pre: `document.querySelector('#editbutton').click()` },{ name: 'settings', path: '/projects/hycon/settings', sel: '#setdescription md-editor' },];await send('Page.enable'); await send('Runtime.enable'); await send('Network.enable');await send('Page.bringToFront'); await send('Emulation.setFocusEmulationEnabled', { enabled: true });await send('Network.setCookie', { name: 'hlsid', value: sid, url: BASE, httpOnly: true });const out = {};for (const W of [390, 1280]) {await send('Emulation.setDeviceMetricsOverride', { width: W, height: W < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: W < 600 });for (const f of FIELDS) {const key = `${mode}|${W}|${f.name}`;await send('Page.navigate', { url: BASE + f.path });await waitFor(`!!document.querySelector('main') && !!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1`, 'page ' + f.path);await sleep(1200);if (f.pre) { await ev(f.pre); await sleep(1200); }const ok = await waitFor(`!!document.querySelector(${JSON.stringify(f.sel + ' article')}) && document.querySelector(${JSON.stringify(f.sel)}).getBoundingClientRect().width > 0`, f.name);if (!ok) { out[key] = { error: 'editor not found' }; continue; }if (f.name !== 'editsummary') await waitFor(`(() => { const m = document.querySelector(${JSON.stringify(f.sel)}); return m.classList.contains('empty') || m.classList.contains('md-empty'); })()`, 'mounted ' + f.name, 8000);await rect(f.sel); await sleep(300);const before = await ev(MEASURE(f.sel));await shot(`${mode}-${W}-${f.name}-empty`);let after = null;if (f.name !== 'editsummary') {await click(f.sel + ' article'); await sleep(300);await send('Input.insertText', { text: 'x' }); await sleep(400);after = await ev(MEASURE(f.sel));await shot(`${mode}-${W}-${f.name}-typed`);}out[key] = { before, after, jump: after ? +(after.host_h - before.host_h).toFixed(1) : null };console.log(key, JSON.stringify(out[key]));}}writeFileSync(outFile, JSON.stringify(out, null, 1));ws.close();
Branches
Latest commits
- 0814ce6bTickets conductor: brief 025 tickets#36 style formmre
- 1b6916c4Tickets conductor: Atlas handover tickets#36mre
- aab95226Tickets conductor: worldapi-conductor paths, deploy blocker = read-only diskmre
- 6372b06dTickets conductor: worker port slotmre
- 836af31cTickets conductor: token pathsmre
- b03f11b6Tickets conductor: CONDUCTOR.md (project part), short STATUS.md, old STATUS to archive/2026-10-31mre
- a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
- cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
- 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
- b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
- f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
- 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
- 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
- d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
- afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
- 48c1ba79tickets: md-paste-files gate with the file manager casesmre
- f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
- 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
- 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
- 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre