layouts
All repositories: gitoria
89.0 KB
// tests/browser.mjs — THE GATE of layouts.worldapi.org: its own server, real headless Chrome, real clicks.// node tests/browser.mjs (LAYOUTS_GATE_PORT server, default 8760; LAYOUTS_GATE_CHROME "8761-8764" = Chrome debug ports;// 8765/8766 are foreign on Loreana — never use them)// What it proves, at 390 and 1280 px: the three shells and their states (list-first item → detail → back; three-pane all three// on desktop, list → detail on the phone; the sidebar overlay and the search + user menu popovers open and close), the header// flush with the content column, no sideways scroll, the themed components without decorative frames, the accent switcher,// the theme gate helper, and no console errors. Screenshots land in .scratch/gate-*.png — LOOK at them.import { spawn, execFileSync } from 'node:child_process';import { writeFileSync, existsSync, mkdirSync, rmSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { launchBrowser } from './cdp.mjs';import { AUDIT } from './taps-audit.mjs';import { DISPLAY } from './display-audit.mjs';import { mdShowcase } from './md-showcase.mjs';import { slotStart } from './slot-start.mjs';if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';const APP = resolve(dirname(fileURLToPath(import.meta.url)), '..');const PORT = Number(process.env.LAYOUTS_GATE_PORT || 8760);const [CH_FROM, CH_TO] = (process.env.LAYOUTS_GATE_CHROME || '8761-8764').split('-').map(Number);const BASE = `http://127.0.0.1:${PORT}`;const SCRATCH = join(APP, '.scratch');mkdirSync(SCRATCH, { recursive: true });for (const f of ['gate-shots']) rmSync(join(SCRATCH, f), { recursive: true, force: true });const SHOTS = join(SCRATCH, 'gate-shots');mkdirSync(SHOTS, { recursive: true });let failures = 0, passes = 0;function check(label, ok, detail = '') {console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`);if (ok) passes++; else failures++;}const sleep = (ms) => new Promise(r => setTimeout(r, ms));let log = '', server = null, browser = null;async function startServer() {server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, env: { ...process.env, LAYOUTS_PORT: String(PORT), LAYOUTS_WATCH: '0' }, stdio: ['ignore', 'pipe', 'pipe'] });server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);for (let i = 0; ; i++) {try { if ((await fetch(BASE + '/')).ok) break; } catch {}if (i > 1600) throw new Error('server did not come up\n' + log);await sleep(250);}}async function stop() {if (browser) { try { await browser.close(); } catch {} browser = null; }if (server) {try { server.kill('SIGTERM'); } catch {}await new Promise(r => { if (server.exitCode !== null || server.signalCode !== null) return r(); server.once('exit', r); setTimeout(r, 3000); });server = null;}}async function main() {await slotStart();// ---- the theme gate helper (no server needed) -----------------------------------------------------------------const helper = (args) => { try { return { code: 0, out: execFileSync('node', [join(APP, 'theme/check-theme.mjs'), ...args], { encoding: 'utf8' }) }; } catch (e) { return { code: e.status, out: String(e.stdout) }; } };const own = helper([APP]);check('check-theme on this app: 0 problems (exit 0)', own.code === 0 && /0 problems/.test(own.out), own.out.slice(-600));const fx = join(SCRATCH, 'gate-check-fixture');rmSync(fx, { recursive: true, force: true });mkdirSync(fx, { recursive: true });writeFileSync(join(fx, 'styles.hl'), ["a { color = '#ff0000' }","'.card' { border = '1px solid ' + colorBorder }","'.box' { background = 'white' }","details { border = '1px solid ' + colorBorder }","'.zone' { border = '2px dashed ' + colorBorder } // functional: a drop zone","'.x' { color = 'var(--color-text, #c3c8cd)' border = '0' }","'.r1' { padding = '0' borderRadius = '.4rem' }","'.r2' { borderRadius = 'var(--layout-radius)' }","'.r3' { borderRadius = radiusSmall borderTopLeftRadius = 'var(--radius-large, 10px)' }","'.r4' { borderRadius = radiusLarge + ' ' + radiusLarge + ' 0 0' }","'.r5' { borderRadius = '50%' } // an avatar","'.r6' { borderRadius = radiusLarge + ' 3px' }",].join('\n'));writeFileSync(join(fx, 'extra.css'), '.a { border-radius: var(--radius-small); }\n.b { border-top-left-radius: 4px; border-radius: 0 }\n');const bad = helper([fx]);check('check-theme flags a hard-coded #hex, a decorative border and a named colour', bad.code === 1 && /styles.hl:1: hard-coded colour/.test(bad.out) && /styles.hl:2: decorative border/.test(bad.out) && /styles.hl:3: named colour/.test(bad.out), bad.out);const radiusLines = bad.out.split('\n').filter(l => /corner radius/.test(l)).map(l => l.split(':').slice(0, 2).join(':')).sort().join(' ');check('check-theme flags every corner radius but radiusSmall / radiusLarge / 50% (hl and css; 7 problems in all)', bad.code === 1 && /7 problems/.test(bad.out) && radiusLines === 'extra.css:2 styles.hl:12 styles.hl:7 styles.hl:8', radiusLines + '\n' + bad.out);// ---- the server ---------------------------------------------------------------------------------------------------await startServer();const routes = ['/', '/elements', '/components', '/shells', '/docs', '/components/month-view', '/components/date-picker', '/components/range-picker', '/components/pagination', '/components/md-editor', '/components/code-editor', '/components/file-upload', '/components/modal', '/components/comments', '/components/files-upload', '/components/files-upload-pick', '/components/media-player', '/shells/content-first', '/shells/content-first/movie', '/shells/list-first', '/shells/list-first/trip', '/shells/three-pane', '/shells/three-pane/m2', '/search/modal'];const codes = await Promise.all(routes.map(async r => [r, (await fetch(BASE + r)).status]));check(`all ${routes.length} pages answer 200`, codes.every(([, c]) => c === 200), JSON.stringify(codes.filter(([, c]) => c !== 200)));// mission 007: no link of the app may leave it or land on a raw file (the Settings link once opened a .md file)const crawl = [];for (const r of [...routes, '/settings', '/read/using-the-theme', '/read/readme-modal', '/read/layouts-app-header', '/search/zzzz']) {const html = await (await fetch(BASE + r)).text();for (const m of html.matchAll(/<a [^>]*href="([^"]*)"/g)) crawl.push([r, m[1]]);}const rawLinks = crawl.filter(([, h]) => /\.md(#|$)/.test(h)).map(([r, h]) => r + ' -> ' + h);check(`no link of any page opens a raw .md file (${crawl.length} links crawled; docs and READMEs open in the app: /read/…)`, rawLinks.length === 0, [...new Set(rawLinks)].slice(0, 8).join('\n'));const internal = [...new Set(crawl.map(([, h]) => h.split('#')[0]).filter(h => h.startsWith('/') && !h.startsWith('//')))];const badLinks = [];for (const h of internal) { const res = await fetch(BASE + h); if (res.status !== 200 || !/text\/html/.test(res.headers.get('content-type') || '')) badLinks.push(h + ' ' + res.status + ' ' + res.headers.get('content-type')); }check(`all ${internal.length} distinct internal links answer 200 as HTML pages (no 404, no raw file)`, badLinks.length === 0, badLinks.slice(0, 8).join('\n'));const external = [...new Set(crawl.map(([, h]) => h).filter(h => /^(https?:)?\/\//.test(h)))];check('the only link that leaves the app is the sibling components.hybriel.worldapi.org', external.every(h => h === 'https://components.hybriel.worldapi.org/'), external.join(' '));const settings = await fetch(BASE + '/settings');const sHtml = await settings.text();check('the user menu\'s Settings is /settings, a page of the app (not a file)', /<a [^>]*href="\/settings"[^>]*>Settings<\/a>/.test(await (await fetch(BASE + '/')).text()) && settings.ok && /text\/html/.test(settings.headers.get('content-type')) && /application-header|applicationHeader/i.test(sHtml));const readme = await fetch(BASE + '/components/modal/README.md');check('a component README is served as Markdown', readme.ok && /markdown/.test(readme.headers.get('content-type')));const doc = await fetch(BASE + '/docs/layouts/list-first.md');check('a layout doc is served as Markdown', doc.ok && /markdown/.test(doc.headers.get('content-type')) && (await doc.text()).includes('# ListFirst'));const sr = await fetch(BASE + '/search?q=Date+Pick', { redirect: 'manual' });check('the header search GET /search?q= redirects to /search/<words>', sr.status === 302 && sr.headers.get('location') === '/search/date-pick', sr.status + ' ' + sr.headers.get('location'));const css = await (await fetch(BASE + '/__hl/app.css')).text();check('the stylesheet carries the theme: tokens (incl. the two radii), type slots and the html-prefixed component rules', /--color-accent:/.test(css) && /--color-type1:/.test(css) && /--layout-column:/.test(css) && css.includes('html pagination button{border:0;border-radius:var(--radius-small);min-width:var(--layout-tap);}') && /--radius-small:5px;--radius-large:10px;/.test(css) && css.includes('html md-editor{border:0'), css.slice(0, 300));check('the theme comes BEFORE the components\' own Style (cascade: theme rules win by the html prefix)', css.indexOf('html pagination button') < css.indexOf('pagination button{'), 'order');check('no style rule dropped at boot', !/style DROPPED/.test(log), log.split('\n').filter(l => /DROPPED/.test(l)).join('\n'));browser = await launchBrowser({ debugPortRange: [CH_FROM, CH_TO] });const page = await browser.newPage();const ev = (e) => page.evaluate(e);const shot = async (name) => { const { data } = await page.send('Page.captureScreenshot', { format: 'png' }); writeFileSync(join(SHOTS, `gate-${name}.png`), Buffer.from(data, 'base64')); };const size = (w) => page.send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 600 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 600 });const open = async (path) => {await page.goto(BASE + path, { timeout: 45000 });await hydrated('hydrated ' + path);await sleep(300);};const shown = (sel) => ev(`(() => { const el = document.querySelector(${JSON.stringify(sel)}); if (!el) return false; const r = el.getBoundingClientRect(); return getComputedStyle(el).display !== 'none' && r.width > 0 && r.height > 0; })()`);const rect = (sel) => ev(`(() => { const el = document.querySelector(${JSON.stringify(sel)}); if (!el) return null; const r = el.getBoundingClientRect(); return { x: Math.round(r.left), r: Math.round(r.right), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) }; })()`);const noSideways = async (label) => { const o = await ev('({ sw: document.documentElement.scrollWidth, w: window.innerWidth })'); check(`${label}: no sideways scroll`, o.sw <= o.w, JSON.stringify(o)); };// a link click may be a full page load (server-rendered HTML first): the next click waits for the page to be live, or it is lostconst hydrated = (label = 'page hydrated') => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 30000, label });const waitPath = async (p) => { await page.waitFor(`location.pathname === ${JSON.stringify(p)}`, { timeout: 15000, label: 'path ' + p }); await hydrated('hydrated after ' + p); };const press = async (key) => {const vk = key === 'Escape' ? 27 : 13;await page.send('Input.dispatchKeyEvent', { type: 'keyDown', key, code: key, windowsVirtualKeyCode: vk });if (key === 'Enter') await page.send('Input.dispatchKeyEvent', { type: 'char', text: '\r' });await page.send('Input.dispatchKeyEvent', { type: 'keyUp', key, code: key, windowsVirtualKeyCode: vk });};const popOpen = (sel) => ev(`document.querySelector(${JSON.stringify(sel)}).matches(':popover-open')`);// ================================== PHONE (390) ==================================await size(390);// content-first (the showcase site itself): content shown, sidebar hidden until the toggleawait open('/elements');check('390 content-first: main shown, sidebar hidden, toggle shown', await shown('content-first > main') && !(await shown('#sidebar')) && await shown('application-header .menu-toggle'));check('390 header: main menu hidden, loupe + user icon shown', !(await shown('application-header main-menu')) && await shown('application-header .search-toggle') && await shown('user-menu .user-toggle'));await noSideways('390 /elements');await shot('390-content-first');await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'sidebar opens' });await sleep(250);const sb = await rect('#sidebar');check('390 toggle opens the sidebar overlay from the left, over the page', sb && sb.x === 0 && sb.w > 250 && sb.w < 390 && sb.h >= 800, JSON.stringify(sb));check('390 the sidebar holds the main menu (the header has no room for it)', await shown('#sidebar main-menu') && (await ev(`document.querySelector('#sidebar main-menu a.current').textContent`)) === 'Elements');await shot('390-sidebar-open');await press('Escape');await page.waitFor(`!document.querySelector('#sidebar').matches(':popover-open')`, { label: 'Esc closes the sidebar' });check('390 Esc closes the sidebar', !(await shown('#sidebar')));await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'sidebar opens again' });await page.click('#sidebar nav a[href="/components/pagination"]');await waitPath('/components/pagination');await page.waitFor(`!!document.querySelector('pagination')`, { label: 'pagination page' });await sleep(300);check('390 a link in the sidebar navigates and the overlay is closed after it', !(await popOpen('#sidebar')) && !(await shown('#sidebar')));// search: the loupe opens the field under the bar, focused; Enter searchesawait open('/');await page.click('application-header .search-toggle');await page.waitFor(`document.querySelector('#app-search').matches(':popover-open')`, { label: 'search opens' });await sleep(200);const sf = await rect('#app-search');check('390 loupe opens the search field full width under the header, focused', sf && sf.x === 0 && sf.w === 390 && sf.y >= 50 && (await ev(`document.activeElement === document.querySelector('#app-search input')`)), JSON.stringify(sf));await shot('390-search-open');await page.type('#app-search input', 'modal');await press('Enter');await waitPath('/search/modal');await page.waitForSelector('ul.pages a[href="/components/modal"]', { timeout: 15000 });check('390 the search lands on /search/modal and finds the Modal page', true);// user menu: the icon opens the dropdown; Esc closes itawait open('/');await page.click('user-menu .user-toggle');await page.waitFor(`document.querySelector('#user-menu').matches(':popover-open')`, { label: 'user menu opens' });await sleep(200);const um = await rect('#user-menu');const items = await ev(`[...document.querySelectorAll('#user-menu a')].map(a => a.textContent)`);check('390 user icon opens the dropdown at the right edge, Settings then Logout last', um && um.r <= 390 && um.r >= 370 && items.join('|') === 'Settings|Logout', JSON.stringify({ um, items }));await shot('390-user-menu');await press('Escape');await page.waitFor(`!document.querySelector('#user-menu').matches(':popover-open')`, { label: 'Esc closes the user menu' });check('390 Esc closes the user menu', true);// list-first: the list first; an item replaces it; back returnsawait open('/shells/list-first');check('390 list-first /: the list shown, the welcome text never', await shown('list-first > aside') && !(await shown('list-first > main')));check('390 list-first: no sidebar toggle (no overlay in this shell)', !(await shown('application-header .menu-toggle')));await noSideways('390 list-first');await shot('390-list-first-list');await page.click('list-first > aside a[href="/shells/list-first/trip"]');await waitPath('/shells/list-first/trip');await page.waitFor(`document.querySelector('list-first').classList.contains('detail')`, { label: 'detail state' });await sleep(300);check('390 list-first item → only the note shows (list gone), with its long title', !(await shown('list-first > aside')) && await shown('list-first > main') && /Helsinki trip/.test(await ev(`document.querySelector('list-first > main h1').textContent`)));check('390 list-first detail: a back link to the list', await shown('list-first a.back'));await noSideways('390 list-first detail (long title)');await shot('390-list-first-detail');await page.click('list-first a.back');await waitPath('/shells/list-first');await page.waitFor(`document.querySelector('list-first').classList.contains('list')`, { label: 'back to the list' });check('390 back → the list again', await shown('list-first > aside'));// three-pane: list first; folders are the overlay; an item shows with its actionsawait open('/shells/three-pane');check('390 three-pane: the message list first, no message, folders hidden', await shown('three-pane > aside') && !(await shown('three-pane > main')) && !(await shown('#sidebar')));await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'folders open' });await sleep(250);check('390 three-pane: the toggle slides the folders in', /Inbox/.test(await ev(`document.querySelector('#sidebar').textContent`)) && await shown('#sidebar'));await shot('390-three-pane-folders');await page.click('#sidebar .sidebar-close');await page.waitFor(`!document.querySelector('#sidebar').matches(':popover-open')`, { label: '× closes the folders' });check('390 three-pane: the × closes the folders', true);await page.click('three-pane > aside a[href="/shells/three-pane/m3"]');await waitPath('/shells/three-pane/m3');await page.waitFor(`document.querySelector('three-pane').classList.contains('detail')`, { label: 'mail detail' });await sleep(300);check('390 three-pane item → the message with its actions, the list gone', !(await shown('three-pane > aside')) && await shown('three-pane > main > menu') && /tracker#32/.test(await ev(`document.querySelector('three-pane > main h1').textContent`)));await noSideways('390 three-pane detail');await page.click('three-pane > main > menu button[value="Archived"]');await page.waitFor(`/Archived/.test(document.querySelector('three-pane > main output').textContent)`, { label: 'action answered' });check('390 three-pane: an action button answers (mock)', true);await shot('390-three-pane-detail');// content-first demo (signed out): the phone-only sidebar holds the main menuawait open('/shells/content-first');check('390 tracker demo: signed out, a login where the user menu would be', await shown('application-header a.button.primary') && !(await ev(`!!document.querySelector('user-menu')`)));await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'tracker sidebar' });await page.click('#sidebar main-menu a[href="/shells/content-first/movie"]');await waitPath('/shells/content-first/movie');await page.waitFor(`document.querySelector('main h1').textContent === 'Movie'`, { label: 'movies' });check('390 tracker demo: Movies from the sidebar menu → only movies, overlay closed', (await ev(`[...document.querySelectorAll('ul.titles .pill')].every(p => p.textContent === 'Movie')`)) && !(await popOpen('#sidebar')));await noSideways('390 tracker demo');await shot('390-tracker-demo');// every other page at 390: no sideways scrollfor (const r of ['/components/month-view', '/components/date-picker', '/components/range-picker', '/components/md-editor', '/components/code-editor', '/components/file-upload', '/components/modal', '/components/comments', '/components/files-upload', '/components/files-upload-pick', '/components/pagination', '/docs']) {await open(r);await noSideways('390 ' + r);if (/comments|files-upload|pagination/.test(r)) await shot('390' + r.replace(/\//g, '-'));}// ================================== DESKTOP (1280) ==================================await size(1280);await open('/elements');check('1280 content-first: sidebar and main side by side, no toggle, no loupe', await shown('#sidebar') && await shown('content-first > main') && !(await shown('application-header .menu-toggle')) && !(await shown('application-header .search-toggle')));const [brand, um2, sideR, mainR, colR] = [await rect('application-header > a.brand'), await rect('user-menu .user-toggle svg'), await rect('#sidebar > nav a'), await rect('content-first > main'), await rect('content-first')];check('1280 header contents flush with the content column (brand text = sidebar text left, user icon right = column right)', Math.abs(brand.x - (sideR.x + 12)) <= 1 && Math.abs(um2.r - mainR.r) <= 1, JSON.stringify({ brand, um2, sideR, mainR, colR }));check('1280 the header shows the main menu with the page marked, and the search field', await shown('application-header main-menu') && (await ev(`document.querySelector('application-header main-menu a.current').textContent`)) === 'Elements' && await shown('#app-search input'));check('1280 the sidebar does not repeat the main menu', !(await shown('#sidebar main-menu')));await shot('1280-content-first');// themed plain elements: borderless except the foldable and the drop zoneconst b = await ev(`(() => { const s = (q, p) => getComputedStyle(document.querySelector(q))[p]; return {button: s('elements-page button.primary', 'borderTopStyle'), input: s('#el-title', 'borderTopStyle'),details: s('elements-page details', 'borderTopStyle'), drop: s('drop-zone', 'borderTopStyle'),td: s('elements-page td', 'borderTopStyle'), h1: s('elements-page h1', 'color'), strong: s('elements-page strong', 'color') }; })()`);check('1280 elements: buttons, fields, table cells have no border; the foldable solid, the drop zone dashed', b.button === 'none' && b.input === 'none' && b.td === 'none' && b.details === 'solid' && b.drop === 'dashed', JSON.stringify(b));check('1280 elements: titles white (text-strong)', b.h1 === 'rgb(245, 250, 255)' && b.strong === 'rgb(245, 250, 255)', JSON.stringify(b));await page.click('elements-page details:nth-of-type(2) summary');check('1280 elements: a foldable opens on its summary', await ev(`document.querySelectorAll('elements-page details')[1].open`));// the accent switcher: a palette colour becomes --color-accent, survives a reload, Reset returns the defaultconst accentOf = () => ev(`getComputedStyle(document.querySelector('application-header main-menu a.current')).color`);const before = await accentOf();await page.click('accent-switcher button[value="purple"]');await sleep(200);check('1280 accent switcher: purple → the marked menu link is purple', (await accentOf()) === 'rgb(197, 134, 192)', await accentOf());await open('/shells');check('1280 accent switcher: the accent stays on the next page (localStorage)', (await accentOf()) === 'rgb(197, 134, 192)', await accentOf());await shot('1280-accent-purple');await page.click('accent-switcher button.reset');await sleep(200);check('1280 accent switcher: Reset → the theme default again', (await accentOf()) === before, `${await accentOf()} vs ${before}`);// themed components: no decorative frames left, functional ones keptawait open('/components/pagination');check('1280 pagination: no frames, the current page is the accent', (await ev(`getComputedStyle(document.querySelector('pagination li.current button')).borderTopStyle`)) === 'none' && (await ev(`getComputedStyle(document.querySelector('pagination li:not(.current) button')).borderTopStyle`)) === 'none');await page.click('pagination li:nth-child(3) button');await page.waitFor(`document.querySelector('pagination li.current button').textContent === '3'`, { label: 'page 3' });check('1280 pagination still works themed (page 3)', true);await open('/components/md-editor');check('1280 md-editor: no outer frame, no line under the toolbar', (await ev(`getComputedStyle(document.querySelector('md-editor')).borderTopStyle`)) === 'none' && (await ev(`getComputedStyle(document.querySelector('md-editor nav')).borderBottomStyle`)) === 'none');await shot('1280-md-editor');await open('/components/code-editor');check('1280 code-editor: no frame, no gutter line', (await ev(`getComputedStyle(document.querySelector('code-editor')).borderTopStyle`)) === 'none' && (await ev(`getComputedStyle(document.querySelector('code-editor code-gutter')).borderRightStyle`)) === 'none');await open('/components/month-view');check('1280 month-view: day cells without grid lines, today still marked', (await ev(`getComputedStyle(document.querySelector('#month-days li')).borderTopStyle`)) === 'none' && (await ev(`document.querySelectorAll('#month-days li.today').length`)) === 1);await shot('1280-month-view');await open('/components/date-picker');await page.click('date-picker input');await page.waitFor(`getComputedStyle(document.querySelector('date-picker picker-popup')).display !== 'none'`, { label: 'date popup' });await sleep(300);check('1280 date-picker: borderless field, the popup a raised surface without frame', (await ev(`getComputedStyle(document.querySelector('date-picker input')).borderTopStyle`)) === 'none' && (await ev(`getComputedStyle(document.querySelector('date-picker month-view')).borderTopStyle`)) === 'none');await shot('1280-date-picker-open');await open('/components/file-upload');check('1280 file-upload: the drop zone keeps its dashed border, the choose button has none', (await ev(`getComputedStyle(document.querySelector('file-upload drop-zone')).borderTopStyle`)) === 'dashed' && (await ev(`getComputedStyle(document.querySelector('file-upload label.choose')).borderTopStyle`)) === 'none');await open('/components/modal');await page.click('#open-confirm');await page.waitFor(`document.querySelector('#confirm').open`, { label: 'modal open' });await sleep(300);check('1280 modal: the window has no frame, no line under the title', (await ev(`getComputedStyle(document.querySelector('#confirm')).borderTopStyle`)) === 'none' && (await ev(`getComputedStyle(document.querySelector('#confirm header')).borderBottomStyle`)) === 'none');await shot('1280-modal-open');await page.click('#confirm footer button[value="delete"]');await page.waitFor(`document.querySelector('#modal-last').textContent === 'confirm: delete'`, { label: 'modal closed' });check('1280 modal still reports how it closed (confirm: delete)', true);// ---- mission 005: pagination tells the page (onPage), md-editor readonly, the two new components: comments, files-upload ----------const key = async (k, code, vk, text, modifiers = 0) => { await page.send('Input.dispatchKeyEvent', { type: 'keyDown', key: k, code, windowsVirtualKeyCode: vk, text, modifiers }); await page.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); };await open('/components/pagination');check('1280 pagination: before any click the page says "none yet"', (await ev(`document.querySelector('#pagination-heard').textContent`)) === 'none yet');await page.click('pagination li:nth-child(4) button');check('1280 pagination: a click on 4 tells the page "page 4" (onPage)', (await ev(`document.querySelector('#pagination-heard').textContent`)) === 'page 4', await ev(`document.querySelector('#pagination-heard').textContent`));await page.click('pagination li:last-child button');await sleep(400);check('1280 pagination: Next tells the page the page after it', /^page [0-9]+$/.test(await ev(`document.querySelector('#pagination-heard').textContent`)) && (await ev(`document.querySelector('#pagination-heard').textContent`)) !== 'page 4', await ev(`document.querySelector('#pagination-heard').textContent`));await shot('1280-pagination');await open('/components/md-editor');const ro = await ev(`(() => { const ed = [...document.querySelectorAll('md-editor')].find(m => m.querySelector('input[name=shown]')); if (!ed) return null; const a = ed.querySelector('article'); return { toolbar: getComputedStyle(ed.querySelector('nav')).display !== 'none', editable: a.isContentEditable, strong: !!a.querySelector('strong'), li: a.querySelectorAll('li').length, h1: !!a.querySelector('h1') }; })()`);check('1280 md-editor readonly: the Markdown shown formatted (h1, bold, list), not editable, no toolbar', ro && ro.h1 && ro.strong && ro.li === 2 && !ro.editable && !ro.toolbar, JSON.stringify(ro));await ev(`[...document.querySelectorAll('md-editor')].find(m => m.querySelector('input[name=shown]')).scrollIntoView()`);await shot('1280-md-editor-readonly');// ---- mission 010: real keys on the showcase md-editor page (a table typed after a list is a table), 390 and 1280 ----for (const w of [390, 1280]) {await size(w); await open('/components/md-editor');await mdShowcase(page, { check, sleep, label: String(w), shot: (n) => shot(`${w}-${n}`) });}await size(1280);// ---- comments ----await open('/components/comments');const R = (id) => `document.querySelector('comments-block li.comment[data-id="${id}"]')`;const art = (id) => ev(`(${R(id)}.querySelector('md-editor article') || {}).innerHTML`);const ids = () => ev(`[...document.querySelectorAll('comments-block li.comment')].map(li => li.dataset.id).join(',')`);const count = () => ev(`document.querySelector('comments-block .comments-count').textContent`);const told = () => ev(`document.querySelector('#comments-told').textContent`);const btns = (id) => ev(`[...${R(id)}.querySelectorAll('comment-actions button')].map(b => b.textContent).join('|')`);await page.waitFor(`!!${R('c1')}.querySelector('md-editor article ul')`, { label: 'comment Markdown drawn' }).catch(() => {});check('1280 comments: "3 comments", the three comments, the texts drawn as formatted Markdown (bold, code, link, list)', (await count()) === '3 comments' && (await ids()) === 'c1,c2,c3' && /<strong>Markdown<\/strong>/.test(await art('c1')) && /<code>code<\/code>/.test(await art('c1')) && /<ul><li>one<\/li><li>two<\/li><\/ul>/.test(await art('c1')), (await count()) + ' ' + (await art('c1')));check('1280 comments: a shown text is not editable and has no toolbar', await ev(`!${R('c1')}.querySelector('md-editor article').isContentEditable && getComputedStyle(${R('c1')}.querySelector('md-editor nav')).display === 'none'`));check('1280 comments: as alice, Edit / Delete only on alice\'s comments (c1, c3), the like on every one', (await btns('c1')) === '♡ 2|Edit|Delete' && (await btns('c2')) === '♥ 1' && (await btns('c3')) === '♡ 0|Edit|Delete', [await btns('c1'), await btns('c2'), await btns('c3')].join(' / '));check('1280 comments: avatar initial, name, time, "edited" only on the edited one', await ev(`(() => { const li = ${R('c2')}; return li.querySelector('comment-avatar').textContent === 'B' && li.querySelector('.comment-author').textContent === 'bob' && li.querySelector('time').textContent === 'Oct 17, 10:40' && !!li.querySelector('details.comment-history') && !${R('c3')}.querySelector('details.comment-history'); })()`));await shot('1280-comments');await page.click('comments-block li.comment[data-id="c1"] .comment-like');await page.waitFor(`${R('c1')}.querySelector('.comment-like').textContent === '♥ 3' && document.querySelector('#comments-told').textContent === 'like c1'`, { label: 'liked' }).catch(() => {});check('1280 comments: a click on the like → ♥ 3, pressed, the page told "like c1"', (await ev(`${R('c1')}.querySelector('.comment-like').textContent`)) === '♥ 3' && (await ev(`${R('c1')}.querySelector('.comment-like').getAttribute('aria-pressed')`)) === 'true' && (await told()) === 'like c1', await told());await page.click('comments-block form.comment-form md-editor article');await typeText('Hello **world** by keys');await sleep(200);check('1280 comments: typing in the form formats (**world** → bold) as in the editor', /<strong>world<\/strong>/.test(await ev(`document.querySelector('comments-block form.comment-form article').innerHTML`)));await key('Enter', 'Enter', 13, '\r', 2);await page.waitFor(`document.querySelectorAll('comments-block li.comment').length === 4 && !!${R('n1')}.querySelector('md-editor article p')`, { label: 'posted by Ctrl+Enter' }).catch(() => {});check('1280 comments: Ctrl+Enter posts — "4 comments", the new one last by alice, formatted, the form empty again, page told "post"', (await ids()) === 'c1,c2,c3,n1' && (await count()) === '4 comments' && /Hello <strong>world<\/strong> by keys/.test(await art('n1')) && (await told()) === 'post' && (await ev(`document.querySelector('comments-block form.comment-form article').textContent`)) === '', (await ids()) + ' ' + (await count()) + ' ' + (await told()));await page.click('comments-block li.comment[data-id="n1"] .comment-edit-start');await page.waitFor(`!!${R('n1')}.querySelector('form.comment-edit article p')`, { label: 'edit form' }).catch(() => {});await page.click('comments-block li.comment[data-id="n1"] form.comment-edit article');await key('End', 'End', 35, undefined, 2);await typeText(' and more');await page.click('comments-block li.comment[data-id="n1"] .comment-save');await page.waitFor(`!!${R('n1')}.querySelector('details.comment-history') && /by keys and more/.test((${R('n1')}.querySelector('md-editor article') || {}).innerHTML || '')`, { label: 'edited' }).catch(() => {});check('1280 comments: Edit, type, Save → the text changed, "edited" appears, the page told "edit n1"', /by keys and more/.test(await art('n1') || '') && (await told()) === 'edit n1' && (await ev(`!!${R('n1')}.querySelector('details.comment-history')`)), (await art('n1')) + ' ' + (await told()));await page.click('comments-block li.comment[data-id="n1"] .comment-delete');await page.waitFor(`!!${R('n1')}.querySelector('.comment-delete-yes')`, { label: 'asks' }).catch(() => {});check('1280 comments: Delete asks first ("Delete this comment?") and nothing is gone yet', (await ids()) === 'c1,c2,c3,n1' && /Delete this comment\?/.test(await ev(`${R('n1')}.querySelector('comment-ask').textContent`)));await page.click('comments-block li.comment[data-id="n1"] .comment-delete-yes');await page.waitFor(`!${R('n1')}`, { label: 'deleted' }).catch(() => {});check('1280 comments: Delete again removes it — "3 comments", the page told "delete n1"', (await ids()) === 'c1,c2,c3' && (await count()) === '3 comments' && (await told()) === 'delete n1', (await ids()) + ' ' + (await told()));await page.click('#as-bob');await page.waitFor(`document.querySelector('#comments-me').textContent === 'bob' && ${R('c2')}.querySelector('.comment-edit-start')`, { label: 'bob' }).catch(() => {});check('1280 comments: as bob, Edit / Delete only on bob\'s c2 (alice\'s c1 liked by alice stays ♥ 3)', (await btns('c1')) === '♥ 3' && (await btns('c2')) === '♥ 1|Edit|Delete' && (await btns('c3')) === '♡ 0', [await btns('c1'), await btns('c2'), await btns('c3')].join(' / '));await page.click('#as-nobody');await page.waitFor(`document.querySelector('#comments-me').textContent === ''`, { label: 'nobody' }).catch(() => {});await sleep(300);check('1280 comments: as nobody, no form, no Edit / Delete, the sign-in text instead', !(await ev(`!!document.querySelector('comments-block form.comment-form')`)) && (await ev(`document.querySelectorAll('comments-block .comment-edit-start, comments-block .comment-delete').length`)) === 0 && /Choose a user above/.test(await ev(`document.querySelector('comments-block .comments-sign-in').textContent`)));await page.click('#as-alice');await page.waitFor(`!!document.querySelector('comments-block form.comment-form')`, { label: 'alice again' }).catch(() => {});await ev('scrollTo(0, 0)');// the look: the bubble is a surface without a frame, the avatar round, the post button not framedconst look = await ev(`(() => { const s = (q, p) => getComputedStyle(document.querySelector(q))[p]; return { bubble: s('comments-block comment-bubble', 'borderTopStyle'), avatar: s('comments-block comment-avatar', 'borderTopLeftRadius'), post: s('comments-block button.comment-post', 'borderTopStyle'), details: s('comments-block details.comment-history', 'borderTopStyle') }; })()`);check('1280 comments: the bubble and the Comment button have no frame, the avatar is round (50%)', look.bubble === 'none' && look.post === 'none' && look.avatar === '50%', JSON.stringify(look));// K1: the theme styles every details/summary as a framed foldable (border, grey header strip, margins); the comment's "edited" must stay a quiet label// beside the time, and every bubble hugs its content (no inline min-height of a 6-row editor on a readonly text)const k1 = await ev(`(() => { const d = ${R('c2')}.querySelector('details.comment-history'); const s = d.querySelector('summary'); const t = ${R('c2')}.querySelector('comment-meta time').getBoundingClientRect(); const sr = s.getBoundingClientRect(); const cs = getComputedStyle(d), ss = getComputedStyle(s); const hug = [...document.querySelectorAll('comments-block li.comment')].map(li => { const b = li.querySelector('comment-bubble'); const last = [...b.children].filter(c => c.getBoundingClientRect().height > 0).pop().getBoundingClientRect(); return Math.round(b.getBoundingClientRect().bottom - last.bottom - parseFloat(getComputedStyle(b).paddingBottom)); }); return { box: cs.borderTopStyle, bg: ss.backgroundColor, sb: ss.borderBottomStyle, pad: ss.paddingTop, sameLine: Math.abs(sr.top - t.top) < 14 && sr.left > t.right - 1, h: Math.round(sr.height), hug }; })()`);check('1280 comments: "edited" is a quiet label on the time\'s line (no frame, no header strip, its padding only the 44 px hit area, sync MC) and every bubble hugs its content', k1.box === 'none' && k1.bg === 'rgba(0, 0, 0, 0)' && k1.sb === 'none' && parseFloat(k1.pad) <= 14 && k1.sameLine && k1.h <= 48 && k1.hug.length >= 3 && k1.hug.every(x => x <= 3), JSON.stringify(k1));// ---- files-upload ----const UP = join(SCRATCH, 'up');mkdirSync(UP, { recursive: true });writeFileSync(join(UP, 'a.txt'), 'hello a');writeFileSync(join(UP, 'b.txt'), 'hello b, a bit longer');writeFileSync(join(UP, 'c.bin'), Buffer.alloc(1536 * 1024, 7));await open('/components/files-upload', '/components/files-upload-pick');const rows = () => ev(`[...document.querySelectorAll('files-upload ul.files li')].map(li => [li.querySelector('.name').textContent, li.querySelector('.state').textContent].join('|'))`);const summary = () => ev(`(document.querySelector('files-upload output.summary') || {}).textContent`);check('1280 files-upload: the drop zone keeps its dashed border, the choose button has none, the input takes several', (await ev(`getComputedStyle(document.querySelector('files-upload drop-zone')).borderTopStyle`)) === 'dashed' && (await ev(`getComputedStyle(document.querySelector('files-upload label.choose')).borderTopStyle`)) === 'none' && (await ev(`document.querySelector('files-upload input[type=file]').multiple`)));await shot('1280-files-upload');const zone = await page.box('files-upload drop-zone');const dropData = { items: [], files: [join(UP, 'a.txt'), join(UP, 'b.txt'), join(UP, 'c.bin')], dragOperationsMask: 1 };for (const type of ['dragEnter', 'dragOver', 'drop']) await page.send('Input.dispatchDragEvent', { type, x: Math.round(zone.x), y: Math.round(zone.y), data: dropData });await page.waitFor(`document.querySelectorAll('files-upload li.done').length === 3`, { timeout: 60000, label: 'three uploaded' }).catch(() => {});const r1 = await rows();check('1280 files-upload: a real drop of three files → three rows in drop order, all Uploaded, "3 of 3 uploaded"', r1.join(',') === 'a.txt|Uploaded,b.txt|Uploaded,c.bin|Uploaded' && /3 of 3/.test(await summary()), r1.join(',') + ' / ' + await summary());const { root } = await page.send('DOM.getDocument');const { nodeId } = await page.send('DOM.querySelector', { nodeId: root.nodeId, selector: 'files-upload input[type=file]' });await page.send('DOM.setFileInputFiles', { files: [join(UP, 'a.txt'), join(UP, 'b.txt')], nodeId });await page.waitFor(`document.querySelectorAll('files-upload li.done').length === 5`, { timeout: 30000, label: 'five uploaded' }).catch(() => {});check('1280 files-upload: choosing two more files adds two rows → "5 of 5 uploaded"', (await ev(`document.querySelectorAll('files-upload ul.files li').length`)) === 5 && /5 of 5/.test(await summary()), await summary());await ev('scrollTo(0, 0)');await shot('1280-files-upload-done');// ---- mission 008: components 1442e58 — pick mode, comments with attachments, md-editor rows / files="off" / md-empty ----------const PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';writeFileSync(join(UP, 'pic.png'), Buffer.from(PNG, 'base64'));writeFileSync(join(UP, 'doc.pdf'), '%PDF-1.4 test');writeFileSync(join(UP, 'big.bin'), Buffer.alloc(2200 * 1024, 1));const fileInput = async (sel, files) => {const { root: rt } = await page.send('DOM.getDocument');const { nodeId: nid } = await page.send('DOM.querySelector', { nodeId: rt.nodeId, selector: sel });await page.send('DOM.setFileInputFiles', { files, nodeId: nid });};// a real paste event carrying a file (never the system clipboard): the target is the focused text fieldconst pasteFile = (sel, name, type) => ev(`(() => { const dt = new DataTransfer(); const b = Uint8Array.from(atob(${JSON.stringify(PNG)}), c => c.charCodeAt(0)); dt.items.add(new File([b], ${JSON.stringify(name)}, { type: ${JSON.stringify(type)} })); const t = document.querySelector(${JSON.stringify(sel)}); t.focus(); t.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return true; })()`);for (const w of [1280, 390]) {await size(w);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(',')`);check(w + ' pick: the page has a pick area, the chat form inside it, no upload rows, no files yet', await ev(`!!document.querySelector('files-upload pick-area form#chat-form') && document.querySelectorAll('files-upload li').length === 0`));await shot('pick-' + w + '-before');await fileInput('files-upload input[type=file]', [join(UP, 'pic.png'), join(UP, 'doc.pdf')]);await page.waitFor(`document.querySelectorAll('files-upload li.picked').length === 2`, { label: 'picked 2' }).catch(() => {});check(w + ' pick: choosing a picture and a pdf → two rows in order, the picture as a thumbnail (img.thumb), the pdf with its kind', (await pk()) === 'pic.png,doc.pdf' && await ev(`!!document.querySelector('files-upload li.picked img.thumb') && /PDF/i.test(document.querySelectorAll('files-upload li.picked')[1].querySelector('.kind').textContent)`), await pk());await page.click('#chat-text');await pasteFile('#chat-text', 'pasted.png', 'image/png');await page.waitFor(`document.querySelectorAll('files-upload li.picked').length === 3`, { label: 'paste' }).catch(() => {});check(w + ' pick: a paste of a file into the text field collects it (3 rows, the pasted one last), the text stays in the field', (await pk()) === 'pic.png,doc.pdf,pasted.png' && await ev(`document.querySelector('#chat-text').value === ''`), await pk());await fileInput('files-upload input[type=file]', [join(UP, 'big.bin')]);await page.waitFor(`document.querySelectorAll('files-upload li.refused').length === 1`, { label: 'refused' }).catch(() => {});check(w + ' pick: a file over maxSize (2 MB) gets a refused row "Too big", the three others stay', /Too big/.test(await ev(`(document.querySelector('files-upload li.refused .state') || {}).textContent || ''`)) && (await ev(`document.querySelectorAll('files-upload li.picked').length`)) === 3, await pk());await page.click('files-upload li.refused button.remove');await page.waitFor(`document.querySelectorAll('files-upload li.refused').length === 0`, { label: 'refused gone' }).catch(() => {});await page.click('files-upload li.picked[data-i="1"] button.remove');await page.waitFor(`document.querySelectorAll('files-upload li.picked').length === 2`, { label: 'removed' }).catch(() => {});check(w + ' pick: ✕ on the refused row and on doc.pdf take them away → pic.png, pasted.png (the page\'s list follows)', (await pk()) === 'pic.png,pasted.png', await pk());await shot('pick-' + w + '-picked');const rm = await ev(`(() => { const r = document.querySelector('files-upload li.picked button.remove').getBoundingClientRect(); return [r.width, r.height]; })()`);check(w + ' pick: the ✕ is at least 44 × 44', rm[0] >= 44 && rm[1] >= 44, rm.join('x'));// ---- UX mission (creator 2026-10-24: "how is the file drop related to the text field?"): the composer is ONE box ----await page.click('#chat-text');await typeText('Boxed');const bx = await ev(`(() => { const R = (s) => { const e = document.querySelector(s); if (!e) return null; const b = e.getBoundingClientRect(); return { l: Math.round(b.left), r: Math.round(b.right), t: Math.round(b.top), b: Math.round(b.bottom) }; }; const bg = (s) => getComputedStyle(document.querySelector(s)).backgroundColor; return { area: R('files-upload pick-area'), text: R('#chat-text'), list: R('files-upload ul.files'), choose: R('files-upload pick-area label.choose'), send: R('#chat-send'), zone: !!document.querySelector('files-upload drop-zone'), areaBg: bg('files-upload pick-area'), textBg: bg('#chat-text'), sendInArea: document.querySelector('files-upload pick-area').contains(document.querySelector('#chat-send')) }; })()`);check(w + ' pick (one box): the picked files sit right under the text field INSIDE the same box; no separate drop zone', !bx.zone && bx.text.t >= bx.area.t && bx.list.t >= bx.text.b - 1 && bx.list.t - bx.text.b <= 12 && bx.list.b <= bx.area.b && bx.list.l >= bx.area.l && bx.list.r <= bx.area.r, JSON.stringify(bx));check(w + ' pick (one box): "Choose files" is a small button at the bottom left, Send is at the END (bottom right), both in one footer row under the files', bx.sendInArea && bx.choose.l - bx.area.l <= 24 && bx.area.r - bx.send.r <= 24 && Math.abs((bx.choose.t + bx.choose.b) / 2 - (bx.send.t + bx.send.b) / 2) <= 6 && bx.choose.t >= bx.list.b - 1 && bx.send.t >= bx.list.b - 1 && bx.send.l > bx.choose.r && bx.send.b <= bx.area.b, JSON.stringify(bx));check(w + ' pick (one box): the field has no background of its own, the box is the field (sunken surface)', bx.textBg === 'rgba(0, 0, 0, 0)' && bx.areaBg !== 'rgba(0, 0, 0, 0)', JSON.stringify([bx.textBg, bx.areaBg]));const cw = await ev(`(() => { const b = document.querySelector('files-upload pick-area label.choose').getBoundingClientRect(); return [Math.round(b.width), Math.round(b.height)]; })()`);check(w + ' pick (one box): "Choose files" is a small button (under 160 px wide) and a 44 px tap target', cw[0] < 160 && cw[1] >= 44, cw.join('x'));// a real drop of a file onto the TEXT FIELD (not a drop zone) collects it: the whole box takes the dropconst tbox = await page.box('#chat-text');const dropOnText = { items: [], files: [join(UP, 'a.txt')], dragOperationsMask: 1 };for (const type of ['dragEnter', 'dragOver']) await page.send('Input.dispatchDragEvent', { type, x: Math.round(tbox.x), y: Math.round(tbox.y), data: dropOnText });check(w + ' pick (one box): a file dragged over the text field lights the box (class over)', await ev(`document.querySelector('files-upload').classList.contains('over')`));await page.send('Input.dispatchDragEvent', { type: 'drop', x: Math.round(tbox.x), y: Math.round(tbox.y), data: dropOnText });await page.waitFor(`document.querySelectorAll('files-upload li.picked').length === 3`, { label: 'drop on the text field' }).catch(() => {});check(w + ' pick (one box): a real drop onto the text field collects the file (3 rows, a.txt last), the typed text stays', (await pk()) === 'pic.png,pasted.png,a.txt' && (await ev(`document.querySelector('#chat-text').value`)) === 'Boxed', await pk());await page.click('files-upload li.picked[data-i="2"] button.remove');await page.waitFor(`document.querySelectorAll('files-upload li.picked').length === 2`, { label: 'dropped one removed' }).catch(() => {});await shot('pick-' + w + '-box');await ev(`(() => { const t = document.querySelector('#chat-text'); t.value = ''; })()`);await page.click('#chat-text');await typeText('Two files');await page.click('#chat-send');await page.waitFor(`document.querySelectorAll('#sent li').length === 1`, { label: 'sent' }).catch(() => {});check(w + ' pick: Send shows "Two files" with "2 files: pic.png, pasted.png", empties the list and the field', (await ev(`document.querySelector('#sent .sent-text').textContent`)) === 'Two files' && (await ev(`document.querySelector('#sent .sent-files').textContent`)) === '2 files: pic.png, pasted.png' && (await pk()) === '' && (await ev(`document.querySelector('#chat-text').value`)) === '', await ev(`document.querySelector('#sent').textContent`));await shot('pick-' + w + '-sent');await noSideways(w + ' /components/files-upload-pick (used)');// comments with attachmentsawait open('/components/comments');check(w + ' comments attach: the form sits inside a pick area with a "Choose files" input; the editor has no File button', await ev(`!!document.querySelector('comments-block files-upload pick-area label.choose input[type=file]') && !!document.querySelector('comments-block files-upload pick-area form.comment-form') && getComputedStyle(document.querySelector('comments-block form.comment-form md-editor button.file')).display === 'none'`));check(w + ' comments attach: the existing comment c3 shows its file as a plain row (no link)', (await ev(`(document.querySelector('comments-block li.comment[data-id="c3"] .comment-file') || {}).textContent || ''`)).includes('notes-from-the-meeting.pdf') && await ev(`document.querySelector('comments-block li.comment[data-id="c3"] .comment-file').tagName === 'SPAN'`));await shot('comments-' + w + '-before');// creator 2026-10-24 ("half this distance please"): the like / Edit / Delete row sits close under its comment: its box starts at most 8 px inside the// bubble's empty bottom padding, never over the comment's text, and the buttons stay 44 px tallconst ra = await ev(`(() => { const out = []; for (const li of document.querySelectorAll('comments-block li.comment')) { const bub = li.querySelector('comment-bubble'), act = li.querySelector('comment-actions'); if (!bub || !act) continue; const bb = bub.getBoundingClientRect(), ab = act.getBoundingClientRect(), last = bub.lastElementChild.getBoundingClientRect(); const btn = act.querySelector('button').getBoundingClientRect(); out.push({ gap: Math.round(ab.top - bb.bottom), content: Math.round(last.bottom - ab.top), tap: Math.round(btn.height) }); } return out; })()`);check(w + ' comments: the reactions row starts 0–8 px inside its bubble (halved distance), never over the comment text, buttons 44 px', ra.length > 0 && ra.every(r => r.gap <= 0 && r.gap >= -8 && r.content <= 0.5 && r.tap >= 44), JSON.stringify(ra));await fileInput('comments-block files-upload label.choose input[type=file]', [join(UP, 'pic.png'), join(UP, 'doc.pdf')]);await page.waitFor(`document.querySelectorAll('comments-block li.picked').length === 2`, { label: 'comment files' }).catch(() => {});await pasteFile('comments-block form.comment-form md-editor article', 'shot.png', 'image/png');await page.waitFor(`document.querySelectorAll('comments-block li.picked').length === 3`, { label: 'comment paste' }).catch(() => {});check(w + ' comments attach: two chosen + one pasted into the editor (files="off": the FilesUpload takes it) → 3 waiting', (await ev(`document.querySelectorAll('comments-block li.picked').length`)) === 3 && (await ev(`document.querySelector('comments-block form.comment-form article').textContent`)) === '');await page.click('comments-block form.comment-form md-editor article');await typeText('with files');await shot('comments-' + w + '-attached');await key('Enter', 'Enter', 13, '\r', 2);await page.waitFor(`document.querySelectorAll('comments-block li.comment').length === 4 && document.querySelector('#comments-told').textContent === 'post with 3 files'`, { label: 'posted with files' }).catch(() => {});check(w + ' comments attach: Ctrl+Enter posts → 4 comments, told "post with 3 files", the new one lists pic.png, doc.pdf, shot.png as rows, the waiting files are cleared', (await told()) === 'post with 3 files' && (await ev(`[...document.querySelectorAll('comments-block li.comment[data-id="n1"] .comment-file')].map(e => e.textContent.replace(/\\s+/g, ' ').trim()).join('|')`)).split('|').length === 3 && (await ev(`document.querySelectorAll('comments-block li.picked').length`)) === 0, await told());await shot('comments-' + w + '-posted');await noSideways(w + ' /components/comments (with files)');// md-editor: rows, files="off", md-emptyawait open('/components/md-editor');const me = await ev(`(() => { const ed = [...document.querySelectorAll('md-editor')].find(e => e.querySelector('[name=line]') || e.getAttribute('name') === 'line' || /One line/.test(e.innerHTML)); if (!ed) return null; const s = ed.querySelector('article'); return { h: s.getBoundingClientRect().height, file: getComputedStyle(ed.querySelector('button.file')).display !== 'none', empty: ed.classList.contains('md-empty'), old: ed.classList.contains('empty'), min: getComputedStyle(s).minHeight, fs: parseFloat(getComputedStyle(s).fontSize) }; })()`);check(w + ' md-editor rows=1: the surface is one line high (min-height 24px, < 3 lines), no File button, empty state is the class md-empty (not "empty")', !!me && me.h < me.fs * 3 && me.min === '24px' && !me.file && me.empty && !me.old, JSON.stringify(me));const first = await ev(`(() => { const ed = document.querySelector('md-editor'); return { file: getComputedStyle(ed.querySelector('button.file')).display !== 'none', h: ed.querySelector('article').getBoundingClientRect().height }; })()`);check(w + ' md-editor default: the File button is there and the surface keeps its six-row height (≥ 6 lines)', first.file && first.h >= 6 * 16 * 1.4, JSON.stringify(first));await page.click('md-editor[name="line"] article, form:last-of-type md-editor article').catch(() => {});await shot('mdeditor-' + w);const tb = await ev(`(() => { const t = [...document.querySelectorAll('md-editor')].find(e => /One line/.test(e.innerHTML)).querySelector('nav'); if (!t) return null; const r = t.getBoundingClientRect(); const kb = [...t.querySelectorAll(':scope > button')].filter(c => c.getBoundingClientRect().width > 0); const kids = kb.map(c => c.getBoundingClientRect()); return { h: r.height, n: kids.length, rows: new Set(kids.map(k => Math.round(k.top))).size, w: r.width }; })()`);check(w + ' md-editor: toolbar of the one-row editor has 11 buttons (File is off, Table is in) and is ' + (w === 390 ? 'two rows on the phone' : 'ONE row on the desktop'), !!tb && tb.n === 11 && tb.rows === (w === 390 ? 2 : 1), JSON.stringify(tb));const tb2 = await ev(`(() => { const t = document.querySelector('md-editor nav'); const kids = [...t.querySelectorAll(':scope > button')].filter(c => c.getBoundingClientRect().width > 0); const b = kids.map(c => c.getBoundingClientRect()); return { n: kids.length, rows: new Set(b.map(k => Math.round(k.top))).size, minW: Math.min(...b.map(k => k.width)), minH: Math.min(...b.map(k => k.height)), table: kids.some(c => /table/i.test((c.getAttribute('aria-label') || '') + (c.title || '') + c.className)) }; })()`);check(w + ' md-editor: the full toolbar has 12 buttons including Table and File, ' + (w === 390 ? 'two rows, every button 44 px high and wide' : 'ONE row, every button 44 px high (40 wide)'), !!tb2 && tb2.n === 12 && tb2.table && tb2.rows === (w === 390 ? 2 : 1) && tb2.minH >= 44 && tb2.minW >= (w === 390 ? 44 : 40), JSON.stringify(tb2));const tl = await ev(`(() => { const c = document.querySelector('md-editor article td'); if (!c) return null; const s = getComputedStyle(c); return { w: s.borderTopWidth, st: s.borderTopStyle }; })()`);check(w + ' md-editor: a table in the editor has thin 1 px lines on its cells (the theme draws them)', !!tl && tl.w === '1px' && tl.st === 'solid', JSON.stringify(tl));await noSideways(w + ' /components/md-editor (new demos)');}await size(1280);// two corner radii only (docs/design-rules.md): every element of every page has corners of 0, 5px, 10px or 50%const cornersOf = `(() => { const out = {}; for (const el of document.querySelectorAll('*')) { const c = getComputedStyle(el);for (const v of [c.borderTopLeftRadius, c.borderTopRightRadius, c.borderBottomRightRadius, c.borderBottomLeftRadius])if (!['0px', '5px', '10px', '50%'].includes(v)) out[v] = (out[v] || el.localName + (el.className && typeof el.className === 'string' ? '.' + el.className.split(' ')[0] : '')); }return out; })()`;const odd = {};for (const r of routes) { await open(r); const o = await ev(cornersOf); if (Object.keys(o).length) odd[r] = o; }check(`1280 all ${routes.length} pages: every corner radius is 0, 5px (small), 10px (large) or 50%`, !Object.keys(odd).length, JSON.stringify(odd));await open('/elements');const rad = await ev(`(() => { const s = (q) => getComputedStyle(document.querySelector(q)).borderTopLeftRadius; return {button: s('elements-page button.primary'), input: s('#el-title'), pill: s('elements-page .pill'), details: s('elements-page details'), drop: s('drop-zone'), menuLink: s('#sidebar > nav a') }; })()`);check('1280 radii: buttons, fields, pills, menu links 5px; foldables and drop zones 10px', rad.button === '5px' && rad.input === '5px' && rad.pill === '5px' && rad.menuLink === '5px' && rad.details === '10px' && rad.drop === '10px', JSON.stringify(rad));// list-first desktop: both; welcome on /; an item opens beside the listawait open('/shells/list-first');const lf = [await rect('list-first > aside'), await rect('list-first > main')];check('1280 list-first /: list and welcome side by side, full width', await shown('list-first > aside') && await shown('list-first > main') && lf[0].x === 0 && lf[1].x === lf[0].r && lf[1].r === 1280 && /Pick a note/.test(await ev(`document.querySelector('list-first > main').textContent`)), JSON.stringify(lf));const hb = await rect('application-header > a.brand');check('1280 list-first: the header spans the page like the shell (brand at the gutter)', hb.x === 16 || hb.x === 24, JSON.stringify(hb));await page.click('list-first > aside a[href="/shells/list-first/groceries"]');await waitPath('/shells/list-first/groceries');await page.waitFor(`document.querySelector('list-first > main h1') && document.querySelector('list-first > main h1').textContent === 'Groceries'`, { label: 'groceries' });await sleep(300);check('1280 list-first item: the note beside the list, the item marked, no back link', await shown('list-first > aside') && (await ev(`document.querySelector('list-first > aside a.selected').getAttribute('href')`)) === '/shells/list-first/groceries' && !(await shown('list-first a.back')));await shot('1280-list-first-detail');// three-pane desktop: all three at the same timeawait open('/shells/three-pane/m2');const tp = [await rect('#sidebar'), await rect('three-pane > aside'), await rect('three-pane > main')];check('1280 three-pane: folders, list and message side by side', tp.every(Boolean) && tp[0].x === 0 && tp[1].x === tp[0].r && tp[2].x === tp[1].r && tp[2].r === 1280 && !(await shown('application-header .menu-toggle')), JSON.stringify(tp));check('1280 three-pane: the actions panel and the opened message', await shown('three-pane > main > menu') && /borderless/.test(await ev(`document.querySelector('three-pane > main h1').textContent`)));await page.click('three-pane > aside a[href="/shells/three-pane/m4"]');await waitPath('/shells/three-pane/m4');await page.waitFor(`/invoice/.test(document.querySelector('three-pane > main h1').textContent)`, { label: 'm4' });check('1280 three-pane: another message opens in place, all three still shown', await shown('#sidebar') && await shown('three-pane > aside'));await shot('1280-three-pane');// content-first demo desktop: the header menu, the column, the loginawait open('/shells/content-first/series');const tb = [await rect('application-header > a.brand'), await rect('content-first > main'), await rect('application-header a.button.primary')];check('1280 tracker demo: header flush with the centred column (brand left = column left, login right = column right)', Math.abs(tb[0].x - tb[1].x) <= 1 && Math.abs(tb[2].r - tb[1].r) <= 1 && tb[1].x > 16, JSON.stringify(tb));check('1280 tracker demo: the phone-only sidebar is gone, the main menu is in the header with Series marked', !(await shown('#sidebar')) && (await ev(`document.querySelector('application-header main-menu a.current').textContent`)) === 'Series');await shot('1280-tracker-demo');// the user menu on desktopawait open('/');await page.click('user-menu .user-toggle');await page.waitFor(`document.querySelector('#user-menu').matches(':popover-open')`, { label: 'user menu desktop' });await sleep(200);const ud = [await rect('#user-menu'), await rect('content-first > main')];check('1280 user menu: the dropdown ends flush with the column, under the header', Math.abs(ud[0].r - ud[1].r) <= 1 && ud[0].y >= 52, JSON.stringify(ud));await shot('1280-user-menu');// ---- tap targets at 390 (mission 006): every button, icon button, brand, menu item, tab and list link >= 44 x 44, fields >= 16 px ----await size(390);for (const path of ['/', '/elements', '/components/pagination', '/components/md-editor', '/components/file-upload', '/components/date-picker', '/shells/content-first/movie', '/shells/list-first/trip', '/shells/three-pane/m2']) {await open(path);for (const [label, toggle, pop] of [['', null, null], ['sidebar open', 'application-header .menu-toggle', '#sidebar'], ['user menu open', 'user-menu .user-toggle', '#user-menu'], ['search open', 'application-header .search-toggle', '#app-search']]) {if (toggle) {if (!(await shown(toggle)) || !(await ev(`!!document.querySelector(${JSON.stringify(pop)})`))) continue;await page.click(toggle);await page.waitFor(`document.querySelector(${JSON.stringify(pop)}).matches(':popover-open')`, { label });await sleep(150);}const a = await ev(AUDIT);const hard = a.taps.filter(t => !t.inline);check(`390 ${path} ${label}: ${a.n} tap targets, none under 44 px, no field under 16 px, nothing wider than the screen`, hard.length === 0 && a.inputs.length === 0 && a.nwide === 0 && a.sw <= a.w, JSON.stringify({ taps: hard.slice(0, 6), inputs: a.inputs.slice(0, 3), wide: a.wide.slice(0, 3), sw: a.sw }));if (toggle) await ev(`document.querySelector(${JSON.stringify(pop)}).hidePopover()`);}}// mission 007: the display audit (found in a real Chrome): per page and width — no sideways scroll, nothing outside the screen,// no text cut off or spilling, no overlapping siblings, no control hidden behind another, no closed popover left on the page,// no text under 4.5:1, no content under the sticky header// ---- mission 009: the main menu marks the current page (aria-current, a visible non-colour marker, contrast), a count badge, the host's say ----const lum = (c) => { const v = c.map(x => { x /= 255; return x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); }); return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2]; };const ratio = (a, b) => { const x = lum(a), y = lum(b); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); };const rgbOf = (s) => (String(s).match(/rgba?\(([^)]+)\)/) || [0, '0,0,0'])[1].split(',').slice(0, 3).map(Number);const marks = (root) => ev(`[...document.querySelectorAll(${JSON.stringify(root + ' a')})].filter(a => a.getAttribute('aria-current') === 'page').map(a => a.firstChild.textContent.trim())`);const markStyle = (sel) => ev(`(() => { const a = document.querySelector(${JSON.stringify(sel)}); if (!a) return null; const c = getComputedStyle(a); return { color: c.color, bg: c.backgroundColor, shadow: c.boxShadow, border: c.borderTopWidth + ' ' + c.borderBottomWidth + ' ' + c.borderLeftWidth + ' ' + c.borderRightWidth === '0px 0px 0px 0px' ? '0px' : 'set', accent: getComputedStyle(document.documentElement).getPropertyValue('--color-accent').trim(), n: a.parentElement.querySelectorAll('a.current').length }; })()`);// UX mission: the marked link has NO bar and NO border (creator 2026-10-24: "why did you add these ugly borders to active nav items?"): no box-shadow, no border, the accent as its text colour on the surface background, text >= 4.5:1const markOk = (m) => { if (!m || m.shadow !== 'none' || m.border !== '0px') return false; const bg = rgbOf(m.bg); const acc = /^#/.test(m.accent) ? [1, 3, 5].map(i => parseInt(m.accent.slice(i, i + 2), 16)) : rgbOf(m.accent); const col = rgbOf(m.color); return col.join() === acc.join() && ratio(col, bg) >= 4.5; };await size(1280);await open('/components');check('1280 main menu: exactly Components is marked (aria-current="page")', JSON.stringify(await marks('application-header main-menu')) === '["Components"]', JSON.stringify(await marks('application-header main-menu')));let ms = await markStyle('application-header main-menu a.current');check('1280 main menu: the marked link is marked by the accent colour on the surface only (no bar, no border), text >= 4.5:1', markOk(ms), JSON.stringify(ms));await page.click('application-header main-menu a[href="/shells"]');await waitPath('/shells');await sleep(400);check('1280 click Shells in the header: the marker moved to Shells, only one', JSON.stringify(await marks('application-header main-menu')) === '["Shells"]', JSON.stringify(await marks('application-header main-menu')));await shot('1280-menu-shells');await page.click('application-header main-menu a[href="/docs"]');await waitPath('/docs');await sleep(400);check('1280 click Docs: the marker moved to Docs', JSON.stringify(await marks('application-header main-menu')) === '["Docs"]');await open('/components/pagination');check('1280 a page below a section (/components/pagination) marks Components in the menu, Pagination in the sidebar', JSON.stringify(await marks('application-header main-menu')) === '["Components"]' && JSON.stringify(await marks('#sidebar nav:not(main-menu nav)')).includes('Pagination'), JSON.stringify([await marks('application-header main-menu'), await marks('#sidebar')]));ms = await markStyle('#sidebar nav a[aria-current="page"]:not(main-menu a)');check('1280 sidebar nav: the current page is the accent colour on the surface only (no bar, no border)', markOk(ms), JSON.stringify(ms));await shot('1280-menu-sidebar-current');await open('/read/using-the-theme');check('1280 the host says which one (current = "/docs" on a /read page): Docs is marked', JSON.stringify(await marks('application-header main-menu')) === '["Docs"]', JSON.stringify(await marks('application-header main-menu')));await open('/shells/content-first');check('1280 item.current = true (host override, no path match): Series is marked on the all-titles page', JSON.stringify(await marks('application-header main-menu')) === '["Series"]', JSON.stringify(await marks('application-header main-menu')));const badge = await ev(`(() => { const a = document.querySelector('application-header main-menu a[href="/shells/content-first/show"]'); const b = a && a.querySelector('span.count'); if (!b) return null; const c = getComputedStyle(b); return { label: a.firstChild.textContent.trim(), count: b.textContent, color: c.color, bg: c.backgroundColor }; })()`);check('1280 a menu item carries a count badge as a prop (label stays "Shows", badge 12, text >= 4.5:1)', badge && badge.label === 'Shows' && badge.count === '12' && ratio(rgbOf(badge.color), rgbOf(badge.bg)) >= 4.5, JSON.stringify(badge));check('1280 items without a count have no badge', (await ev(`document.querySelectorAll('application-header main-menu span.count').length`)) === 1);await shot('1280-menu-badge');await page.click('application-header main-menu a[href="/shells/content-first/movie"]');await waitPath('/shells/content-first/movie');await sleep(400);check('1280 click Movies in the tracker demo: the marker moved from Series to Movies', JSON.stringify(await marks('application-header main-menu')) === '["Movies"]', JSON.stringify(await marks('application-header main-menu')));// mission 011 (hybriel#197): the tracker demo gives MainMenu NO `current`; the marker comes from the route and is in the server's HTML (no flicker)const ssrMarks = async (path) => { const html = await (await fetch(BASE + path)).text(); return [...html.matchAll(/<main-menu>.*?<\/main-menu>/gs)].map(m => [...m[0].matchAll(/<a href="[^"]*" class="current" aria-current="page">([^<]*)/g)].map(x => x[1]).join(',')); };for (const [path, want] of [['/shells/content-first/movie', 'Movies'], ['/shells/content-first/genre', 'Genres'], ['/shells/content-first/person', 'People']]) {const got = await ssrMarks(path);check('SSR ' + path + ': both main menus (header, sidebar) carry the marker from the route, before any script', got.length === 2 && got.every(g => g === want), JSON.stringify(got));}check('SSR /shells/content-first: Series is marked (item.current flag stays the fallback)', (await ssrMarks('/shells/content-first')).every(g => g === 'Series'));await size(390);await open('/components');await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'sidebar opens (menu mark)' });await sleep(250);check('390 sidebar main menu: Components marked', JSON.stringify(await marks('#sidebar main-menu')) === '["Components"]');ms = await markStyle('#sidebar main-menu a.current');check('390 sidebar main menu: accent colour only, no bar, no border', markOk(ms), JSON.stringify(ms));await shot('390-menu-components');await page.click('#sidebar main-menu a[href="/shells"]');await waitPath('/shells');await sleep(400);await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'sidebar opens again' });await sleep(250);check('390 click Shells in the sidebar menu, reopen: the marker moved to Shells', JSON.stringify(await marks('#sidebar main-menu')) === '["Shells"]', JSON.stringify(await marks('#sidebar main-menu')));await shot('390-menu-shells');await ev(`document.querySelector('#sidebar').hidePopover()`);await open('/shells/content-first/show');await page.click('application-header .menu-toggle');await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'tracker sidebar opens' });await sleep(250);check('390 the badge shows in the phone menu next to "Shows" and the tap target stays >= 44 px', await ev(`(() => { const a = document.querySelector('#sidebar main-menu a[href="/shells/content-first/show"]'); const b = a.querySelector('span.count'); return !!b && b.textContent === '12' && a.getBoundingClientRect().height >= 44; })()`));await shot('390-menu-badge');await ev(`document.querySelector('#sidebar').hidePopover()`);const shownPages = ['/', '/elements', '/components', '/components/month-view', '/components/date-picker', '/components/pagination', '/components/md-editor', '/components/comments', '/components/files-upload-pick', '/components/modal', '/shells', '/shells/content-first/movie', '/shells/list-first', '/shells/list-first/trip', '/shells/three-pane', '/shells/three-pane/m2', '/docs', '/read/using-the-theme', '/settings', '/search/modal'];const findings = (d) => {const bits = [];if (d.hscroll) bits.push('sideways scroll ' + d.sw);for (const k of ['wide', 'spill', 'overlaps', 'covered', 'stray', 'contrast']) if (d[k].length) bits.push(`${k}: ${JSON.stringify(d[k][0])}${d[k].length > 1 ? ' +' + (d[k].length - 1) : ''}`);const clip = d.clipped.filter(c => !c.ellipsis); if (clip.length) bits.push('clipped: ' + JSON.stringify(clip[0]));if (d.underHeader) bits.push('under the header: ' + JSON.stringify(d.underHeader));return bits.join(' ; ');};for (const w of [390, 1280]) {await size(w);for (const path of shownPages) {await open(path);const states = [['', null, null]];if (await shown('application-header .menu-toggle')) states.push(['sidebar open', 'application-header .menu-toggle', '#sidebar']);if (await shown('application-header .search-toggle')) states.push(['search open', 'application-header .search-toggle', '#app-search']);if (await shown('user-menu .user-toggle')) states.push(['user menu open', 'user-menu .user-toggle', '#user-menu']);for (const [label, toggle, pop] of states) {if (toggle) { await page.click(toggle); await page.waitFor(`document.querySelector(${JSON.stringify(pop)}).matches(':popover-open')`, { label }); await sleep(150); }const d = await ev(DISPLAY);check(`${w} display ${path} ${label}: nothing overlaps, spills, hides behind another or leaves the screen`, findings(d) === '', findings(d));if (toggle) await ev(`document.querySelector(${JSON.stringify(pop)}).hidePopover()`);}}}// ---- mission ML (mobile first audit, 390 px): list mlRows, table words, the "edited" tap target, code in titles ----await size(390);const mlBoxes = (js) => ev(js);await open('/shells/list-first');const mlRows = await mlBoxes(`[...document.querySelectorAll('list-first > aside li a')].map(a => { const ar = a.getBoundingClientRect(), side = a.closest('aside').getBoundingClientRect(), t = a.querySelector('note-title').getBoundingClientRect(), u = a.querySelector('note-updated').getBoundingClientRect(); return { w: Math.round(ar.width), side: Math.round(side.width), under: u.top >= t.bottom - 1, uh: Math.round(u.height), uw: Math.round(u.width), text: a.textContent.slice(0, 20) }; })`);check(`390 list-first: ${mlRows.length} note rows are as wide as the list, the date under the title on ONE line (not a 1-letter column beside it)`, mlRows.length === 6 && mlRows.every(r => r.w >= r.side - 32 && r.under && r.uh <= 24 && r.uw > 40), JSON.stringify(mlRows.filter(r => !(r.w >= r.side - 32 && r.under && r.uh <= 24 && r.uw > 40))));await open('/shells/three-pane');const mlMails = await mlBoxes(`[...document.querySelectorAll('three-pane > aside li a')].map(a => { const ar = a.getBoundingClientRect(), f = a.querySelector('mail-from').getBoundingClientRect(), s = a.querySelector('mail-subject').getBoundingClientRect(), sp = [...a.querySelectorAll('mail-from span')].map(x => x.getBoundingClientRect()); return { w: Math.round(ar.width), fw: Math.round(f.width), subjectBelow: s.top >= f.bottom - 1, subjectW: Math.round(s.width), fromH: Math.round(sp[0].height), dateH: Math.round(sp[1].height), dateW: Math.round(sp[1].width), text: a.textContent.slice(0, 20) }; })`);const mailOk = (m) => m.fw >= m.w - 32 && m.subjectBelow && m.subjectW >= m.w - 32 && m.dateH <= 24 && m.dateW > 30 && m.fromH <= 48;check(`390 three-pane: ${mlMails.length} mail rows: sender + date on one row over the full width, the subject below it (no squeezed columns)`, mlMails.length === 6 && mlMails.every(mailOk), JSON.stringify(mlMails.filter(m => !mailOk(m))));await shot('390-ml-mail-list');await open('/elements');const mlCell = await mlBoxes(`(() => { const td = [...document.querySelectorAll('table td')].find(t => t.textContent.trim() === 'watched'); const r = td.getBoundingClientRect(); return { h: Math.round(r.height), w: Math.round(r.width), line: parseFloat(getComputedStyle(td).lineHeight) }; })()`);check('390 elements: the table word "watched" stays on one line (a table mlCell is not squeezed to a letter per line)', mlCell.h < mlCell.line * 1.8 + 12, JSON.stringify(mlCell));await open('/components/comments');const mlEd = await mlBoxes(`(() => { const s = document.querySelector('comments-block details.comment-history summary'); const r = s.getBoundingClientRect(); return { w: Math.round(r.width), h: Math.round(r.height) }; })()`);check('390 comments: the "edited" label is a 44 px tap target', mlEd.w >= 44 && mlEd.h >= 44, JSON.stringify(mlEd));await open('/read/layouts-app-header');const mlHc = await mlBoxes(`(() => { const h = document.querySelector('md-editor article h1'); const c = h.querySelector('code'); return { h: parseFloat(getComputedStyle(h).fontSize), c: parseFloat(getComputedStyle(c).fontSize) }; })()`);check('390 docs: code in a title is smaller than the title (not title-sized and wrapping word by word)', mlHc.c <= mlHc.h * 0.7, JSON.stringify(mlHc));await shot('390-ml-docs-title');// ---- sync of components.hybriel 4922f9c (mission MC/SY): 44 px targets on a phone in the pickers' popups, month view, modal, pagination, comments ----const smallTargets = (sel) => ev(`[...document.querySelectorAll(${JSON.stringify(sel)})].filter(e => e.getBoundingClientRect().width > 0 && e.closest('md-editor') == null).map(e => { const r = e.getBoundingClientRect(); return { t: (e.textContent || e.id || e.tagName).trim().slice(0, 12), w: Math.round(r.width), h: Math.round(r.height) }; }).filter(x => x.h < 43.5 || x.w < 43.5)`);await open('/components/month-view');check('390 month-view: prev / next are 44 px targets', (await smallTargets('month-view header button')).length === 0, JSON.stringify(await smallTargets('month-view header button')));await open('/components/date-picker');await page.click('date-picker input');await page.waitFor(`getComputedStyle(document.querySelector('date-picker picker-popup')).display !== 'none'`, { label: 'date popup 390' });await sleep(300);const dpSmall = await smallTargets('date-picker input, date-picker picker-popup button, date-picker ol.days li');check('390 date-picker: field, popup arrows and the day cells are 44 px targets', dpSmall.length === 0, JSON.stringify(dpSmall.slice(0, 5)));await shot('390-sy-date-picker-open');await open('/components/range-picker');await page.click('range-picker input');await page.waitFor(`getComputedStyle(document.querySelector('range-picker picker-popup')).display !== 'none'`, { label: 'range popup 390' });await sleep(300);const rpSmall = await smallTargets('range-picker input, range-picker picker-popup button, range-picker ol.days li');check('390 range-picker: field, popup arrows and the day cells are 44 px targets', rpSmall.length === 0, JSON.stringify(rpSmall.slice(0, 5)));await open('/components/pagination');check('390 pagination: page buttons are 44 px targets', (await smallTargets('pagination li:not(.gap) button')).length === 0, JSON.stringify(await smallTargets('pagination li:not(.gap) button')));await open('/components/modal');await page.click('#open-confirm');await page.waitFor(`document.querySelector('#confirm').open`, { label: 'modal open 390' });await sleep(300);const mdSmall = await smallTargets('#confirm button');check('390 modal: × and the footer buttons are 44 px targets', mdSmall.length === 0, JSON.stringify(mdSmall));await shot('390-sy-modal-open');await open('/components/comments');const cmSmall = await smallTargets('comments-block button, comments-block summary');check('390 comments: like / Edit / Delete / "edited" are 44 px targets', cmSmall.length === 0, JSON.stringify(cmSmall.slice(0, 5)));await shot('390-sy-comments');// ---- HL-STANDARD F5 + F21: the keyboard and the history (W1110C) -----------------------------------------------------------------// real Tab / Enter / Space key events (no click, no focus() call to get there), Back / Forward / reload / a second tab on deep URLsconst kEnter = () => key('Enter', 'Enter', 13, '\r');const kSpace = () => key(' ', 'Space', 32, ' ');const kTab = (shift = false) => key('Tab', 'Tab', 9, undefined, shift ? 8 : 0);const activeIs = (sel) => ev(`(() => { const a = document.activeElement; return !!a && a.matches(${JSON.stringify(sel)}); })()`);const activeDesc = () => ev(`(() => { const a = document.activeElement; return a ? a.tagName.toLowerCase() + (a.getAttribute('href') ? '[' + a.getAttribute('href') + ']' : '') + (a.name ? '#' + a.name : '') : 'none'; })()`);// Tab (or Shift+Tab) until the focused element matches sel; returns the list of stops it passed, or nullconst tabTo = async (sel, max = 60, shift = false) => {const stops = [];for (let i = 0; i < max; i++) {if (await activeIs(sel)) return stops;await kTab(shift);stops.push(await activeDesc());}return (await activeIs(sel)) ? stops : null;};const snap = () => ev(`(() => { const m = document.querySelector('main h1, three-pane > main h1'); const c = document.querySelector('application-header main-menu a.current'); const sel = document.querySelector('three-pane > aside a.selected'); return location.pathname + ' | ' + (m ? m.textContent.trim() : '-') + ' | ' + (c ? c.textContent : '-') + ' | ' + (sel ? sel.getAttribute('href') : '-'); })()`);await size(1280);// -- main menu with the keyboard: Tab from the top of the page reaches the brand, then the menu links; Enter on a link goes thereawait open('/elements');const toMenu = await tabTo('application-header main-menu a[href="/components"]');check('1280 keyboard: Tab from the page top reaches the brand and then the main menu link "Components"', toMenu !== null && toMenu.some(s => /^a\[\/\]$/.test(s)) && toMenu.length <= 12, JSON.stringify(toMenu));check('1280 keyboard: the focused menu link shows a visible focus ring', (await ev(`(() => { const s = getComputedStyle(document.activeElement); return s.outlineStyle !== 'none' && parseFloat(s.outlineWidth) > 0; })()`)), await ev(`getComputedStyle(document.activeElement).outline`));await kEnter();await waitPath('/components');await page.waitFor(`(document.querySelector('application-header main-menu a.current') || {}).textContent === 'Components'`, { label: 'Components marked current' });check('1280 keyboard: Enter on the focused main menu link opens /components and marks it current', (await snap()).startsWith('/components |'), await snap());await tabTo('application-header main-menu a[href="/shells"]');await kTab(true);check('1280 keyboard: Shift+Tab walks back to the previous menu link', await activeIs('application-header main-menu a[href="/components"]'), await activeDesc());// -- buttons: Space and Enter on the accent switcher's real buttonsconst accentNow = () => ev(`getComputedStyle(document.querySelector('application-header main-menu a.current')).color`);await open('/elements');const accDefault = await accentNow();const toPurple = await tabTo('accent-switcher button[value="purple"]', 80);check('1280 keyboard: Tab reaches the accent switcher\'s purple button', toPurple !== null, 'not reached');await kSpace();await sleep(250);check('1280 keyboard: Space on a focused button activates it (purple accent)', (await accentNow()) === 'rgb(197, 134, 192)', await accentNow());await tabTo('accent-switcher button.reset');await kEnter();await sleep(250);check('1280 keyboard: Enter on a focused button activates it (Reset → default accent)', (await accentNow()) === accDefault, `${await accentNow()} vs ${accDefault}`);// -- the search form: Tab into the field, type, Enter submits (GET /search?q= → /search/modal)await open('/');const toSearch = await tabTo('#app-search input');check('1280 keyboard: Tab reaches the header search field', toSearch !== null, 'not reached');await typeText('modal');await kEnter();await waitPath('/search/modal');await page.waitForSelector('ul.pages a[href="/components/modal"]', { timeout: 15000 });check('1280 keyboard: Enter in the search field submits it → /search/modal lists the Modal page', true);// -- history: Back / Forward / reload / a second tab on the search result and on a deep three-pane URL show the same stateconst search1 = await snap();const listOf = () => ev(`[...document.querySelectorAll('ul.pages a')].map(a => a.getAttribute('href')).join(',')`);const listBefore = await listOf();// a marker set before the reload must be gone afterwards: only then is the NEW document there (not the old socket)const reloadFresh = async (label) => { await ev('window.__w1110 = 1'); await page.send('Page.reload'); await page.waitFor('window.__w1110 === undefined', { timeout: 30000, label: 'new document ' + label }); await hydrated('hydrated after reload ' + label); };await reloadFresh('search'); await sleep(300);check('1280 reload on /search/modal shows the same page and the same hits', (await snap()) === search1 && (await listOf()) === listBefore && /\/components\/modal/.test(listBefore), `${await snap()} vs ${search1}`);await open('/shells/three-pane');await page.click('three-pane > aside a[href="/shells/three-pane/m3"]');await waitPath('/shells/three-pane/m3');await page.waitFor(`document.querySelector('three-pane').classList.contains('detail') || !!document.querySelector('three-pane > main h1')`, { label: 'm3 shown' });await sleep(300);const m3 = await snap();await tabTo('three-pane > aside a[href="/shells/three-pane/m2"]', 80);await kEnter();await waitPath('/shells/three-pane/m2');await page.waitFor(`/^Re: the theme/.test(((document.querySelector('three-pane > main h1') || {}).textContent || '').trim())`, { label: 'm2 shown' });await sleep(300);const m2 = await snap();const isM2 = (t) => /^\/shells\/three-pane\/m2 \| Re: the theme[^|]* \| [^|]* \| \/shells\/three-pane\/m2$/.test(t);check('1280 keyboard: Tab to a message in the list and Enter opens it (/shells/three-pane/m2, another title than m3)', m2 !== m3 && isM2(m2), m2 + ' / ' + m3);await ev('history.back()');await waitPath('/shells/three-pane/m3');await sleep(400);check('1280 Back from m2 returns to m3 with the same message shown', (await snap()) === m3 && /^\/shells\/three-pane\/m3 \| tracker#32 .* \| - \| \/shells\/three-pane\/m3$/.test(m3), `${await snap()} vs ${m3}`);await ev('history.forward()');await waitPath('/shells/three-pane/m2');await sleep(400);check('1280 Forward returns to m2 with the same message shown', (await snap()) === m2 && isM2(m2), `${await snap()} vs ${m2}`);await reloadFresh('m2'); await sleep(400);check('1280 reload on /shells/three-pane/m2 shows the same message', (await snap()) === m2 && isM2(m2), `${await snap()} vs ${m2}`);const tab2 = await browser.newPage();let tab2Problems = [];try {await tab2.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });await tab2.goto(BASE + '/shells/three-pane/m2', { timeout: 45000 });await tab2.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 30000, label: 'new tab live' });await sleep(400);const other = await tab2.evaluate(`(() => { const m = document.querySelector('main h1, three-pane > main h1'); const c = document.querySelector('application-header main-menu a.current'); const sel = document.querySelector('three-pane > aside a.selected'); return location.pathname + ' | ' + (m ? m.textContent.trim() : '-') + ' | ' + (c ? c.textContent : '-') + ' | ' + (sel ? sel.getAttribute('href') : '-'); })()`);check('1280 the same URL opened in a new tab shows the same message', other === m2 && isM2(other), `${other} vs ${m2}`);} finally { tab2Problems = tab2.problems(); await tab2.close().catch(() => {}); }// -- the comment form with the keyboard: type in the editor, Tab to the post button, Enter postsawait open('/components/comments');const n0 = Number(await ev(`document.querySelectorAll('comments-block li.comment').length`));await page.click('comments-block form.comment-form md-editor [contenteditable]');await typeText('posted by Tab and Enter');const toPost = await tabTo('comments-block form.comment-form button.comment-post', 20);check('1280 keyboard: Tab leaves the comment editor and reaches the post button', toPost !== null, 'not reached from the editor');await kEnter();await page.waitFor(`document.querySelectorAll('comments-block li.comment').length === ${n0 + 1}`, { label: 'posted by Enter on the button' }).catch(() => {});check('1280 keyboard: Enter on the focused post button submits the comment form (one more comment)', Number(await ev(`document.querySelectorAll('comments-block li.comment').length`)) === n0 + 1 && /Tab and Enter/.test(await ev(`document.querySelector('comments-block li.comment:last-child').textContent`)), String(await ev(`document.querySelectorAll('comments-block li.comment').length`)));// -- the phone: Tab to the sidebar toggle, Enter opens the overlay, Tab into it, Enter on a link navigates and closes itawait size(390);await open('/elements');const toToggle = await tabTo('application-header .menu-toggle');check('390 keyboard: Tab reaches the sidebar toggle', toToggle !== null, 'not reached');await kEnter();await page.waitFor(`document.querySelector('#sidebar').matches(':popover-open')`, { label: 'Enter on the toggle opens the sidebar' });check('390 keyboard: Enter on the toggle opens the sidebar overlay', true);const toLink = await tabTo('#sidebar nav a[href="/components/pagination"]', 80);check('390 keyboard: Tab moves into the open sidebar and reaches a page link', toLink !== null, 'not reached');await kEnter();await waitPath('/components/pagination');await sleep(300);check('390 keyboard: Enter on the sidebar link navigates and closes the overlay', !(await popOpen('#sidebar')), String(await popOpen('#sidebar')));await size(1280);const problems = [...page.problems(), ...tab2Problems].filter(m => !/favicon|Failed to load resource/.test(m.text));check('no console errors or warnings on any page', problems.length === 0, problems.map(p => p.text).join('\n'));}try {await main();} catch (e) {failures++;console.log('FAIL (aborted) ' + (e && e.stack || e));} finally {await stop();}console.log(`\n${passes} passed, ${failures} failed — screenshots in .scratch/gate-shots/`);process.exit(failures ? 1 : 0);
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