diff --git a/components/settings/tabs/PluginLogSettings.test.tsx b/components/settings/tabs/PluginLogSettings.test.tsx index ccd3095f2..9cb567bfb 100644 --- a/components/settings/tabs/PluginLogSettings.test.tsx +++ b/components/settings/tabs/PluginLogSettings.test.tsx @@ -66,9 +66,15 @@ test('local logging controls default off, disclose verbose risk, and call host-o assert.match(document.querySelector('[role=alert]')!.textContent!, /synthetic preferences write failed/); await act(async () => button('Close').click()); assert.equal(document.querySelector('[role=dialog]'), null); - assert.equal(document.activeElement, configure); + // Radix restores focus in a setTimeout(0) after the dialog unmounts. + // act() can finish before that timer, so drain it before checking focus. + await new Promise((resolve) => setTimeout(resolve, 0)); + // Comparing DOM objects directly makes Node inspect the entire JSDOM graph + // on failure, which can stall the test process while formatting the diff. + assert.ok(document.activeElement === configure, `expected focus on Configure, got ${document.activeElement?.tagName}`); } finally { await act(async () => root.unmount()); + await new Promise((resolve) => setTimeout(resolve, 0)); dom.window.close(); for (const [key, descriptor] of previous) { if (descriptor) Object.defineProperty(globalThis, key, descriptor);