From ce62d6db74acdfeaa1d5ad4b8eedc59756e8cd7c Mon Sep 17 00:00:00 2001 From: Shakker <165377636+shakkernerd@users.noreply.github.com> Date: Tue, 25 Aug 2026 15:47:28 +0100 Subject: [PATCH] test: await lazy sidebar load before teardown (#129376) * fix: drain lazy UI module loads in tests * test: await lazy sidebar before teardown --- ui/src/app/app-host-pairing-access.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/src/app/app-host-pairing-access.test.ts b/ui/src/app/app-host-pairing-access.test.ts index d54e8f722571..57246d9f64cd 100644 --- a/ui/src/app/app-host-pairing-access.test.ts +++ b/ui/src/app/app-host-pairing-access.test.ts @@ -31,6 +31,8 @@ type PairingSidebar = HTMLElement & { type PairingAuth = { role: string; scopes?: string[] }; +let renderedSidebar = false; + function createPairingShell(params: { auth: PairingAuth | null; connected?: boolean; @@ -109,6 +111,7 @@ function createPairingShell(params: { const container = document.createElement("div"); const renderSidebar = () => { + renderedSidebar = true; render(shell.render(), container); const sidebar = container.querySelector("openclaw-app-sidebar"); if (!sidebar) { @@ -146,8 +149,11 @@ function createPairingShell(params: { afterEach(async () => { vi.useRealTimers(); + if (renderedSidebar) { + await waitForFast(() => expect(customElements.get("openclaw-app-sidebar")).toBeDefined()); + renderedSidebar = false; + } document.body.replaceChildren(); - await Promise.resolve(); vi.unstubAllGlobals(); vi.restoreAllMocks(); Reflect.deleteProperty(document, "execCommand");