gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite84be3dee84be3deident#34: browser gate lists the Edit/Delete buttons by namemree84be3de/tests/mobile-measure.js

4.8 KB

  1. // tests/mobile-measure.js — THE PHONE MEASUREMENT of one page (tickets mission 022, from gitoria's), evaluated inside the page by
  2. // tests/e2e-theme.mjs (real Chrome) . Set `window.__W` (the phone width, 390) before; returns one object:
  3. // docScrollWidth the page's width (must be ≤ __W: no sideways scroll — innerWidth is NOT used, a mobile viewport grows with the page)
  4. // taps / tapsSmall interactive elements (a[href], button, summary, fields) and those under 44×44 px. Exempt (WCAG 2.5.8 "inline"):
  5. // a link that flows inside a sentence (display inline, its parent has more text than the link)
  6. // inputsSmall visible fields with a font under 16 px (iOS zooms into them on focus)
  7. // textSmall visible elements whose own text is under 14 px
  8. // headerH the application header's height
  9. // boxesOver code / table boxes (pre, markdown tables) that reach past the screen edge
  10. // wide visible elements wider than the screen (not inside a box that scrolls sideways itself)
  11. (() => {
  12. const W = window.__W || 390;
  13. const sel = (e) => { let s = e.tagName.toLowerCase(); if (e.id) s += '#' + e.id; else if (typeof e.className === 'string' && e.className.trim()) s += '.' + e.className.trim().split(/\s+/).join('.'); return s; };
  14. const shown = (e) => { const r = e.getBoundingClientRect(); if (r.width <= 0 || r.height <= 0) return false; const cs = getComputedStyle(e); return cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0'; };
  15. const out = { url: location.href, W, docScrollWidth: document.documentElement.scrollWidth, docHeight: document.documentElement.scrollHeight };
  16. out.hscroll = out.docScrollWidth > W;
  17. const inline = (e) => { if (e.tagName !== 'A' || getComputedStyle(e).display !== 'inline' || !e.parentElement) return false; return e.parentElement.textContent.trim().length > e.textContent.trim().length; };
  18. const tapEls = [...document.querySelectorAll('a[href], button, summary, input:not([type=hidden]), select, textarea, [role=button]')].filter(shown);
  19. const small = [];
  20. for (const e of tapEls) { if (inline(e)) continue; const r = e.getBoundingClientRect(); if (r.width < 43.5 || r.height < 43.5) small.push(`${sel(e)} "${(e.textContent || e.value || '').trim().slice(0, 20)}" ${Math.round(r.width)}x${Math.round(r.height)}`); }
  21. // ident's selector (shadow DOM): its visible buttons count too
  22. for (const h of document.querySelectorAll('ident-selector')) if (h.shadowRoot && shown(h)) for (const e of h.shadowRoot.querySelectorAll('button, a[href], input')) { if (!shown(e)) continue; const r = e.getBoundingClientRect(); if (r.width < 43.5 || r.height < 43.5) small.push(`shadow:${sel(e)} ${Math.round(r.width)}x${Math.round(r.height)}`); }
  23. out.taps = tapEls.length; out.tapsSmall = small.length; out.tapsSmallList = small.slice(0, 12);
  24. const fields = [...document.querySelectorAll('input:not([type=hidden]), textarea, select')].filter(shown);
  25. out.inputs = fields.length; out.inputsSmallList = fields.filter(e => parseFloat(getComputedStyle(e).fontSize) < 15.95).map(e => `${sel(e)} ${getComputedStyle(e).fontSize}`);
  26. out.inputsSmall = out.inputsSmallList.length;
  27. const tiny = {};
  28. for (const e of document.querySelectorAll('body *')) {
  29. if (['SCRIPT', 'STYLE'].includes(e.tagName)) continue;
  30. if (![...e.childNodes].some(n => n.nodeType === 3 && n.textContent.trim())) continue;
  31. if (!shown(e)) continue;
  32. const fs = parseFloat(getComputedStyle(e).fontSize);
  33. if (fs < 13.95) { const k = `${sel(e)} ${fs.toFixed(1)}px`; tiny[k] = (tiny[k] || 0) + 1; }
  34. }
  35. out.textSmall = Object.values(tiny).reduce((a, b) => a + b, 0); out.textSmallList = Object.entries(tiny).slice(0, 8).map(([k, v]) => `${k} x${v}`);
  36. const hd = document.querySelector('application-header'); out.headerH = hd ? Math.round(hd.getBoundingClientRect().height) : null;
  37. out.boxesOver = [...document.querySelectorAll('pre, table, markdown-table')].filter(shown).filter(e => e.getBoundingClientRect().right > W + 1).map(e => `${sel(e)} right ${Math.round(e.getBoundingClientRect().right)}`);
  38. // elements that reach past the screen edge, not counting the contents of an element that scrolls sideways itself
  39. const insideScroll = (e) => { for (let p = e.parentElement; p; p = p.parentElement) { const o = getComputedStyle(p).overflowX; if (o === 'auto' || o === 'scroll' || o === 'hidden') return true; } return false; };
  40. out.wideList = [...document.querySelectorAll('body *')].filter(shown).filter(e => e.getBoundingClientRect().right > W + 0.5 && !insideScroll(e)).slice(0, 8).map(e => `${sel(e)} right ${Math.round(e.getBoundingClientRect().right)}`);
  41. out.wide = out.wideList.length;
  42. out.ok = !out.hscroll && out.tapsSmall === 0 && out.inputsSmall === 0 && out.textSmall === 0 && (out.headerH === null || out.headerH <= 53) && out.boxesOver.length === 0 && out.wide === 0;
  43. return out;
  44. })()

Branches

Latest commits

  • e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
  • fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre
  • 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
  • e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
  • 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
  • f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
  • b323265aMerge branch 'f5-styles' into mainIdent
  • 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
  • f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
  • 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
  • 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
  • 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
  • f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
  • 8370b748ident#33: the app request box moves into home.hl's Stylemre
  • 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
  • 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
  • d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
  • ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre
  • 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
  • 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre