Skip to content

test(e2e): test-analytics-fluid-charts.js is flaky (measures columns before styles apply) #148

Description

@dborup

Summary

test-analytics-fluid-charts.js (the "Kpa-clawbot#1058 Analytics fluid charts E2E" step in the Playwright job, .github/workflows/deploy.yml around line 581) fails intermittently on PRs that don't touch analytics. A single rerun has gone green each time.

Observed failures

PR Run / job (attempt 1) Failing step
#135 (live.js only) run 36543893158, job 109332087103 viewport 2560 / wrapper 2520px → side-by-side (≥2 cols), no overflow: expected ≥2 columns at wrapper 2520px; got 1
#139 (map.js/CSS for the map side pane only) run 36557644736, job 109377157851 AC3: layout reflows on resize (1440 side-by-side → 768 stacked): precondition failed: expected ≥2 cols at 1300px; got 1

Different steps fail, always the same way: a width that should give ≥2 columns measures 1 column. All other steps in the same run pass. Note: the batch agent reported these as test-charts-fluid-1058-e2e.js, which is a different test (it passed 23/23 in both runs); its 20/20 local reruns therefore did not exercise the flaky file.

Likely cause (hypothesis, not yet reproduced)

The harness writes a temp HTML file that pulls in style.css with <link rel="stylesheet"> and navigates with page.goto(..., { waitUntil: 'domcontentloaded' }) (around line 82). colCount() then measures card positions immediately. domcontentloaded does not wait for stylesheets, so on a slow CI runner the measurement can run before the grid/container-query CSS applies; unstyled cards stack in one column, which is exactly the observed "got 1".

Proposed fix

  • Wait for styles before measuring: waitUntil: 'load', or wait until getComputedStyle(grid).containerType is inline-size (the opt-in the first step already asserts) and the grid has its column template, before calling colCount().
  • Apply the same wait after setViewportSize in the resize step (AC3).
  • No change to the CSS under test.

Acceptance criteria

  • Reproduce first: e.g. delay the stylesheet (route interception or a throttled file:// → local server) so the unfixed test fails deterministically, and show it passes with the fix.
  • The test runs ≥50 times in a row without failure locally, and CI stays green.
  • The assertions themselves (column counts, overflow, reflow) are unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions