@krizaka/page-audit 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krizaka/page-audit",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The page audit of every Krizaka app, in one place: HTTP status, empty main, horizontal overflow, a card out of its panel, sections covering each other, a column cut off, top chrome overlaps, unnamed buttons, empty headings. Runs in a real browser (Playwright) over a route list, viewports and themes, with View Transitions neutralised and a self-test on its own fixtures.",
5
5
  "keywords": [
6
6
  "krizaka",
package/src/fixtures.mjs CHANGED
@@ -43,3 +43,8 @@ export const BROKEN_PARTS = page(`<img src="data:image/png;base64,AAAA" width="4
43
43
  /** Chrome that fits the family: one footer naming Krizaka, a nav. */
44
44
  export const CHROME_FINE = `<!doctype html><html><body><nav>n</nav><main><p>Hello</p></main><footer>A Krizaka product</footer></body></html>`;
45
45
  export const CHROME_BAD = `<!doctype html><html><body><main><p>Hello</p></main><footer>one</footer><footer>two</footer></body></html>`;
46
+
47
+ /** A short token in a table row stretched by a tall neighbour: the cell is tall, its text is one line. */
48
+ export const TOKEN_IN_STRETCHED_ROW = page(`<table style="width:600px"><tbody><tr><td>orazaka-media-pack</td><td>${"A long description. ".repeat(30)}</td></tr></tbody></table>`);
49
+ /** An identifier in a narrow cell that breaks every few characters. */
50
+ export const TOKEN_WRAPPED = page(`<table style="width:100px;table-layout:fixed"><tbody><tr><td style="word-break:break-all;font-size:20px">abcdefghijklmnopqrstuvwxyz0123456789</td></tr></tbody></table>`);
@@ -164,14 +164,15 @@ function clipsOf() {
164
164
  .map(nameOf);
165
165
  }
166
166
 
167
- /** A long token (an id, an address) that wraps character by character: a cell taller than two lines for text without a space. */
167
+ /** A long token (an id, an address) that wraps character by character: text without a space whose own lines (not the cell's, which a taller neighbour in the row stretches) are more than two and a half. */
168
168
  function tooTall(el) {
169
169
  const text = (el.textContent || "").trim();
170
170
  if (text.length < 12 || /\s/.test(text) || el.children.length > 1) return false;
171
171
  const cs = getComputedStyle(el);
172
172
  const lh = Number.parseFloat(cs.lineHeight) || Number.parseFloat(cs.fontSize) * 1.4;
173
- const content = el.getBoundingClientRect().height - Number.parseFloat(cs.paddingTop) - Number.parseFloat(cs.paddingBottom);
174
- return content > lh * 2.5;
173
+ const range = document.createRange();
174
+ range.selectNodeContents(el);
175
+ return range.getBoundingClientRect().height > lh * 2.5;
175
176
  }
176
177
 
177
178
  function wrappedOf() {
package/src/self-test.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // The audit proven on its own fixtures, in a real browser: each broken fixture must be reported, the fine ones must not.
2
2
  // A guard that stopped seeing is itself a red build.
3
- import { BOX_TOO_WIDE, BROKEN_PARTS, CARD_OVER_NEXT, CHROME_BAD, CHROME_FINE, COLUMN_CUT, EMPTY_MAIN, FINE, FOLDED_SECTION, FRAME_FITS, FRAME_FORCES_SCROLL, HIDDEN_CONTENT, SECTIONS_OVERLAP, SMALL_ACTION } from "./fixtures.mjs";
3
+ import { BOX_TOO_WIDE, BROKEN_PARTS, CARD_OVER_NEXT, CHROME_BAD, CHROME_FINE, COLUMN_CUT, EMPTY_MAIN, FINE, FOLDED_SECTION, FRAME_FITS, FRAME_FORCES_SCROLL, HIDDEN_CONTENT, SECTIONS_OVERLAP, SMALL_ACTION, TOKEN_IN_STRETCHED_ROW, TOKEN_WRAPPED } from "./fixtures.mjs";
4
4
  import { auditPage, problemsOf } from "./page-audit.mjs";
5
5
  import { auditContext } from "./settle.mjs";
6
6
 
@@ -9,6 +9,7 @@ const EXPECT = [
9
9
  ["a card over the next section", CARD_OVER_NEXT, /covers a neighbouring section/],
10
10
  ["two sections on top of each other", SECTIONS_OVERLAP, /covers a neighbouring section/],
11
11
  ["a column cut by a clipping wrapper", COLUMN_CUT, /is cut off/],
12
+ ["an identifier that breaks every few characters", TOKEN_WRAPPED, /wraps one character per line/],
12
13
  ["an empty <main>", EMPTY_MAIN, /empty <main>/, { emptyMain: true }],
13
14
  ["a frame that forces a scroll", FRAME_FORCES_SCROLL, /the frame forces a scroll/, { frame: true }],
14
15
  ["an action under the tap target", SMALL_ACTION, /an action is 24 px tall \(< 36\)/, { minAction: 36 }],
@@ -23,6 +24,7 @@ const FINES = [
23
24
  ["a fine layout", FINE],
24
25
  ["content that is not drawn (a visually hidden table, a folded details)", HIDDEN_CONTENT],
25
26
  ["a section folded in a details", FOLDED_SECTION],
27
+ ["a short token in a row a taller neighbour stretches", TOKEN_IN_STRETCHED_ROW],
26
28
  ];
27
29
  /** Fixtures that must stay clean even with every opt-in check on. */
28
30
  const ALL = { emptyMain: true, frame: true, minAction: 36, boxes: true, pictures: true, emptyControls: true, hardColors: true, landmarks: "public" };