Mobile guard: drop the HtmlBlock table rule; colour e2e baseline = first 2026.11.4-head commit
- Tables inside HtmlBlocks are left alone on phones: display:block (the only way to make one scroll) shrank a fitting width:100% table's rows from 349px to 77px at 390. Wide tables stay clipped as before. The <pre> rule (max-width:100%;overflow-x:auto, no display change) and the media rules stay. - Browser suite: width:100% table still spans the screen (fails on cfeeef3's rule: first row 78px); the 10-column bare table moved to htmlwide (clipped, page never scrolls sideways). - e2e-color-system: default COLOR_BASE_COMMITab7a100->69fd34b, the first commit with the 2026.11.4 published head (ColumnLayout stacking + Navbar wrap) and none of the colour feature.ab7a100predates that head, so check 5 failed on main itself. This branch's own head change (mobile guard) is folded back by exact string, asserted present once, before comparing, so the check still proves the colour feature changed nothing else. Passes on 69fd34b; fails (as it should) againstab7a100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfeeef37ce
commit
542f5efc78
8 files changed
+63
-37
No files matched your search
@@ -25,10 +25,23 @@ import { buildProject } from './e2e-color-system-fixture.mjs';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const BACKEND_DIR = process.env.WHP_BACKEND_DIR || '/workspace/whp-wt-color-system';
|
||||
// Pre-colour-feature baseline. On a branch that also carries other head changes (e.g. the release
|
||||
// branch, where mobile-parity's <=767px stacking rules land first) point this at the commit just
|
||||
// before the colour merge: COLOR_BASE_COMMIT=<sha>.
|
||||
const BASE_COMMIT = process.env.COLOR_BASE_COMMIT || 'ab7a100';
|
||||
// Pre-colour-feature baseline. 69fd34b = the first commit carrying the 2026.11.4 published head
|
||||
// (ColumnLayout stacking + Navbar wrap, fix/mobile-parity) and none of the colour feature, so "no brand
|
||||
// colours => published document unchanged" compares against the head that actually shipped before it.
|
||||
// (ab7a100, the old default, predates the 2026.11.4 head rules, so this check failed on main since then.)
|
||||
// Override with COLOR_BASE_COMMIT=<sha> on a branch with other deliberate head changes.
|
||||
const BASE_COMMIT = process.env.COLOR_BASE_COMMIT || '69fd34b';
|
||||
// Deliberate head changes made AFTER the base, folded back before the comparison so it still proves the
|
||||
// colour feature changed nothing else. Each `from` must occur exactly once (checked).
|
||||
const HEAD_FOLDS = [
|
||||
{
|
||||
why: 'mobile-guard: card-grid / long-word / HtmlBlock media rules in the <=767px block; Navbar wrap moved to <=991px',
|
||||
from: '[class^="cols_"]{flex-direction:column!important;align-items:stretch!important}[data-wsb-grid]{grid-template-columns:minmax(0,1fr)!important}body{overflow-wrap:break-word}[data-wsb-html] :is(img,video,iframe,embed,object,svg,canvas){max-width:100%}[data-wsb-html] :is(img,video){height:auto}[data-wsb-html] pre{max-width:100%;overflow-x:auto}}@media(max-width:991px){nav[class^="nav_"],nav[class^="nav_"] .navbar-links{flex-wrap:wrap}}',
|
||||
to: '[class^="cols_"]{flex-direction:column!important;align-items:stretch!important}nav[class^="nav_"],nav[class^="nav_"] .navbar-links{flex-wrap:wrap}}',
|
||||
},
|
||||
];
|
||||
const foldHead = (html) => HEAD_FOLDS.reduce((h, f) => (h.split(f.from).length === 2 ? h.replace(f.from, () => f.to) : h), html);
|
||||
const foldsApplied = (html) => HEAD_FOLDS.map((f) => html.split(f.from).length - 1);
|
||||
const SHOTS = process.env.COLOR_SHOTS || '';
|
||||
if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
|
||||
|
||||
@@ -350,7 +363,8 @@ async function run(name, launcher, exe) {
|
||||
eq('5 non-brand swatches change nothing in the published document', pplain, pa);
|
||||
if (haveBackend) eq('5 no-brand site: frontend :root == backend :root', rootDecl(pa), rootDecl(backendHtml(noDesign, 0)));
|
||||
if (baseExporter) {
|
||||
eq(`5 no-brand site: published document identical to the pre-feature baseline (${BASE_COMMIT})`, pa === baseExporter.renderPublished(noDesign, 0), true);
|
||||
eq(`5 no-brand site: each later deliberate head change found exactly once (${HEAD_FOLDS.map((f) => f.why.split(':')[0]).join(', ')})`, foldsApplied(pa), HEAD_FOLDS.map(() => 1));
|
||||
eq(`5 no-brand site: published document identical to the pre-feature baseline (${BASE_COMMIT}, later head changes folded back)`, foldHead(pa) === baseExporter.renderPublished(noDesign, 0), true);
|
||||
} else console.log(`[${name}] SKIP baseline comparison`);
|
||||
await pub.close();
|
||||
|
||||
|
||||
@@ -60,11 +60,12 @@ export function componentsState(): string {
|
||||
return JSON.stringify(nodes);
|
||||
}
|
||||
|
||||
/** Customer raw HTML the phone net makes fit: media shrink, tables and <pre> scroll on their own, long words wrap. */
|
||||
/** Customer raw HTML that fits a phone with the net: media shrink, <pre> scrolls on its own, long words wrap,
|
||||
* a full-width table keeps spanning the screen. */
|
||||
export const HTML_FITS: Record<string, string> = {
|
||||
hbIframe: '<iframe width="800" height="450" src="about:blank" title="video"></iframe>',
|
||||
hbImg: '<img src="data:image/gif;base64,R0lGODlhAQABAAAAACw=" width="1200" height="400" alt="">',
|
||||
hbTableBare: '<table id="bare-table"><tr>' + Array.from({ length: 10 }, (_, i) => `<td>Column_heading_${i}</td>`).join('') + '</tr></table>',
|
||||
hbTableFull: '<table id="full-table" style="width:100%;border-collapse:collapse" border="1"><tr><th>Plan</th><th>Price</th></tr><tr><td>Basic</td><td>$5</td></tr></table>',
|
||||
hbPre: '<pre>const reallyLongLine = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";</pre>',
|
||||
hbUrl: '<p>See https://example.com/a/really/long/path/that/never/breaks/because/it/has/no/spaces/at/all/ok</p>',
|
||||
// Deliberate horizontal scroller: must STILL scroll (the net must not flatten or clip it).
|
||||
@@ -81,6 +82,8 @@ export const HTML_WIDE: Record<string, string> = {
|
||||
hbGridFr: '<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:32px"><div style="padding:24px"><h3>Multi-Brand Portfolio</h3></div><div style="padding:24px"><h3>Hosting</h3></div><div style="padding:24px"><h3>StreamerTools</h3></div><div style="padding:24px"><h3>Consultancy</h3></div></div>',
|
||||
hbStyleFlex: '<style>.cards{display:flex;gap:16px}.card{flex:0 0 360px;padding:16px;border:1px solid #ccc}</style><div class="cards"><div class="card">A</div><div class="card">B</div><div class="card">C</div></div>',
|
||||
hbMinWidth: '<div style="min-width:900px">min-width 900px content</div>',
|
||||
// Tables are deliberately left alone by the net (scrolling one would shrink full-width tables): clipped as before.
|
||||
hbTableBare: '<table id="bare-table"><tr>' + Array.from({ length: 10 }, (_, i) => `<td>Column_heading_${i}</td>`).join('') + '</tr></table>',
|
||||
};
|
||||
|
||||
function htmlState(blocks: Record<string, string>, probes: boolean): string {
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
* Builds three representative documents with the REAL exporter (scripts/e2e-mobile-guard-entry.ts):
|
||||
* components - Navbar with 8 links, hero, ColumnLayout 2/3/4/30-70, FeaturesGrid, Testimonials,
|
||||
* NumberCounter, Gallery, PricingTable, ReviewsStrip, a 1600px image, long word + URL
|
||||
* htmlblocks - customer HtmlBlocks the phone net makes fit (iframe, img, bare wide table, pre, URL), an
|
||||
* htmlblocks - customer HtmlBlocks that fit a phone with the net (iframe, img, width:100% table, pre, URL), an
|
||||
* intentional overflow-x:auto table, and probes: sticky bar, absolutely positioned dropdown,
|
||||
* multi-root blocks as direct flex items / grid cells, collapsing margins, an inline run
|
||||
* htmlwide - customer HtmlBlocks wider than a phone BY DESIGN (fixed width, px grid, 4x1fr grid, <style>
|
||||
* flex cards, min-width): clipped as before, the publish warning is their guard
|
||||
* htmlwide - customer HtmlBlocks wider than a phone (fixed width, px grid, 4x1fr grid, <style> flex cards,
|
||||
* min-width, a 10-column bare table): clipped as before, the publish warning is their guard
|
||||
* and measures them at 360 / 390 / 768 / 1280.
|
||||
*
|
||||
* Asserted:
|
||||
@@ -24,7 +24,8 @@
|
||||
* - ColumnLayout rows stack (one column per row) at <=767px; component card grids are one column at
|
||||
* <=767px and keep more than one column at 768 (tablet).
|
||||
* - the Navbar fits the viewport and wraps its links onto more than one row at 360/390.
|
||||
* - the intentional overflow-x:auto table still scrolls; the bare wide table scrolls on its own on phones.
|
||||
* - the intentional overflow-x:auto table still scrolls; a width:100% table still spans the screen; a wide
|
||||
* table (htmlwide) is clipped and never makes the page scroll sideways.
|
||||
* - htmlblocks probes, every width: the HtmlBlock wrapper is display:contents, sticky still sticks, the
|
||||
* dropdown is visible on top, multi-root blocks stay separate flex items / grid cells.
|
||||
* - desktop (1280) is unchanged by the mobile hooks: every element box AND the full-page screenshot are
|
||||
@@ -162,9 +163,16 @@ function probes() {
|
||||
out.dropdownVisible = !!hit && (hit === last || last.contains(hit));
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
// Wide bare table: it scrolls by itself, so its last cell is reachable.
|
||||
const t = document.getElementById('bare-table');
|
||||
if (t) { t.scrollLeft = 10000; out.tableScrolls = t.scrollWidth > t.clientWidth && t.scrollLeft > 0; t.scrollLeft = 0; }
|
||||
// A width:100% table still spans its container: its first row is as wide as the table's parent content box.
|
||||
const t = document.getElementById('full-table');
|
||||
if (t) {
|
||||
let host = t.parentElement;
|
||||
while (host && getComputedStyle(host).display === 'contents') host = host.parentElement;
|
||||
const cs = getComputedStyle(host);
|
||||
const inner = host.getBoundingClientRect().width - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight);
|
||||
out.fullTableRow = Math.round(t.querySelector('tr').getBoundingClientRect().width);
|
||||
out.fullTableSpans = Math.abs(t.querySelector('tr').getBoundingClientRect().width - inner) <= 2;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -232,7 +240,7 @@ async function run(name, launcher, exe) {
|
||||
ok(pr.rootsAreFlexItems, `${tag}: a multi-root HtmlBlock in a flex row is no longer separate flex items`);
|
||||
ok(pr.stickyTop !== undefined && Math.abs(pr.stickyTop) <= 1, `${tag}: position:sticky inside an HtmlBlock stopped sticking (top=${pr.stickyTop})`);
|
||||
ok(pr.dropdownVisible, `${tag}: an absolutely positioned dropdown inside an HtmlBlock is clipped or covered`);
|
||||
if (mobile) ok(pr.tableScrolls, `${tag}: the wide bare table does not scroll on its own`);
|
||||
ok(pr.fullTableSpans, `${tag}: a width:100% table no longer spans the screen (first row ${pr.fullTableRow}px)`);
|
||||
}
|
||||
if (docName === 'components') {
|
||||
for (const c of m.cols) ok(mobile ? c.rows === c.n : c.rows === 1, `${tag}: ColumnLayout ${mobile ? 'not stacked' : 'stacked'} (${c.rows} rows / ${c.n} cols)`);
|
||||
|
||||
Reference in new issue
Block a user