tickets
All repositories: gitoria
15.1 KB
// tests/e2e-ux-tickets.mjs — LISBETH E2E of the UX mission (creator 2026-10-24): the ticket page's ONE composer ("Respond": editor, files,// `State [select]` + main button) and the ticket list's "New ticket" / "New project" windows, in the creator's real Chrome.// node tests/e2e-ux-tickets.mjs <base url> <sid> <shot dir> <ticket path e.g. /tickets.worldapi.org/1> [list path, default /]// BROWSER RULE (caramboleyo 2026-10-23): ONE own tab (Target.createTarget) in the Chrome on lisbeth :9223, closed in finally, then the// connection is dropped — never Browser.close, no other tab touched, nothing cleared (only my own cookie is set). Run under// `timeout 600 flock /media/STORAGE/claude-scratch/atlas/lisbeth.lock …`. The app runs on loreana (a COPY of the data) and is reached from// lisbeth through `ssh -R <port>:127.0.0.1:<port> lisbeth`. Test files on lisbeth: /tmp/atlas-UX-files/{sunset.png,forest.png,notes.txt}.// Real mouse clicks and keys everywhere (typing, the State select with ArrowDown, Ctrl+A / Backspace, Escape); the chooser's file input is// filled with DOM.setFileInputFiles (the only way to pick a file without the system dialog).import { writeFileSync } from 'node:fs';const [BASE, SID, SHOTS, TICKET, LIST = '/'] = process.argv.slice(2);const F = '/tmp/atlas-UX-files/';const sleep = (ms) => new Promise(r => setTimeout(r, ms));const J = JSON.stringify;let pass = 0, fail = 0;const check = (label, ok, detail = '') => { console.log((ok ? 'ok ' : 'FAIL ') + label + (ok ? '' : ' — ' + String(detail).slice(0, 400))); if (ok) pass++; else fail++; };const ver = await (await fetch('http://127.0.0.1:9223/json/version')).json();const bws = new WebSocket(ver.webSocketDebuggerUrl.replace(/ws:\/\/[^/]+/, 'ws://127.0.0.1:9223'));await new Promise(r => bws.onopen = r);let bid = 0; const bpend = new Map();bws.onmessage = m => { const d = JSON.parse(m.data); if (d.id && bpend.has(d.id)) { bpend.get(d.id)(d); bpend.delete(d.id); } };const bsend = (method, params = {}) => new Promise((res, rej) => { const i = ++bid; bpend.set(i, d => d.error ? rej(new Error(J(d.error))) : res(d.result)); bws.send(J({ id: i, method, params })); });const { targetId } = await bsend('Target.createTarget', { url: 'about:blank' });let ws;try {ws = new WebSocket(`ws://127.0.0.1:9223/devtools/page/${targetId}`);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 + ': ' + J(d.error))) : res(d.result)); ws.send(J({ id: i, method, params })); });const ev = async (e) => { const r = await send('Runtime.evaluate', { expression: e, returnByValue: true, awaitPromise: true }); if (r.exceptionDetails) throw new Error(J(r.exceptionDetails).slice(0, 400)); return r.result.value; };const waitFor = async (e, label, ms = 25000) => { const t = Date.now(); while (Date.now() - t < ms) { try { if (await ev(e)) return true; } catch {} await sleep(150); } console.log(' timeout: ' + label); return false; };const rect = (sel) => ev(`(() => { const e = document.querySelector(${J(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, w: r.width, h: r.height }; })()`);const click = async (sel) => { const r = await rect(sel); if (!r) throw new Error('no ' + sel); await sleep(150); const r2 = await rect(sel); for (const [type, extra] of [['mouseMoved', {}], ['mousePressed', { button: 'left', clickCount: 1 }], ['mouseReleased', { button: 'left', clickCount: 1 }]]) await send('Input.dispatchMouseEvent', { type, x: r2.x, y: r2.y, ...extra }); await sleep(200); };const key = async (k, code, vk, mod = 0, text) => { await send('Input.dispatchKeyEvent', { type: text ? 'keyDown' : 'rawKeyDown', modifiers: mod, key: k, code, windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk, text }); await send('Input.dispatchKeyEvent', { type: 'keyUp', modifiers: mod, key: k, code, windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk }); };const typeText = async (t) => { for (const ch of t) await send('Input.dispatchKeyEvent', { type: 'keyDown', text: ch, unmodifiedText: ch, key: ch }).then(() => send('Input.dispatchKeyEvent', { type: 'keyUp', key: ch })); };const chooseFiles = async (names) => { const { root } = await send('DOM.getDocument'); const { nodeId } = await send('DOM.querySelector', { nodeId: root.nodeId, selector: '#commentform pick-area label.choose input[type=file]' }); await send('DOM.setFileInputFiles', { files: names.map(n => F + n), nodeId }); };const size = (w) => send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });const shot = async (name) => { const r = await send('Page.captureScreenshot', { format: 'png' }); writeFileSync(`${SHOTS}/${name}.png`, Buffer.from(r.data, 'base64')); console.log(' shot ' + name); };const open = async (path) => { await send('Page.navigate', { url: BASE + path }); await sleep(700); await waitFor('document.readyState === "complete" && !!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', 'page live', 40000); await sleep(700); };await send('Page.enable'); await send('Runtime.enable'); await send('DOM.enable'); await send('Network.enable');await send('Network.setCookie', { name: 'hlsid', value: SID, url: BASE, httpOnly: true });await send('Page.bringToFront');const SELS = '#commentform select[name=state]';const label = () => ev(`document.querySelector('#commentform button.comment-post').textContent.trim()`);const stateNow = () => ev(`document.querySelector('#state').textContent`);const chosenText = () => ev(`(() => { const s = document.querySelector(${J(SELS)}); return s.options[s.selectedIndex].textContent.trim(); })()`);const pickState = async (name) => { await ev(`document.querySelector(${J(SELS)}).focus()`); for (let i = 0; i < 14; i++) { if ((await chosenText()) === name) return true; await key('ArrowDown', 'ArrowDown', 40); await sleep(150); } return false; };const comments = () => ev(`document.querySelectorAll('#events li.comment').length`);for (const W of [390, 1280]) {await size(W);console.log(`--- ${W} px: ticket ${TICKET}`);await open(TICKET);await waitFor(`!!document.querySelector('#commentform form.comment-form md-editor article')`, 'composer');await sleep(800);const opts = (await ev(`[...document.querySelectorAll(${J(SELS)} + ' option')].map(o => o.textContent.trim())`));const start = await stateNow();check(`${W} the composer has the State select (first "no change", the current state ${start} left out) and the button "Comment"`, opts[0] === 'no change' && !opts.includes(start) && (await label()) === 'Comment', J([opts, start, await label()]));check(`${W} no separate state form and no second editor on the page`, await ev(`!document.querySelector('#stateform') && document.querySelectorAll('#commentform md-editor').length === 1`));// 1. the box with two files chosen through its buttonawait chooseFiles(['sunset.png', 'forest.png']);await waitFor(`document.querySelectorAll('#commentform li.picked').length === 2 && [...document.querySelectorAll('#commentform img.thumb')].every(i => i.complete && i.naturalWidth > 0)`, 'two thumbs');await click('#commentform md-editor article');await typeText('Lisbeth ' + W + ': both, with two files');const target = ['progress', 'open', 'reopened'].find(x => opts.includes(x));check(`${W} a real ArrowDown on the State select picks "${target}"`, await pickState(target));check(`${W} text + state → the button says "Comment and set to ${target}"`, (await label()) === 'Comment and set to ' + target, await label());const geo = await ev(`(() => { const R = (s) => { const e = document.querySelector(s); if (!e) return null; const b = e.getBoundingClientRect(); return { l: b.left, r: b.right, t: b.top, b: b.bottom }; }; return { box: R('#commentform pick-area'), editor: R('#commentform md-editor'), list: R('#commentform ul.files.picked'), choose: R('#commentform label.choose'), select: R(${J(SELS)}), post: R('#commentform button.comment-post'), side: document.documentElement.scrollWidth, w: innerWidth }; })()`);check(`${W} one box: the files sit under the editor inside it, the footer under the files, nothing wider than the screen`, geo.list.t >= geo.editor.b - 1 && geo.list.b <= geo.box.b && geo.choose.t >= geo.list.b - 1 && geo.post.t >= geo.list.b - 1 && geo.post.r <= geo.box.r + 1 && geo.post.b <= geo.box.b + 1 && geo.side <= geo.w, J(geo));if (W >= 1000) check(`${W} footer row: "Choose files" at the left, State + the button at the right end, one row`, geo.choose.l - geo.box.l <= 24 && geo.box.r - geo.post.r <= 24 && geo.select.r < geo.post.l && Math.abs((geo.choose.t + geo.choose.b) / 2 - (geo.post.t + geo.post.b) / 2) <= 8, J(geo));await shot(`lisbeth-${W}-ticket-composer-both`);const c0 = await comments();await click('#commentform button.comment-post');await waitFor(`document.querySelector('#state').textContent === ${J(target)} && document.querySelectorAll('#events li.comment').length === ${c0 + 1}`, 'both posted');check(`${W} both → the comment with two thumbnails appears and the state is now ${target}; the box is empty again`, (await stateNow()) === target && (await ev(`[...document.querySelectorAll('#events li.comment')].pop().querySelectorAll('ul.comment-files img').length`)) === 2 && (await ev(`document.querySelectorAll('#commentform li.picked').length === 0`)) && (await chosenText()) === 'no change' && (await label()) === 'Comment');await ev(`[...document.querySelectorAll('#events li.comment')].pop().scrollIntoView({ block: 'center' })`);await shot(`lisbeth-${W}-ticket-after-both`);// 2. comment onlyawait click('#commentform md-editor article');await typeText('Lisbeth ' + W + ': just a comment');check(`${W} text only → "Comment"`, (await label()) === 'Comment', await label());await click('#commentform button.comment-post');await waitFor(`document.querySelectorAll('#events li.comment').length === ${c0 + 2}`, 'comment only posted');check(`${W} comment only → one more comment, the state stays ${target}`, (await comments()) === c0 + 2 && (await stateNow()) === target);// 3. state only, and the words switch with the text (real Ctrl+A, Backspace)const opts2 = await ev(`[...document.querySelectorAll(${J(SELS)} + ' option')].map(o => o.textContent.trim())`);const t2 = opts2.includes('done') ? 'done' : opts2.find(x => x !== 'no change' && x !== 'review' && x !== 'pending');check(`${W} a real ArrowDown picks "${t2}"`, await pickState(t2));check(`${W} a state and nothing written → "Set to ${t2}"`, (await label()) === 'Set to ' + t2, await label());await click('#commentform md-editor article');await typeText('x');check(`${W} one letter typed → "Comment and set to ${t2}"`, (await label()) === 'Comment and set to ' + t2, await label());await key('a', 'KeyA', 65, 2); await key('Backspace', 'Backspace', 8); await sleep(400);check(`${W} text deleted → "Set to ${t2}" again`, (await label()) === 'Set to ' + t2, await label());await shot(`lisbeth-${W}-ticket-state-only`);await click('#commentform button.comment-post');await waitFor(`document.querySelector('#state').textContent === ${J(t2)}`, 'state only');check(`${W} state only → the state is ${t2}, no new comment`, (await stateNow()) === t2 && (await comments()) === c0 + 2);// 4. the list: New ticket / New project windowsconsole.log(`--- ${W} px: list ${LIST}`);await open(LIST);await waitFor(`!!document.querySelector('#newticketbutton')`, 'New ticket button');const lg = await ev(`(() => { const R = (s) => { const e = document.querySelector(s); if (!e) return null; const b = e.getBoundingClientRect(); const c = getComputedStyle(e); return { l: b.left, r: b.right, t: b.top, b: b.bottom, bg: c.backgroundColor }; }; return { row: R('heading-row'), h1: R('#heading'), nt: R('#newticketbutton'), np: R('#newprojectlink'), fold: !!document.querySelector('#newticket') }; })()`);check(`${W} list: "New ticket" (accent) and "New project" (quiet) sit in the heading row, at 1280 New ticket at the right end (at 390 they wrap under the heading); no fold-out bar`, !!lg.nt && !!lg.np && lg.nt.bg !== 'rgba(0, 0, 0, 0)' && lg.np.bg === 'rgba(0, 0, 0, 0)' && (W < 1000 || lg.nt.r >= lg.row.r - 2) && !lg.fold && (W < 1000 || (lg.nt.t >= lg.row.t - 1 && lg.nt.b <= lg.row.b + 1 && lg.h1.r <= lg.np.l)), J(lg));await shot(`lisbeth-${W}-list`);await click('#newticketbutton');await waitFor(`!!document.querySelector('dialog#newticketmodal[open]')`, 'new ticket window');await sleep(400);const dg = await ev(`(() => { const r = document.querySelector('dialog#newticketmodal').getBoundingClientRect(); return { w: r.width, h: r.height, vw: innerWidth, vh: innerHeight }; })()`);check(`${W} the New ticket window is ${W < 600 ? 'full screen' : 'a centred window'}`, W < 600 ? dg.w >= dg.vw - 1 && dg.h >= dg.vh - 1 : dg.w < 700 && dg.h < dg.vh, J(dg));await click('#newsubject');await typeText('Lisbeth ' + W + ' ticket from the window');await click('#newsummary md-editor article');await typeText('written in the window');await shot(`lisbeth-${W}-list-new-ticket-window`);await click('#newsubmit');await waitFor(`!document.querySelector('dialog[open]') && !!document.querySelector('#notice')`, 'window closed after submit');check(`${W} submit → the window closes, the notice says "Opened …", the new ticket is a row of the list`, /^Opened /.test(await ev(`document.querySelector('#notice').textContent`)) && (await ev(`[...document.querySelectorAll('#tickets li a.subject')].some(a => a.textContent.includes('ticket from the window'))`)), await ev(`document.querySelector('#notice').textContent`));await click('#newprojectlink');await waitFor(`!!document.querySelector('dialog#newprojectmodal[open]')`, 'new project window');await click('#projecttitle');const suffix = Date.now().toString(36);await typeText('Lisbeth ' + W + ' project ' + suffix);await waitFor(`document.querySelector('#projectslug').value === 'lisbeth-${W}-project-${suffix}'`, 'slug');await shot(`lisbeth-${W}-list-new-project-window`);await click('#projectcreate');await waitFor(`!document.querySelector('dialog[open]') && /Created /.test((document.querySelector('#notice') || {}).textContent || '')`, 'project window closed');check(`${W} New project → the window closes and the notice links its settings`, (await ev(`document.querySelector('#noticelink').getAttribute('href')`)) === `/projects/lisbeth-${W}-project-${suffix}/settings`);await click('#newticketbutton');await waitFor(`!!document.querySelector('dialog#newticketmodal[open]')`, 'reopen');await key('Escape', 'Escape', 27);await waitFor(`!document.querySelector('dialog[open]')`, 'Esc closes');check(`${W} Esc closes the window`, await ev(`!document.querySelector('dialog[open]')`));}} finally {try { if (ws) ws.close(); } catch {}try { await bsend('Target.closeTarget', { targetId }); } catch {}bws.close();}console.log(`lisbeth e2e: ${pass} passed, ${fail} failed`);process.exit(fail ? 1 : 0);
Branches
Latest commits
- 5d144817Merge branch 'records-t40' into mainTickets
- 44ee6f06|||PR records: #43 #45 livemre
- b8fdeee9Merge branch 'p39-routes' into mainTickets
- a0187a0a|||PR Remove redundant route-order loopmre
- 369e4b9cMerge branch 'k40-lists' into mainTickets
- 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
- 610d8e8aMerge branch 'records-t39' into mainTickets
- 32bcdf24|||PR records: GO P39 K40mre
- 4123c6d1Merge branch 'records-t38' into mainTickets
- cd3641a1|||PR records: day72 deploy live, tickets closedmre
- 7d44d852Merge branch 'records-t37' into mainTickets
- 926f7061|||PR records: merges, D36 deploymre
- bf58534eMerge branch 'l33-final' into mainTickets
- 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
- 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
- 5822cb3aMerge branch 'o34-clean' into mainTickets
- 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
- 14cf96b4Merge branch 'records-t36' into mainTickets
- 07749fa1|||PR records: day72 + #40 mergedmre
- ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre