Skip to content

FE-2027: Load the editor's Monaco before the Petrinaut website editor tests - #10111

Merged
kube merged 1 commit into
mainfrom
claude/fe-2027-preload-editor-monaco-in-tests
Oct 20, 2026
Merged

kube merged 1 commit into
mainfrom
claude/fe-2027-preload-editor-monaco-in-tests

Conversation

@claude

@claude claude Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Requested by Bilal Mahmoud · Slack thread

🌟 Purpose

The Petrinaut website tests that mount the full editor fail now and then in Unit (@apps/petrinaut-website) on PRs that don't touch them, for example #9873 and #9944. The cause is in the shared test setup, not in the tests themselves: mounting the editor starts loading its bundled Monaco, and in a parallel run that load is still going during the first test of each file.

This PR loads Monaco once before each file's tests, and fixes the command palette test, which failed whenever Monaco had already loaded.

🔍 Changes

  • renderEditorWith registers a beforeAll that mounts the editor, waits until the editor has assigned MonacoEnvironment.getWorker (it does that once Monaco has loaded), then unmounts. Every test file that uses the helper gets this.
  • The command palette test waits for the dialog to be gone instead of calling waitForElementToBeRemoved(palette). Once Monaco has loaded, the palette closes synchronously and is detached along with its overlay, so waitForElementToBeRemoved never saw it go.
  • Locally, with three runs of the plugin tests at once on 4 cores: without this change the share and walkthrough tests failed in 3 of 3 runs, and with it they passed in 3 of 3. In a single full-suite run, the share test's wait dropped from 1218 ms to about 260 ms.

⚠️ Known issues

  • preloadMonaco() in petrinaut-jsdom.ts imports the monaco-editor package, which is a different copy from the one bundled into @hashintel/petrinaut's dist, so it doesn't warm the editor's Monaco. Its two users are unchanged here.
  • Under the same load, live-conversation.test.ts and voice-history-continuity.test.tsx still flake. They don't use renderEditorWith, and this PR doesn't change them.

Generated by Claude Code

Mounting the editor starts loading its bundled Monaco. In a parallel run
that load outlasts the one-second waits of the first test in each file
that mounts the editor, so the share and walkthrough plugin tests failed
intermittently. The shared `renderEditorWith` helper now mounts the
editor once before each file's tests and waits for the load to finish.

With Monaco loaded, the command palette closes synchronously and is
detached together with its overlay, so `waitForElementToBeRemoved`
never saw it go. Wait for the dialog to be gone instead.
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Oct 20, 2026 10:37am UTC
petrinaut Ready Ready Preview Oct 20, 2026 10:37am UTC
petrinaut-docs Ready Ready Preview Oct 20, 2026 10:37am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Oct 20, 2026 10:37am UTC

Request Review

@kube
kube marked this pull request as ready for review October 20, 2026 10:39
@kube
kube requested a review from a team as a code owner October 20, 2026 10:39
@cursor

cursor Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only changes to shared render setup and one assertion; no production runtime behavior.

Overview
Fixes intermittent failures in Petrinaut website unit tests that mount the full editor under parallel Vitest runs, where bundled Monaco was still loading during the first test in each file.

The shared renderEditorWith helper now runs a file-level beforeAll that mounts the editor once, waits up to 30s for MonacoEnvironment.getWorker (set when Monaco finishes loading), then cleanup()—so every test file that imports the helper warms the editor’s Monaco before its tests run.

The command palette close test no longer uses waitForElementToBeRemoved on the dialog node; it **waitFor**s until the palette dialog is absent from the DOM, because after Monaco is preloaded the palette can close synchronously and detach before element-removal observers fire.

Reviewed by Cursor Bugbot for commit 4e66f51. Bugbot is set up for automated code reviews on this repo. Configure here.

@kube
kube added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit bc6c8f0 Oct 20, 2026
57 checks passed
@kube
kube deleted the claude/fe-2027-preload-editor-monaco-in-tests branch October 20, 2026 10:51

This branch was successfully deployed

3 active deployments
Preview – petrinaut-docs — 4e66f513 Deployed Oct 20, 2026 by vercel[bot]
Preview – hash — 4e66f513 Deployed Oct 20, 2026 by vercel[bot]
Preview – petrinaut — 4e66f513 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants