Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(frontend): align Event with jsdom realm

Steven Enamakel11f3302de4fe
diff --git a/app/src/test/setup.ts b/app/src/test/setup.ts
index 0498b4dfeb..33d07e4f3e 100644
--- a/app/src/test/setup.ts
+++ b/app/src/test/setup.ts
@@ -96,6 +96,15 @@ function ensureStorage(name: 'localStorage' | 'sessionStorage') {
ensureStorage('localStorage');
ensureStorage('sessionStorage');
+// Node 24 provides an `Event` constructor on the process global. Radix's
+// deferred focus restoration uses that constructor, but jsdom DOM nodes only
+// accept events created by their own window realm. Keep the global constructor
+// aligned with jsdom so delayed focus-scope cleanup cannot throw after a test
+// has otherwise passed.
+if (typeof window !== 'undefined' && globalThis.Event !== window.Event) {
+ globalThis.Event = window.Event;
+}
+
// Polyfill window.matchMedia — used by Rive (@rive-app/react-webgl2) and
// some media-query hooks; not implemented in jsdom.
if (typeof window.matchMedia === 'undefined') {