Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

test(ui): agent-bridge UI unit tests (F7)

diegosouzapwf6f5d8da7dd9
diff --git a/tests/unit/ui/agent-bridge-page.test.tsx b/tests/unit/ui/agent-bridge-page.test.tsx
new file mode 100644
index 0000000000..c1fcf46f57
--- /dev/null
+++ b/tests/unit/ui/agent-bridge-page.test.tsx
@@ -0,0 +1,200 @@
+// @vitest-environment jsdom
+/**
+ * UI unit tests for AgentBridge page — smoke render + empty state.
+ */
+import React from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+// ── Mocks ────────────────────────────────────────────────────────────────────
+
+vi.mock("next-intl", () => ({
+ useTranslations: () => (key: string) => key,
+}));
+
+vi.mock("next/link", () => ({
+ default: ({ children, href }: { children: React.ReactNode; href: string }) =>
+ React.createElement("a", { href }, children),
+}));
+
+vi.mock("next/navigation", () => ({
+ redirect: vi.fn(),
+}));
+
+// Mock fetch for hooks
+globalThis.fetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: () => Promise.resolve({ data: [] }),
+} as unknown as Response);
+
+// ── Helpers ───────────────────────────────────────────────────────────────────
+
+const cleanupCallbacks: Array<() => void> = [];
+
+function makeContainer(): HTMLElement {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ cleanupCallbacks.push(() => container.remove());
+ return container;
+}
+
+// ── Tests ────────────────────────────────────────────────────────────────────
+
+describe("EmptyStateNoProviders", () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ it("renders empty state component with link to providers", async () => {
+ const { EmptyStateNoProviders } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/EmptyStateNoProviders"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(React.createElement(EmptyStateNoProviders));
+ });
+
+ expect(document.body.innerHTML).toContain("emptyNoProvidersTitle");
+ expect(document.body.innerHTML).toContain("/dashboard/providers");
+ });
+});
+
+describe("RiskNoticeBanner", () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ try { localStorage.clear(); } catch { /* ignore */ }
+ });
+
+ it("renders risk notice banner when not dismissed", async () => {
+ // Ensure not dismissed
+ try { localStorage.removeItem("omniroute-agentbridge-risk-dismissed"); } catch { /* ignore */ }
+
+ const { RiskNoticeBanner } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/RiskNoticeBanner"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(React.createElement(RiskNoticeBanner));
+ });
+
+ // Banner is rendered (useEffect fires synchronously in jsdom with act)
+ // It shows "riskBannerTitle" i18n key
+ expect(document.body.innerHTML).toContain("riskBannerTitle");
+ });
+
+ it("does not render risk banner when already dismissed", async () => {
+ try {
+ localStorage.setItem("omniroute-agentbridge-risk-dismissed", "true");
+ } catch { /* ignore */ }
+
+ const { RiskNoticeBanner } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/RiskNoticeBanner"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(React.createElement(RiskNoticeBanner));
+ });
+
+ expect(document.body.innerHTML).not.toContain("riskBannerTitle");
+ });
+
+ it("dismisses banner on close click", async () => {
+ try { localStorage.removeItem("omniroute-agentbridge-risk-dismissed"); } catch { /* ignore */ }
+
+ const { RiskNoticeBanner } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/RiskNoticeBanner"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(React.createElement(RiskNoticeBanner));
+ });
+
+ // Click dismiss
+ const closeBtn = container.querySelector('button[aria-label]');
+ await act(async () => {
+ closeBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ // Banner gone
+ expect(document.body.innerHTML).not.toContain("riskBannerTitle");
+ });
+});
+
+describe("BypassListEditor", () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ it("renders default bypass patterns", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: [],
+ onSave: vi.fn(),
+ })
+ );
+ });
+
+ expect(document.body.innerHTML).toContain("*.bank.*");
+ expect(document.body.innerHTML).toContain("*.okta.com");
+ });
+
+ it("renders initial user patterns in textarea", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: ["*.internal.corp"],
+ onSave: vi.fn(),
+ })
+ );
+ });
+
+ const textarea = container.querySelector("textarea");
+ expect(textarea?.value).toContain("*.internal.corp");
+ });
+});
diff --git a/tests/unit/ui/agent-card.test.tsx b/tests/unit/ui/agent-card.test.tsx
new file mode 100644
index 0000000000..9ea5669eb6
--- /dev/null
+++ b/tests/unit/ui/agent-card.test.tsx
@@ -0,0 +1,207 @@
+// @vitest-environment jsdom
+/**
+ * UI unit tests for AgentCard — DNS toggle + wizard open.
+ *
+ * Note: AgentCard/SetupWizard import @/mitm/types (zod types only, no DB).
+ * We set testTimeout=30000 to handle the initial transform overhead.
+ */
+import React from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("next-intl", () => ({
+ useTranslations: () => (key: string) => key,
+}));
+
+vi.mock("next/link", () => ({
+ default: ({ children, href }: { children: React.ReactNode; href: string }) =>
+ React.createElement("a", { href }, children),
+}));
+
+globalThis.fetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: () => Promise.resolve({ data: [] }),
+} as unknown as Response);
+
+const cleanupCallbacks: Array<() => void> = [];
+
+function makeContainer(): HTMLElement {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ cleanupCallbacks.push(() => container.remove());
+ return container;
+}
+
+// Minimal mock target (matches MitmTarget shape but no heavy imports)
+const mockTarget = {
+ id: "copilot" as const,
+ name: "GitHub Copilot",
+ icon: "code",
+ color: "#10B981",
+ hosts: ["api.githubcopilot.com"],
+ port: 443,
+ endpointPatterns: ["/chat/completions"],
+ defaultModels: [{ id: "gpt-4o", name: "GPT-4o", alias: "gpt-4o" }],
+ setupTutorial: {
+ steps: ["Step 1", "Step 2"],
+ detection: { command: "which copilot", platform: "all" as const },
+ },
+ handler: () => Promise.resolve({ default: class {} as never }),
+ riskNoticeKey: "providers.riskNotice.oauth",
+ viability: "supported" as const,
+};
+
+describe("AgentCard", { timeout: 30000 }, () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ it("renders agent name and hosts", async () => {
+ const { AgentCard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentCard"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(AgentCard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: false,
+ mappings: [],
+ onDnsToggle: vi.fn(),
+ onMappingsSave: vi.fn(),
+ })
+ );
+ });
+
+ expect(document.body.innerHTML).toContain("GitHub Copilot");
+ expect(document.body.innerHTML).toContain("api.githubcopilot.com");
+ }, 30000);
+
+ it("expands on click and shows DNS toggle", async () => {
+ const { AgentCard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentCard"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(AgentCard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: true,
+ mappings: [],
+ onDnsToggle: vi.fn(),
+ onMappingsSave: vi.fn(),
+ })
+ );
+ });
+
+ const header = container.querySelector("button[aria-expanded]");
+ expect(header).not.toBeNull();
+
+ await act(async () => {
+ header?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(document.body.innerHTML).toContain("startDns");
+ }, 30000);
+
+ it("calls onDnsToggle when DNS button clicked", async () => {
+ const { AgentCard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentCard"
+ );
+
+ const onDnsToggle = vi.fn().mockResolvedValue(undefined);
+ const container = makeContainer();
+
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(AgentCard, {
+ target: mockTarget,
+ agentState: {
+ agent_id: "copilot",
+ dns_enabled: false,
+ cert_trusted: false,
+ setup_completed: false,
+ last_started_at: null,
+ last_error: null,
+ },
+ serverRunning: true,
+ mappings: [],
+ onDnsToggle,
+ onMappingsSave: vi.fn(),
+ })
+ );
+ });
+
+ // Expand card
+ const header = container.querySelector("button[aria-expanded]");
+ await act(async () => {
+ header?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ // Find and click DNS button
+ const dnsButton = Array.from(container.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("startDns")
+ );
+ expect(dnsButton).not.toBeNull();
+
+ await act(async () => {
+ dnsButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(onDnsToggle).toHaveBeenCalledWith("copilot", true);
+ }, 30000);
+
+ it("opens wizard when setup wizard button clicked", async () => {
+ const { AgentCard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentCard"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(AgentCard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: true,
+ mappings: [],
+ onDnsToggle: vi.fn(),
+ onMappingsSave: vi.fn(),
+ })
+ );
+ });
+
+ // Expand card first
+ const header = container.querySelector("button[aria-expanded]");
+ await act(async () => {
+ header?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ // Find setup wizard button
+ const wizardBtn = Array.from(document.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("setupWizard")
+ );
+
+ await act(async () => {
+ wizardBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(document.body.querySelector('[role="dialog"]')).not.toBeNull();
+ }, 30000);
+});
diff --git a/tests/unit/ui/bypass-list-editor.test.tsx b/tests/unit/ui/bypass-list-editor.test.tsx
new file mode 100644
index 0000000000..108cd51ad5
--- /dev/null
+++ b/tests/unit/ui/bypass-list-editor.test.tsx
@@ -0,0 +1,128 @@
+// @vitest-environment jsdom
+/**
+ * UI unit tests for BypassListEditor — add/remove patterns.
+ */
+import React from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("next-intl", () => ({
+ useTranslations: () => (key: string) => key,
+}));
+
+const cleanupCallbacks: Array<() => void> = [];
+
+function makeContainer(): HTMLElement {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ cleanupCallbacks.push(() => container.remove());
+ return container;
+}
+
+describe("BypassListEditor", { timeout: 30000 }, () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ it("renders default bypass patterns as read-only chips", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: [],
+ onSave: vi.fn(),
+ })
+ );
+ });
+
+ expect(document.body.innerHTML).toContain("*.bank.*");
+ expect(document.body.innerHTML).toContain("*.okta.com");
+ }, 30000);
+
+ it("renders initial user patterns in textarea", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: ["*.internal.corp", "sso.example.com"],
+ onSave: vi.fn(),
+ })
+ );
+ });
+
+ const textarea = container.querySelector("textarea");
+ expect(textarea?.value).toContain("*.internal.corp");
+ expect(textarea?.value).toContain("sso.example.com");
+ }, 30000);
+
+ it("calls onSave when Save button clicked", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const onSave = vi.fn().mockResolvedValue(undefined);
+ const container = makeContainer();
+
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: ["existing.com"],
+ onSave,
+ })
+ );
+ });
+
+ const saveBtn = Array.from(container.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("saveBypassList")
+ );
+ expect(saveBtn).not.toBeNull();
+
+ await act(async () => {
+ saveBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(onSave).toHaveBeenCalled();
+ }, 30000);
+
+ it("renders save button", async () => {
+ const { BypassListEditor } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/BypassListEditor"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(BypassListEditor, {
+ patterns: [],
+ onSave: vi.fn(),
+ })
+ );
+ });
+
+ const saveBtn = Array.from(container.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("saveBypassList")
+ );
+ expect(saveBtn).not.toBeNull();
+ }, 30000);
+});
diff --git a/tests/unit/ui/setup-wizard.test.tsx b/tests/unit/ui/setup-wizard.test.tsx
new file mode 100644
index 0000000000..09d0c183cb
--- /dev/null
+++ b/tests/unit/ui/setup-wizard.test.tsx
@@ -0,0 +1,187 @@
+// @vitest-environment jsdom
+/**
+ * UI unit tests for SetupWizard — 3-step flow.
+ * Timeout raised to 30000ms to handle initial module transform overhead.
+ */
+import React from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("next-intl", () => ({
+ useTranslations: () => (key: string) => key,
+}));
+
+const cleanupCallbacks: Array<() => void> = [];
+
+function makeContainer(): HTMLElement {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ cleanupCallbacks.push(() => container.remove());
+ return container;
+}
+
+const mockTarget = {
+ id: "kiro" as const,
+ name: "Kiro",
+ icon: "smart_toy",
+ color: "#FF9900",
+ hosts: ["prod.kiro.aws"],
+ port: 443,
+ endpointPatterns: ["/v1/chat/completions"],
+ defaultModels: [],
+ setupTutorial: {
+ steps: ["Install Kiro", "Enable trust cert", "Activate DNS"],
+ detection: { command: "which kiro", platform: "all" as const },
+ },
+ handler: () => Promise.resolve({ default: class {} as never }),
+ riskNoticeKey: "providers.riskNotice.oauth",
+};
+
+describe("SetupWizard", { timeout: 30000 }, () => {
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ it("renders step 1 (verify) on open", async () => {
+ const { SetupWizard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(SetupWizard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: false,
+ onClose: vi.fn(),
+ onDnsToggle: vi.fn(),
+ })
+ );
+ });
+
+ expect(document.body.querySelector('[role="dialog"]')).not.toBeNull();
+ expect(document.body.innerHTML).toContain("wizardStep1Label");
+ expect(document.body.innerHTML).toContain("wizardStep1Desc");
+ }, 30000);
+
+ it("navigates to step 2 when Next clicked", async () => {
+ const { SetupWizard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
+ );
+
+ const container = makeContainer();
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(SetupWizard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: true,
+ onClose: vi.fn(),
+ onDnsToggle: vi.fn(),
+ })
+ );
+ });
+
+ const nextBtn = Array.from(document.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("next")
+ );
+ expect(nextBtn).not.toBeNull();
+
+ await act(async () => {
+ nextBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(document.body.innerHTML).toContain("wizardStep2Desc");
+ }, 30000);
+
+ it("calls onDnsToggle when enabling DNS in step 2", async () => {
+ const { SetupWizard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
+ );
+
+ const onDnsToggle = vi.fn().mockResolvedValue(undefined);
+ const container = makeContainer();
+
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(SetupWizard, {
+ target: mockTarget,
+ agentState: {
+ agent_id: "kiro",
+ dns_enabled: false,
+ cert_trusted: false,
+ setup_completed: false,
+ last_started_at: null,
+ last_error: null,
+ },
+ serverRunning: true,
+ onClose: vi.fn(),
+ onDnsToggle,
+ })
+ );
+ });
+
+ // Navigate to step 2
+ const nextBtn = Array.from(document.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("next")
+ );
+ await act(async () => {
+ nextBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ const enableDnsBtn = Array.from(document.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("wizardEnableDns")
+ );
+ expect(enableDnsBtn).not.toBeNull();
+
+ await act(async () => {
+ enableDnsBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(onDnsToggle).toHaveBeenCalledWith("kiro", true);
+ }, 30000);
+
+ it("calls onClose when Cancel clicked on step 1", async () => {
+ const { SetupWizard } = await import(
+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/SetupWizard"
+ );
+
+ const onClose = vi.fn();
+ const container = makeContainer();
+
+ await act(async () => {
+ const root = createRoot(container);
+ root.render(
+ React.createElement(SetupWizard, {
+ target: mockTarget,
+ agentState: undefined,
+ serverRunning: false,
+ onClose,
+ onDnsToggle: vi.fn(),
+ })
+ );
+ });
+
+ const cancelBtn = Array.from(document.querySelectorAll("button")).find((b) =>
+ b.textContent?.includes("cancel")
+ );
+ await act(async () => {
+ cancelBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(onClose).toHaveBeenCalled();
+ }, 30000);
+});