From a75b83a31951fad6bc266afdee4ed7d562988fb0 Mon Sep 17 00:00:00 2001 From: Aaron Perez Date: Wed, 24 Jun 2026 16:20:23 -0500 Subject: [PATCH] fix(SKY-11404): flush Radix focus-scope unmount timer in vitest teardown (#6795) --- skyvern-frontend/vitest.setup.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/skyvern-frontend/vitest.setup.ts b/skyvern-frontend/vitest.setup.ts index 4d98cfd7e..15289b23c 100644 --- a/skyvern-frontend/vitest.setup.ts +++ b/skyvern-frontend/vitest.setup.ts @@ -1,3 +1,6 @@ +import { cleanup } from "@testing-library/react"; +import { afterEach } from "vitest"; + type StorageRecord = Record; const createMemoryStorage = (): Storage => { @@ -58,3 +61,11 @@ if (typeof window !== "undefined") { value: window.CustomEvent, }); } + +// Radix FocusScope schedules a setTimeout(..., 0) on unmount that dispatches a +// CustomEvent. Flush it within the test's realm (cleanup then one macrotask) so +// it can't fire during teardown against a swapped realm and red the run. +afterEach(async () => { + cleanup(); + await new Promise((resolve) => setTimeout(resolve, 0)); +});