Skip to content

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

JavaScript

Make the link-gap and scaled-chip browser cases font-independent

Paul Bakausc3351cac47b4
diff --git a/crates/browser/tests/heading_rhythm.rs b/crates/browser/tests/heading_rhythm.rs
index 13ad9b8e5..6dc213783 100644
--- a/crates/browser/tests/heading_rhythm.rs
+++ b/crates/browser/tests/heading_rhythm.rs
@@ -99,8 +99,9 @@ fn fixture_flags_crowded_headings_and_passes_the_misread_shapes() {
// A grey line too long to read as a label is still content.
"\"Flag Grey Sentence Above\" has 10px above vs 48px below",
// A coloured link or a grey date that closes the block above, laid
- // out in that block's box, is the block's own last line.
- "\"Flag Link Closing Block\" has 15px above vs 40px below",
+ // out in that block's box, is the block's own last line. The link's
+ // gap is asserted below, within a pixel.
+ "\"Flag Link Closing Block\" has ",
"\"Flag Date Closing Post\" has 12px above vs 40px below",
// A heading's own icon or accent bar draws no edge above it.
"\"Flag Icon Heading\" has 12px above vs 40px below",
@@ -111,6 +112,17 @@ fn fixture_flags_crowded_headings_and_passes_the_misread_shapes() {
"expected {heading:?} to flag, got {snippets:?}"
);
}
+ // The gap above the link closing the block runs from the bottom of the
+ // link's text box, which is the face's ascent and descent: 15px in
+ // Georgia, 16px in the serif a Linux runner substitutes for it.
+ let link = snippets
+ .iter()
+ .find(|s| s.contains("\"Flag Link Closing Block\" has "))
+ .expect("the link closing the block flags");
+ assert!(
+ ["15px", "16px"].iter().any(|px| link.contains(&format!("has {px} above vs 40px below"))),
+ "{link}"
+ );
let stray: Vec<&&str> = snippets.iter().filter(|s| s.contains("\"Pass ")).collect();
assert!(stray.is_empty(), "should-pass headings flagged: {stray:?}");
assert_eq!(snippets.len(), 20, "{snippets:?}");
diff --git a/tests/fixtures/antipatterns/cramped-padding-edges.html b/tests/fixtures/antipatterns/cramped-padding-edges.html
index ac03cc0df..abb6155b2 100644
--- a/tests/fixtures/antipatterns/cramped-padding-edges.html
+++ b/tests/fixtures/antipatterns/cramped-padding-edges.html
@@ -37,7 +37,11 @@
.pass-layer-grid { background: #f5f5f5; }
.pass-layer-grid p { margin: 0; }
.scaled { transform: scale(0.3); transform-origin: 0 0; width: 600px; height: 12px; }
- .pass-scaled-chip { display: inline-block; background: #e8e8ea; padding: 0 6px; font-size: 14px; line-height: 28px; font-style: normal; }
+ /* 40px of line height leaves 3px of drawn room above and below the label
+ whatever face sets it (a CJK fallback on Windows draws a text box near
+ two ems tall), and under the 4px a full-scale edge needs, so only a
+ measure taken at the transform's scale passes it. */
+ .pass-scaled-chip { display: inline-block; background: #e8e8ea; padding: 0 6px; font-size: 14px; line-height: 40px; font-style: normal; }
</style>
</head>
<body>