Skip to content

test: fix flaky WebKit dialog tests - #607

Open
uniqueg wants to merge 3 commits into
devfrom
test/606-webkit-dialog-flaky
Open

uniqueg wants to merge 3 commits into
devfrom
test/606-webkit-dialog-flaky

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the flaky WebKit dialog tests of @elixir-cloud/design (Node 22 and 24) by changing only the dialog tests. No assertion changed.

Cause. Playwright's WebKit build sometimes blocks the page's main thread for seconds (5–20 s seen locally) when a modal dialog leaves the top layer, either through dialog.close() or when an open dialog is removed. Instrumented runs showed that the time is spent inside WebKit, before any of the component's callbacks run. The global mocha timeout is 3000 ms with retries: 1 (web-test.runner-config.mjs), which leads to two failure modes:

  • 54 x "Timeout of 3000ms exceeded" (no test name). The stall hits the root afterEach of @open-wc/testing, which runs fixtureCleanup() and so removes the open dialogs. Mocha fails a synchronous hook that runs longer than its timeout. Hooks aren't retried, and a failed root hook aborts every remaining test of the file.
  • "closes only the innermost of nested dialogs" (outer closed as well). The stall hits the test body. The test times out and its retry starts while the blocked attempt's Escape press is still pending, so the retry gets two Escape presses.

Fix. In dialog.test.ts, the dialog suite now has a 10 s timeout. Its own afterEach runs fixtureCleanup() with a 25 s timeout and runs before the root hook, which then has nothing left to remove. The comment says that this makes both failure modes rare, not impossible.

Verification

WebKit 26.0 (Playwright 1.56.1 build 2215, with the Ubuntu 24.04 libraries extracted locally), with the full design suite in all three browsers, pinned to 2 CPUs (taskset -c 0,1) to imitate a busy runner. Command: npx web-test-runner --group default --port 8000 --config ../../web-test.runner-config.mjs.

  • Before: the 45-test mass failure (the local equivalent of the 54) in about 1 in 3 to 1 in 7 runs, for example 2 of 15 plain runs, and in almost every instrumented loop.
  • After: 90 of 90 loaded runs green (60 with the first version of the fix, 30 with the final one).
  • eslint --max-warnings 0 and prettier --check on the file pass, and so does the pre-commit npm run lint.
  • CI: run 45038365595 green on the first attempt and on two reruns (attempts 2 and 3), Test (Node 22) and Test (Node 24) included.

Local-only noise (not CI): the Ace code-editor tests in global.test.ts load their worker from cdn.jsdelivr.net, which the local sandbox blocks, so they failed now and then. That is unrelated to this change.

Decisions taken

  • Lane: full review (two rounds), although only test code changes.
  • Changes the test file only. The global timeout and the WebKit concurrency stay as they are: concurrency: 1 for WebKit was tried and didn't help (1 mass failure in 30 runs).

Declined review findings

  • Raise testsFinishTimeout (120 s per file), because several long stalls in one file could add up past it. Declined: one stall that fails both attempts already takes up to 70 s. Two of them in one run would be needed to pass the limit, which wasn't seen in 90 runs, and raising the limit would change all packages. Revisit if "Browser tests did not finish" shows up.
  • Sourcery: raise the test timeout above 20 s. Declined (answered in the thread): the 20 s stalls only came with extreme local load, and 25 s or more per test would push the worst case toward the 120 s limit per file.
  • Share the pattern for other top-layer suites. Declined for now: no other suite uses modal dialogs.

Open questions

None.

Closes #606

🤖 Generated with Claude Code

Summary by Sourcery

Stabilize WebKit dialog tests under intermittent browser main-thread stalls without changing their assertions.

Bug Fixes:

  • Reduce flaky WebKit dialog test failures by giving the dialog suite and its fixture cleanup sufficient time to complete during browser stalls.

Enhancements:

  • Ensure dialog fixtures are cleaned up by the suite before the global cleanup hook runs.

uniqueg and others added 2 commits November 22, 2026 15:56
Playwright's WebKit build sometimes blocks the page for seconds when a
modal dialog leaves the top layer, on busy runners. With the global
3000 ms timeout, a blocked root cleanup hook aborted all remaining
dialog tests (54 timeouts), and a blocked test's retry could get the
leftover Escape press of the blocked attempt.

The dialog suite now has a 15 s timeout and cleans up its fixtures in
its own hook, so the cleanup runs within that timeout.

Closes #606

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests get 10 s (two attempts stay well within the file's 120 s), the
suite's fixture cleanup 25 s, which covers the longest WebKit stall
seen locally (about 20 s). The comment no longer suggests that the
leftover key presses of a blocked attempt are impossible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uniqueg uniqueg added priority: medium Medium priority type: bug Something isn't working workload: hours Likely takes hours to resolve labels Nov 22, 2026
@uniqueg uniqueg self-assigned this Nov 22, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Tests

Give the dialog test suite and fixture cleanup longer, separate timeouts so WebKit stalls are less likely to abort the suite or interfere with retries.

  • packages/ecc-utils-design/src/components/dialog/tests/dialog.test.ts L4, L132-148

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.53%. Comparing base (b35b87a) to head (6f8c69b).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #607      +/-   ##
==========================================
+ Coverage   77.46%   77.53%   +0.07%     
==========================================
  Files          76       76              
  Lines       19477    19477              
  Branches     1268     1269       +1     
==========================================
+ Hits        15087    15102      +15     
+ Misses       4368     4355      -13     
+ Partials       22       20       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@uniqueg
uniqueg marked this pull request as ready for review November 22, 2026 15:31
@uniqueg
uniqueg requested a review from anuragxxd as a code owner November 22, 2026 15:31
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 7285baf

#606 test: fix flaky WebKit tests of the design dialog · 2 of 2 met

# Requirement Status Notes
1 Dialog tests pass reliably in WebKit. ✅ Met The PR reports 90 successful WebKit runs after the change and green CI runs, including reruns.
2 Do not weaken the dialog tests. ✅ Met The diff changes only suite and cleanup timeouts and adds fixture cleanup; no assertions are changed.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-utils-design/src/components/dialog/tests/dialog.test.ts" line_range="140" />
<code_context>
+  // blocked attempt; a blocked hook isn't retried and aborts all remaining
+  // tests. The longer timeouts make both rare, not impossible. (`this.timeout`
+  // needs a `function`, not an arrow function.)
+  this.timeout(10000);
+
+  // Removes the fixtures with a longer timeout than the tests (the cleanup of
</code_context>
<issue_to_address>
**Nested dialog closes unexpectedly**

When a test-body Escape-triggered close stalls for more than 10 seconds, `this.timeout(10000)` expires while `sendKeys` or `updateComplete` is still pending, so Mocha retries before the first Escape finishes; the late and retried presses can close the outer dialog too, and the nested-dialog test fails intermittently.

Raise the test timeout above the documented 20-second stall window while keeping the cleanup timeout longer.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: packages/ecc-utils-design/src/components/dialog/tests/dialog.test.ts:140


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

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

Labels

priority: medium Medium priority type: bug Something isn't working workload: hours Likely takes hours to resolve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: fix flaky WebKit tests of the design dialog

1 participant