test(e2e): measure fluid charts only once style.css applies (#148) - #157
Merged
Merged
Conversation
…et (#148) The harness navigates with waitUntil 'domcontentloaded', which does not wait for style.css. Route style.css through the context so it can be held back, and add a step that holds it back for a second before measuring the 1300px case. Unstyled cards stack in one column, so the step fails with "got 1", the same message as the CI flakes. It fails 10/10 locally until the measurement waits for the stylesheet. FLUID_CHARTS_CSS_DELAY_MS holds style.css back on every load, which reproduces the failing steps seen in CI (2520px side-by-side, AC3 precondition). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Navigate with waitUntil 'load' and wait until the harness's stylesheet link has its sheet, then two frames, before measuring. The AC3 resize step uses the same wait after setViewportSize. The wait is on the stylesheet itself, not on container-type or the grid template, so a regression in the CSS under test still fails on its own assertion. Assertions (column counts, overflow, reflow) are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #148
Cause
test-analytics-fluid-charts.js(the "Kpa-clawbot#1058 Analytics fluid charts E2E" step in the Playwright job) writes afile://harness that linkspublic/style.csswith<link rel="stylesheet">, navigates withwaitUntil: 'domcontentloaded'and measures right away.DOMContentLoadeddoes not wait for stylesheets. Whenstyle.csshas not been applied yet, the.analytics-chartscards are plain blocks and stack in one column, so every "≥2 columns" check readsgot 1.The three 1-column checks (768/760, 1440/600 and the AC3 shrink) also pass on an unstyled page, so before this change they could pass without the CSS under test having been applied.
Failures in CI (attempt 1; a rerun went green each time)
viewport 2560 / wrapper 2520px → side-by-side (≥2 cols), no overflow: expected ≥2 columns at wrapper 2520px; got 1AC3: layout reflows on resize (1440 side-by-side → 768 stacked): precondition failed: expected ≥2 cols at 1300px; got 13ff60504)AC3: layout reflows on resize (1440 side-by-side → 768 stacked): precondition failed: expected ≥2 cols at 1300px; got 1Reproduction (commit
5fd36858)style.cssthrough the browser context, so it can be held back. Playwright route interception works forfile://URLs.style.cssheld back for 1 s. On the unfixed measurement it fails withexpected ≥2 columns at wrapper 1300px; got 1, 10 times out of 10 locally.FLUID_CHARTS_CSS_DELAY_MS=<ms>holdsstyle.cssback on every load. WithFLUID_CHARTS_CSS_DELAY_MS=1500the unfixed test fails exactly the steps seen in CI, with the same messages:Fix (commit
26b934e9)load()navigates withwaitUntil: 'load'. It then callswaitForStyles(), which waits until the harness's stylesheet<link>has itssheet, then for two animation frames.waitForStyles()aftersetViewportSize, in place of the bare two-frame wait.container-typeor the grid template, which the test asserts. A regression in the CSS under test still fails on its own assertion instead of as a timeout.test-analytics-fluid-charts.jschanges; no CSS and no workflow change.FLUID_CHARTS_CSS_DELAY_MS=1500: thesheetwait alone, withdomcontentloadedkept, passes 9/9. Without the wait, the six steps above fail again.Runs (local, macOS, Playwright 1.58.2, Chromium 1208)
FLUID_CHARTS_CSS_DELAY_MS=1500, 20 runs in a row: 20 passed, 0 failed.Similar tests
test-charts-fluid-1058-e2e.js(the other [#1050] Task 5: Analytics chart containers — fluid + auto-stacking Kpa-clawbot/CoreScope#1058 analytics layout test) also navigates withdomcontentloaded, but against the SPA. It measures only after the analytics JS has rendered.analytics-rowwith data, and the app's parser-inserted scripts do not run until the stylesheets before them have loaded. Against a local server on the migrated fixture it passed 23/23. It also passed 23/23 withstyle.cssheld back 1.5 s on all 9 loads (via a local preload that was not committed). It does not have this bug and is not changed.test-analytics-fluid-charts.jsis the only test that measures on afile://harness linkingstyle.css. The other tests that referencestyle.cssand usedomcontentloadedrun against the SPA, like the test above.Not verified
🤖 Generated with Claude Code