Skip to content

test: Make browser e2e tests deterministic and leak-free - #1952

Open
jeswr wants to merge 2 commits into
mainfrom
test/e2e-deterministic-waits
Open

test: Make browser e2e tests deterministic and leak-free#1952
jeswr wants to merge 2 commits into
mainfrom
test/e2e-deterministic-waits

Conversation

@jeswr

@jeswr jeswr commented Jul 4, 2026

Copy link
Copy Markdown
Member

🚧 DRAFT — for @jeswr to review first

Note: This change is agent-generated (Claude Fable 5) from the verified triage of the linked issues.

Closes #704
Closes #385

The two mechanisms (from the triage)

  1. Flake (Investigate missing results #704): after clicking execute, the test slept a fixed setTimeout(res, 1000) and then asserted on div[id=result]. The page's execute handler fills that div only after await eyereasoner.n3reasoner(...) completes, so on a slow runner the assertion races the reasoner and reads an empty div — exactly the Expected: "@prefix : .:Socrates a :Mortal." / Received: "" failure in the linked CI run.
  2. Hang (chore: investigate playwright timeouts #385): page.close() / browser.close() were the last statements of the test body. When any assertion threw, they never ran; the leaked browser kept the jest worker from exiting ("A worker process has failed to exit gracefully..."), which is the mechanism behind the historic 60-minute Windows CI timeouts.

Change

  • Replace both fixed sleeps with page.waitForFunction() polling div[id=result] textContent: non-empty after execute (then assert the exact expected text), empty after clear. Each wait has a generous 90s timeout, inside the existing 120s jest timeout, so a genuine failure still terminates promptly instead of hanging.
  • Move the browser/page lifecycle into try/finally so browser.close() (which also closes its pages) always runs, pass or fail.

No assertion is weakened — the same exact-text expectations remain.

Validation

Playwright cannot run on this (production-shared, browserless) box, so the CI matrix on this PR is the validation for the behavioural change. Locally validated:

  • repo eslint script: exit 0 (only the 3 pre-existing ignore-pattern warnings)
  • standalone tsc --noEmit type-check of __tests__/e2e-test.ts (the repo tsconfig only includes lib/): exit 0

🤖 Generated with Claude Code

The e2e tests slept a fixed 1000ms after clicking execute/clear and then
asserted on div[id=result]; on slow runners the reasoner takes longer
than the sleep, so the assertion reads an empty div (#704). Replace both
sleeps with page.waitForFunction() polling the result div (non-empty
after execute, then assert the exact expected text; empty after clear)
with a generous 90s timeout inside the existing 120s jest timeout.

Also move the browser lifecycle into try/finally so browser.close()
always runs: when an assertion threw, the leaked browser kept the jest
worker alive, which is the mechanism behind the historic 60-minute
Windows CI hangs (#385).

Closes #704
Closes #385

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jeswr
jeswr marked this pull request as ready for review July 4, 2026 21:29
Copilot AI review requested due to automatic review settings July 4, 2026 21:29
@jeswr
jeswr enabled auto-merge (squash) July 4, 2026 21:29

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jeswr
jeswr disabled auto-merge July 4, 2026 22:05
@jeswr
jeswr enabled auto-merge July 4, 2026 23:16
@jeswr
jeswr added this pull request to the merge queue Jul 4, 2026
@jeswr
jeswr removed this pull request from the merge queue due to a manual request Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate missing results chore: investigate playwright timeouts

2 participants