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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
test(ui): coverage for page-moved banner + new translation paths
diegosouzapw6991b9a8eacc
diff --git a/tests/unit/ui/agent-bridge-server-card-a11y.test.tsx b/tests/unit/ui/agent-bridge-server-card-a11y.test.tsxnew file mode 100644index 0000000000..9db239e614--- /dev/null+++ b/tests/unit/ui/agent-bridge-server-card-a11y.test.tsx@@ -0,0 +1,93 @@+/**+ * a11y tests for AgentBridgeServerCard — each action button must have aria-label.+ * Uses source-text inspection (no JSDOM render needed) for the structural assertion.+ */+import { describe, it } from "node:test";+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import path from "node:path";++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const CARD_PATH = path.resolve(+ __dirname,+ "../../../src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentBridgeServerCard.tsx",+);++const src = readFileSync(CARD_PATH, "utf-8");++describe("AgentBridgeServerCard aria-labels (B2)", () => {+ it("Start button has aria-label", () => {+ // Start button: onClick start, aria-label present+ assert.ok(+ src.includes('aria-label={t("startServer")}'),+ 'Start button must have aria-label={t("startServer")}',+ );+ });++ it("Stop button has aria-label", () => {+ assert.ok(+ src.includes('aria-label={t("stopServer")}'),+ 'Stop button must have aria-label={t("stopServer")}',+ );+ });++ it("Restart button has aria-label", () => {+ assert.ok(+ src.includes('aria-label={t("restartServer")}'),+ 'Restart button must have aria-label={t("restartServer")}',+ );+ });++ it("Trust Cert button has aria-label", () => {+ assert.ok(+ src.includes('aria-label={t("trustCert")}'),+ 'Trust Cert button must have aria-label={t("trustCert")}',+ );+ });++ it("Download Cert anchor has aria-label", () => {+ assert.ok(+ src.includes('aria-label={t("downloadCert")}'),+ 'Download Cert anchor must have aria-label={t("downloadCert")}',+ );+ });++ it("Regenerate Cert button has aria-label", () => {+ assert.ok(+ src.includes('aria-label={t("regenerateCert")}'),+ 'Regenerate Cert button must have aria-label={t("regenerateCert")}',+ );+ });++ it("all 5 buttons and 1 anchor have aria-label attributes (6 total)", () => {+ // Count aria-label occurrences in action buttons section+ const matches = src.match(/aria-label=\{t\(/g) ?? [];+ assert.ok(+ matches.length >= 6,+ `Expected at least 6 aria-label attributes, found ${matches.length}`,+ );+ });+});++describe("SessionRecorderBar aria-labels (B2)", () => {+ const BAR_PATH = path.resolve(+ __dirname,+ "../../../src/app/(dashboard)/dashboard/tools/traffic-inspector/components/session/SessionRecorderBar.tsx",+ );+ const barSrc = readFileSync(BAR_PATH, "utf-8");++ it("REC (recordSession) button has aria-label", () => {+ assert.ok(+ barSrc.includes('aria-label={t("recordSession")}'),+ 'REC button must have aria-label={t("recordSession")}',+ );+ });++ it("Stop (stopSession) button has aria-label", () => {+ assert.ok(+ barSrc.includes('aria-label={t("stopSession")}'),+ 'Stop button must have aria-label={t("stopSession")}',+ );+ });+});diff --git a/tests/unit/ui/conversation-tab-separators.test.tsx b/tests/unit/ui/conversation-tab-separators.test.tsxindex 07f58b15ab..7faad9b6b1 100644--- a/tests/unit/ui/conversation-tab-separators.test.tsx+++ b/tests/unit/ui/conversation-tab-separators.test.tsx@@ -138,4 +138,14 @@ describe("ConversationTab separators rendering logic", () => {const totalTurns = request.length + response.length;assert.equal(totalTurns, 2);});++ it("conversationNotAvailable key resolves when body is null (normalizeConversation returns null)", () => {+ // When requestBody is null and responseBody is null, normalizeConversation returns null.+ // The ConversationTab renders t("conversationNotAvailable") in that case.+ const req = makeRequest({ requestBody: null, responseBody: null });+ const result = normalizeConversation(req);++ // Must return null so the component falls through to the conversationNotAvailable branch.+ assert.equal(result, null, "normalizeConversation must return null for non-LLM / null body");+ });});diff --git a/tests/unit/ui/mitm-proxy-moved-page.test.tsx b/tests/unit/ui/mitm-proxy-moved-page.test.tsxnew file mode 100644index 0000000000..072b6004f3--- /dev/null+++ b/tests/unit/ui/mitm-proxy-moved-page.test.tsx@@ -0,0 +1,121 @@+/**+ * Tests for the MITM Proxy "page moved" banner (C4).+ * Validates:+ * - Banner renders with pageMoved.title text+ * - "Go now" button triggers router.replace+ * - Auto-redirect is set up via setTimeout+ */+// @vitest-environment jsdom+import React from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++const mockReplace = vi.fn();++vi.mock("next/navigation", () => ({+ useRouter: () => ({ replace: mockReplace }),+}));++vi.mock("next-intl", () => ({+ useTranslations: (ns: string) => (key: string) => `${ns}.${key}`,+}));++const cleanupCallbacks: Array<() => void> = [];++function makeContainer(): HTMLElement {+ const container = document.createElement("div");+ document.body.appendChild(container);+ cleanupCallbacks.push(() => container.remove());+ return container;+}++describe("MitmProxyMovedPage — page-moved banner (C4)", { timeout: 30000 }, () => {+ beforeEach(() => {+ (+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }+ ).IS_REACT_ACT_ENVIRONMENT = true;+ vi.useFakeTimers();+ mockReplace.mockClear();+ });++ afterEach(() => {+ while (cleanupCallbacks.length > 0) cleanupCallbacks.pop()?.();+ document.body.innerHTML = "";+ vi.useRealTimers();+ vi.clearAllMocks();+ });++ it("renders with pageMoved.title text", async () => {+ const { default: MitmProxyMovedPage } = await import(+ "../../../src/app/(dashboard)/dashboard/system/mitm-proxy/page"+ );++ const container = makeContainer();+ await act(async () => {+ const root = createRoot(container);+ root.render(React.createElement(MitmProxyMovedPage));+ });++ expect(container.textContent).toContain("agentBridge.pageMoved.title");+ });++ it("renders pageMoved.message text", async () => {+ const { default: MitmProxyMovedPage } = await import(+ "../../../src/app/(dashboard)/dashboard/system/mitm-proxy/page"+ );++ const container = makeContainer();+ await act(async () => {+ const root = createRoot(container);+ root.render(React.createElement(MitmProxyMovedPage));+ });++ expect(container.textContent).toContain("agentBridge.pageMoved.message");+ });++ it("clicking goNow button calls router.replace with agent-bridge path", async () => {+ const { default: MitmProxyMovedPage } = await import(+ "../../../src/app/(dashboard)/dashboard/system/mitm-proxy/page"+ );++ const container = makeContainer();+ await act(async () => {+ const root = createRoot(container);+ root.render(React.createElement(MitmProxyMovedPage));+ });++ const goNowBtn = Array.from(container.querySelectorAll("button")).find((b) =>+ b.textContent?.includes("agentBridge.pageMoved.goNow")+ );+ expect(goNowBtn).not.toBeNull();++ await act(async () => {+ goNowBtn?.dispatchEvent(new MouseEvent("click", { bubbles: true }));+ });++ expect(mockReplace).toHaveBeenCalledWith("/dashboard/tools/agent-bridge");+ });++ it("auto-redirect fires after 2500ms via setTimeout", async () => {+ const { default: MitmProxyMovedPage } = await import(+ "../../../src/app/(dashboard)/dashboard/system/mitm-proxy/page"+ );++ const container = makeContainer();+ await act(async () => {+ const root = createRoot(container);+ root.render(React.createElement(MitmProxyMovedPage));+ });++ // Not yet redirected+ expect(mockReplace).not.toHaveBeenCalled();++ // Advance timers past the 2500ms threshold+ await act(async () => {+ vi.advanceTimersByTime(2600);+ });++ expect(mockReplace).toHaveBeenCalledWith("/dashboard/tools/agent-bridge");+ });+});