Skip to content

The design language that makes your AI harness better at design.

JavaScript

Fixtures for the viewport-edge and overflow taste calls

Paul Bakaus8be4323b0504
diff --git a/tests/fixtures/antipatterns/body-text-viewport-edge-phone.html b/tests/fixtures/antipatterns/body-text-viewport-edge-phone.html
new file mode 100644
index 000000000..6cfd95851
--- /dev/null
+++ b/tests/fixtures/antipatterns/body-text-viewport-edge-phone.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Body text viewport edge at phone width: should flag vs should pass</title>
+ <style>
+ /* Fixture for body-text-viewport-edge at 390px, scanned with a 390x844
+ viewport. At 480px or less the gutter floor is 12px (16px above): a
+ consistent 12px gutter is a common mobile setting, and text 8px from
+ a phone's edge still reports.
+
+ The body hides sideways overflow, as centene.com's does, so the page
+ cannot scroll sideways: the list at the bottom runs past the right
+ edge and is cut off. That reports once, as the page's overflow, and
+ its items report no gutter. */
+ html { margin: 0; }
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; color: #111; background: #fff; overflow-x: hidden; }
+ h2 { font: 600 14px/1 system-ui; text-transform: uppercase; letter-spacing: 0.05em; margin: 24px 16px 8px; color: #475569; }
+ p, li { margin: 0 0 16px; }
+ .gutter-8 { padding: 0 8px; }
+ .gutter-11 { padding: 0 11px; }
+ .gutter-12 { padding: 0 12px; }
+ .gutter-14 { padding: 0 14px; }
+ .gutter-24 { padding: 0 24px; }
+ .wide-list { width: 480px; margin: 0; padding: 0 0 0 24px; list-style-position: inside; }
+ </style>
+</head>
+<body>
+ <section data-col="flag">
+ <h2>Should flag</h2>
+ <p class="gutter-8 flag-phone-8">This paragraph keeps only 8px between its words and each side of a phone's window, under the 12px a phone gutter needs.</p>
+ <p class="gutter-11 flag-phone-11">This paragraph keeps 11px between its words and each side of the window, a pixel short of the phone gutter floor.</p>
+ </section>
+
+ <section data-col="pass">
+ <h2>Should pass</h2>
+ <p class="gutter-12 pass-phone-12">This paragraph keeps a consistent 12px gutter on both sides of a 390px window, the common mobile setting the phone floor allows.</p>
+ <p class="gutter-14 pass-phone-14">This paragraph keeps 14px on both sides of the window, over the 12px floor that applies at 480px and narrower.</p>
+ <p class="gutter-24 pass-phone-24">This paragraph keeps a roomy 24px gutter on both sides of the window, well inside the edges of the phone.</p>
+ </section>
+
+ <section data-col="overflow">
+ <h2>Page overflow</h2>
+ <!-- A list set 480px wide on a 390px window whose body hides sideways
+ overflow: every item is cut off at the right edge. -->
+ <ul class="wide-list">
+ <li class="past-wide-item">The first item of a list laid out at a fixed desktop width, so every line of it runs past the right edge of the phone and is cut off.</li>
+ <li class="past-wide-item">The second item of the same list, cut off at the same edge, one more line a visitor cannot read the end of on this phone.</li>
+ </ul>
+ </section>
+
+ <script src="/js/detect-antipatterns-browser.js"></script>
+</body>
+</html>
diff --git a/tests/fixtures/antipatterns/body-text-viewport-edge.html b/tests/fixtures/antipatterns/body-text-viewport-edge.html
index e1c95c68a..08d1b1350 100644
--- a/tests/fixtures/antipatterns/body-text-viewport-edge.html
+++ b/tests/fixtures/antipatterns/body-text-viewport-edge.html
@@ -32,7 +32,8 @@
<body>
<!-- ════════════════════════════════════════════════════════════
- FLAG CASES — body text bleeds to viewport edge.
+ FLAG CASES — body text bleeds to viewport edge (under 16px of the
+ side of a window wider than 480px).
These paragraphs are placed OUTSIDE the .grid container so
their bounding rect actually touches the viewport edges.
═══════════════════════════════════════════════════════════ -->
@@ -52,11 +53,19 @@
<div class="escape">
<p class="flag-inline-prose"><b>An intro set in bold,</b> <i>and the rest of it set in italic, running to the left edge of the viewport with no gutter to hold it in.</i></p>
</div>
+ <!-- ════════════════════════════════════════════════════════════
+ PAGE OVERFLOW CASES — body text that runs past the window's edge.
+ That is not a missing gutter but a page wider than its window, and
+ the paragraphs report no gutter finding. They count toward one
+ page-level finding: this page scrolls sideways, and the widest box
+ that sets its width is the 3800px column row further down.
+ ═══════════════════════════════════════════════════════════ -->
<!-- A wrapper that only hides sideways overflow (Tailwind's
overflow-x-hidden) cuts the words off at the screen edge. Nothing
- scrolls them into view: the cut is the bleed, not a carousel track. -->
+ scrolls them into view: the cut is the page's overflow, not a
+ carousel track. -->
<div class="escape" style="overflow-x: hidden">
- <p class="flag-cut-by-wrapper" style="width: 1400px; margin: 0 0 0 40px">A paragraph given a fixed width wider than the window, inside a page wrapper that hides whatever runs past the right edge, so the end of every line is cut off mid-word where the screen stops and no visitor can ever read it, however far they scroll.</p>
+ <p class="past-cut-by-wrapper" style="width: 1400px; margin: 0 0 0 40px">A paragraph given a fixed width wider than the window, inside a page wrapper that hides whatever runs past the right edge, so the end of every line is cut off mid-word where the screen stops and no visitor can ever read it, however far they scroll.</p>
</div>
<!-- ════════════════════════════════════════════════════════════
@@ -124,7 +133,7 @@
</div>
<!-- The same column starting inside the window runs past its right edge. -->
<div style="width: 2400px">
- <p class="flag-runs-past" style="width: 1100px; margin: 0 0 0 1100px">A column of a fixed-width desktop layout that starts inside the window and runs on past its right edge, cutting every line where the screen stops.</p>
+ <p class="past-runs-on" style="width: 1100px; margin: 0 0 0 1100px">A column of a fixed-width desktop layout that starts inside the window and runs on past its right edge, cutting every line where the screen stops.</p>
</div>
<!-- A ticker moves its track with transforms inside a box that only hides
overflow. The items the clip cuts are brought into view by the script,
@@ -138,21 +147,29 @@
<!-- A row that never wraps, inside a page wrapper as wide as the window that
hides overflow: its second column starts 140px before the right edge
and the wrapper cuts the rest. However little of it shows, that is a
- layout bug a visitor sees, not a copy a carousel parks. -->
+ layout bug a visitor sees, not a copy a carousel parks, and it counts
+ toward the page's overflow. -->
<div class="escape" style="overflow: hidden">
<div style="display: flex; width: max-content">
<div style="flex: 0 0 1140px; height: 40px"></div>
- <p class="flag-shell-sliver" style="flex: 0 0 720px; margin: 0">The second column of a row that never wraps, starting just before the right edge of the window, so the page wrapper cuts off almost every word of it.</p>
+ <p class="past-shell-sliver" style="flex: 0 0 720px; margin: 0">The second column of a row that never wraps, starting just before the right edge of the window, so the page wrapper cuts off almost every word of it.</p>
</div>
</div>
<!-- A wrapper carried by a transform that holds one paragraph and no row of
- items is no track, and the paragraph it lets the clip cut reports. -->
+ items is no track, and the paragraph it lets the clip cut counts. -->
<div class="escape" style="overflow: hidden">
<div style="transform: translateX(0)">
- <p class="flag-transformed-wrapper" style="width: 1400px; margin: 0 0 0 40px">A paragraph given a fixed width wider than the window, inside a wrapper a reveal animation left transformed, so the end of every line is cut off mid-word at the right edge of the screen, and nothing a visitor does brings the words back into view however far they scroll.</p>
+ <p class="past-transformed-wrapper" style="width: 1400px; margin: 0 0 0 40px">A paragraph given a fixed width wider than the window, inside a wrapper a reveal animation left transformed, so the end of every line is cut off mid-word at the right edge of the screen, and nothing a visitor does brings the words back into view however far they scroll.</p>
</div>
</div>
+ <!-- FLAG: a paragraph that runs past the right edge and keeps 8px on
+ the left. The overflow counts toward the page-level finding; the 8px
+ is still a gutter under the 16px floor, and reports as one. -->
+ <div style="width: 2000px">
+ <p class="flag-gutter-beside-overflow" style="width: 1400px; margin: 0 0 0 8px">A paragraph set 8px from the left edge of the window that runs on past its right edge, so it is both too close to one side and wider than the page. Its lines are long enough to fill the whole 1400px measure, which carries every one of them beyond the right side of the window, where a visitor has to scroll sideways to read the end of each line and back again to start the next.</p>
+ </div>
+
<script src="/js/detect-antipatterns-browser.js"></script>
</body>
</html>
diff --git a/tests/fixtures/antipatterns/text-overflow.html b/tests/fixtures/antipatterns/text-overflow.html
index ecddda86b..847f04198 100644
--- a/tests/fixtures/antipatterns/text-overflow.html
+++ b/tests/fixtures/antipatterns/text-overflow.html
@@ -5,8 +5,18 @@
<title>Text overflow fixture (browser-only)</title>
<style>
body { font-family: system-ui, sans-serif; margin: 0; color: #1a1a1a; background: #fff; }
- .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px; align-items: start; }
+ .cols { display: grid; grid-template-columns: 320px 1fr; gap: 24px; padding: 24px; align-items: start; }
.col { padding: 16px; }
+ /* The flag column hides its overflow at 320px, so every spill in it is
+ cut off by a clipping ancestor: text-overflow reports a spill only
+ when a clip cuts it, it runs into another box, or it reaches the
+ viewport edge. */
+ .col.flag { overflow: hidden; }
+ .row { padding: 24px; }
+ .stats { display: grid; grid-template-columns: 92px 92px; column-gap: 8px; width: 192px; }
+ .stat { font-size: 36px; line-height: 40px; white-space: nowrap; }
+ .free { width: 120px; }
+ .headline { width: 300px; margin: 0; font-size: 48px; line-height: 52px; font-weight: 400; color: #111; }
.box { width: 160px; border: 1px solid #ddd; margin: 0 0 24px; padding: 8px; }
.sr-only {
position: absolute;
@@ -46,7 +56,8 @@
</head>
<body>
<div class="cols">
- <!-- FLAG column: content forced wider than its box with no scroll affordance -->
+ <!-- FLAG column: content forced wider than its box with no scroll
+ affordance, cut off by the column's clip -->
<section class="col flag">
<div class="box flag-nowrap" style="white-space: nowrap">A single long line of running text that refuses to wrap and clearly spills past its fixed-width box.</div>
<div class="box flag-longword">Supercalifragilisticexpialidocioussupercalifragilisticexpialidocious</div>
@@ -95,5 +106,41 @@
<div class="box pass-reserve">Durable streams on <span style="display: inline-block; min-width: 220px">storage</span></div>
</section>
</div>
+
+ <!-- FLAG: the spill runs into another box. Two stats in 92px cells with
+ an 8px gap (v0-optimus-delta.vercel.app at 390px): the first runs
+ past its cell into the second, and the two read as one number. -->
+ <div class="row">
+ <div class="stats">
+ <div class="stat flag-stat-collides">99.99%</div>
+ <div class="stat pass-stat-neighbor">&lt;9ms</div>
+ </div>
+ </div>
+
+ <!-- FLAG: the spill reaches the viewport edge. A status line in a 120px
+ box set 160px from the right edge of the window runs off the side of
+ it (a report panel on a phone, soc-workflows-ai-cyb-tstb.bolt.host). -->
+ <div class="row" style="padding-left: 0; padding-right: 0">
+ <div style="margin-left: calc(100vw - 160px); width: 120px">
+ <div class="flag-viewport-edge" style="white-space: nowrap">A status line that never wraps and runs off the side of the window</div>
+ </div>
+ </div>
+
+ <!-- PASS: text that runs past its own box into free space, where nothing
+ is cut or covered. A white-space: pre contact line in a 120px column
+ with empty page beside it (bt.cn's footer), and a nowrap headline
+ line with the next line of the heading set right below it
+ (v0-compute-11.vercel.app). -->
+ <div class="row">
+ <div class="free">
+ <span class="pass-free-space-pre" style="display: block; white-space: pre">Business QQ (sales): 394030111</span>
+ </div>
+ </div>
+ <div class="row">
+ <h2 class="headline">
+ <span class="pass-free-space-headline" style="display: block; white-space: nowrap">Distributed compute,</span>
+ <span style="display: block">agents</span>
+ </h2>
+ </div>
</body>
</html>
diff --git a/tests/oracle/golden/detect-fixture-json-body-text-viewport-edge-phone-html.json b/tests/oracle/golden/detect-fixture-json-body-text-viewport-edge-phone-html.json
new file mode 100644
index 000000000..afe20a428
--- /dev/null
+++ b/tests/oracle/golden/detect-fixture-json-body-text-viewport-edge-phone-html.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "[]\n",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {}
+}
diff --git a/tests/oracle/golden/detect-fixture-text-body-text-viewport-edge-phone-html.json b/tests/oracle/golden/detect-fixture-text-body-text-viewport-edge-phone-html.json
new file mode 100644
index 000000000..7ea122487
--- /dev/null
+++ b/tests/oracle/golden/detect-fixture-text-body-text-viewport-edge-phone-html.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {}
+}