Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

test(settings): retire the tests of the old tabbed API Keys page

rubenluetke10-beep70b5506ed9ed
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.agent-accounts.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.agent-accounts.test.tsx
deleted file mode 100644
index 9c138d0b5a..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.agent-accounts.test.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * The subscription switcher REACHES the Settings page.
- *
- * Deliberately separate from AgentAccountsPanel.test.tsx, which renders the
- * panel on its own. A component that works in isolation and is wired nowhere is
- * the most common way a finished feature stays invisible — and it looks exactly
- * like a working feature from the test suite's side. This renders the real
- * API-Keys view and asserts the panel is in it, with the account rows the
- * backend hands over.
- *
- * Note the tab click: the switcher lives under the Agents category, not on the
- * page the view opens on. That is worth pinning too — "it is in the build" and
- * "the user can reach it" are different claims.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
-
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: false,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-const ACCOUNTS = {
- platforms: [
- {
- platform: "claude",
- active_account: "claude:seat2",
- accounts: [
- {
- id: "claude:default",
- platform: "claude",
- label: "Default Claude Code login",
- config_dir: "/home/u/.claude",
- builtin: true,
- connected: true,
- mode: "subscription",
- message: "Signed in via Claude Max ([email protected]).",
- email: "[email protected]",
- tier: "max",
- },
- {
- id: "claude:seat2",
- platform: "claude",
- label: "Max seat 2",
- config_dir: "/home/u/.jarvis/agent-accounts/claude/seat2",
- builtin: false,
- connected: true,
- mode: "subscription",
- message: "Signed in via Claude Max ([email protected]).",
- email: "[email protected]",
- tier: "max",
- },
- ],
- },
- {
- platform: "codex",
- active_account: "codex:default",
- accounts: [
- {
- id: "codex:default",
- platform: "codex",
- label: "Default Codex login",
- config_dir: "/home/u/.codex",
- builtin: true,
- connected: false,
- mode: "unknown",
- message: "Not signed in — use Sign in to connect this Codex plan.",
- email: null,
- tier: null,
- },
- ],
- },
- ],
-};
-
-const SECTION_HEALTH = {
- sections: {
- brain: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- "computer-use": { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- tts: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- stt: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- realtime: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- subagents: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- advanced: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- },
- checked_at: 0,
- cached: false,
-};
-
-function installFetchMock() {
- const routes: Record<string, unknown> = {
- "/api/agent-accounts": ACCOUNTS,
- "/api/providers/section-health": SECTION_HEALTH,
- "/api/providers": { providers: [] },
- "/api/jarvis-agent/status": { mapping: [], brain_primary: "" },
- "/api/codex/status": { installed: true, connected: true, mode: "chatgpt" },
- "/api/claude/status": { installed: true, connected: true, mode: "subscription" },
- "/api/antigravity/status": { installed: false, connected: false, mode: "unknown" },
- };
- const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
- const url = String(input);
- const prefix = Object.keys(routes)
- .sort((a, b) => b.length - a.length)
- .find((p) => url.startsWith(p));
- const body = prefix ? routes[prefix] : {};
- return {
- ok: true,
- status: 200,
- statusText: "OK",
- json: async () => body,
- text: async () => JSON.stringify(body),
- } as Response;
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
-}
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-/** Open the category the switcher lives in — it is not the default tab. */
-async function openAgentsTab() {
- const tab = await waitFor(() => screen.getByRole("tab", { name: /Agents/i }));
- fireEvent.click(tab);
-}
-
-describe("ApiKeysView — the subscription switcher is wired in", () => {
- it("renders the switcher inside the settings page", async () => {
- installFetchMock();
- renderView();
- await openAgentsTab();
- await waitFor(() => {
- expect(screen.getByText("Your subscriptions")).toBeTruthy();
- });
- });
-
- it("shows both CLIs' accounts, with the active one marked per CLI", async () => {
- installFetchMock();
- renderView();
- await openAgentsTab();
- await waitFor(() => expect(screen.getByText("Max seat 2")).toBeTruthy());
-
- expect(screen.getByText("Default Claude Code login")).toBeTruthy();
- expect(screen.getByText("Default Codex login")).toBeTruthy();
- // One "in use" per platform: the second Claude seat, and Codex's default.
- expect(screen.getAllByText("in use").length).toBe(2);
- expect(screen.getByText("Max seat 2").closest("li")?.textContent).toContain(
- "in use",
- );
- });
-
- it("keeps the unsigned account honest, with the way in offered", async () => {
- installFetchMock();
- renderView();
- await openAgentsTab();
- await waitFor(() => expect(screen.getByText("Default Codex login")).toBeTruthy());
- const row = screen.getByText("Default Codex login").closest("li")!;
- expect(row.textContent).toContain("Not signed in");
- expect(row.querySelector("button")).toBeTruthy();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx
deleted file mode 100644
index effca5a9e6..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.antigravity.test.tsx
+++ /dev/null
@@ -1,364 +0,0 @@
-/**
- * Component tests for Antigravity in ApiKeysView.
- *
- * Antigravity is a Google-subscription worker for Subagents only. It must not
- * render as an activatable main Brain card; the Google login and active toggle
- * live in the Subagent section.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import {
- cleanup,
- fireEvent,
- render,
- screen,
- waitFor,
-} from "@testing-library/react";
-
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
-// mode switch's "Active" badge only) via useVoiceMode, which needs a
-// QueryClientProvider. These tests render ApiKeysView standalone, so the
-// hook is mocked — the mode switch itself is exercised by
-// ApiKeysView.two-mode.test.tsx.
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: false,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-interface RouteResult {
- status?: number;
- body: unknown;
-}
-
-function installFetchMock(routes: Record<string, () => RouteResult>) {
- const calls: { url: string; method: string; body: unknown }[] = [];
- const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
- const url = String(input);
- const method = (init?.method ?? "GET").toUpperCase();
- let body: unknown = null;
- if (typeof init?.body === "string") {
- try {
- body = JSON.parse(init.body);
- } catch {
- body = init.body;
- }
- }
- calls.push({ url, method, body });
- const prefixes = Object.keys(routes).sort((a, b) => b.length - a.length);
- for (const prefix of prefixes) {
- if (url.startsWith(prefix)) {
- const { status = 200, body: resBody } = routes[prefix]();
- return {
- ok: status >= 200 && status < 300,
- status,
- statusText: status >= 200 && status < 300 ? "OK" : "ERR",
- json: async () => resBody,
- text: async () => JSON.stringify(resBody),
- } as Response;
- }
- }
- throw new Error(`unexpected fetch ${url}`);
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
- Object.assign(navigator, {
- clipboard: { writeText: vi.fn(async () => undefined) },
- });
- return { fetchMock, calls };
-}
-
-function antigravityDescriptor(overrides: Record<string, unknown> = {}) {
- return {
- id: "antigravity",
- label: "Antigravity (Google subscription)",
- tier: "brain",
- auth_mode: "antigravity",
- secret_keys: [],
- secrets_set: {},
- dashboard_url: "https://antigravity.google",
- login_cli: ["agy"],
- install_hint: "Install Antigravity (agy) or sign in with the Gemini CLI",
- credential_path_hint: "~/.gemini/oauth_creds.json",
- configured: true, // connected -> configured mirrors it
- active: false,
- brain_switchable: false,
- cli_installed: true,
- antigravity_status: {
- installed: true,
- connected: true,
- mode: "oauth-personal",
- cli_kind: "agy",
- message: "Connected via your Google subscription.",
- version: "agy 0.1.0",
- user_email: "[email protected]",
- binary_path: "agy",
- error: null,
- },
- ...overrides,
- };
-}
-
-function antigravityNotConnected() {
- return antigravityDescriptor({
- configured: false,
- antigravity_status: {
- installed: true,
- connected: false,
- mode: "unknown",
- cli_kind: "agy",
- message: "Installed but not logged in — run the Google login.",
- version: "agy 0.1.0",
- user_email: null,
- binary_path: "agy",
- error: null,
- },
- });
-}
-
-function antigravityMissing() {
- return antigravityDescriptor({
- configured: false,
- cli_installed: false,
- antigravity_status: {
- installed: false,
- connected: false,
- mode: "unknown",
- cli_kind: null,
- message: "No Google CLI found.",
- version: null,
- user_email: null,
- binary_path: "",
- error: "no google cli binary",
- },
- });
-}
-
-const JARVIS_AGENT_EMPTY = {
- configured: true,
- enabled: false,
- binary_path: "",
- binary_detected: null,
- version_pin: null,
- time_cap_min: null,
- concurrency: null,
- state_dir_root: null,
- brain_primary: "gemini",
- provider_slug: null,
- model_override: null,
- model_resolved: null,
- mapping: [
- {
- jarvis: "antigravity",
- openclaw: "agy-cli (direct)",
- env_var: "Google-OAuth",
- env_fallback: null,
- key_set: true,
- is_active_brain: false,
- },
- ],
-};
-
-// The Telephony section mounts inside ApiKeysView, so stub its four endpoints.
-const TELEPHONY_STATUS_EMPTY = {
- available: false,
- configured: false,
- enabled: false,
- account_sid_masked: "",
- phone_number: "",
- public_base_url: "",
- webhook_url: "",
- auth_token_set: false,
- twilio_reachable: false,
- twilio_error: null,
- tts_provider: "",
- tts_voice: "",
- active_calls: 0,
- max_call_seconds: 600,
-};
-const TELEPHONY_CONFIG_EMPTY = {
- enabled: false,
- account_sid: "",
- phone_number: "",
- public_base_url: "",
- greeting: "",
- language_code: "de-DE",
- fallback_mode: "media",
- max_call_seconds: 600,
- auth_token_set: false,
-};
-
-function routesFor(
- provider: Record<string, unknown>,
-): Record<string, () => RouteResult> {
- return {
- "/api/providers": () => ({ body: { providers: [provider] } }),
- "/api/jarvis-agent/status": () => ({ body: JARVIS_AGENT_EMPTY }),
- "/api/antigravity/status": () => ({
- body: provider.antigravity_status ?? {},
- }),
- "/api/jarvis-agent/switch": () => ({
- body: { ok: true, active: "antigravity", persisted: true },
- }),
- "/api/antigravity/login": () => ({
- body: { ok: true, pid: 123, message: "Google login was started" },
- }),
- "/api/antigravity/logout": () => ({
- body: { ok: true, message: "Antigravity (Google) was disconnected" },
- }),
- "/api/telephony/status": () => ({ body: TELEPHONY_STATUS_EMPTY }),
- "/api/telephony/config": () => ({ body: TELEPHONY_CONFIG_EMPTY }),
- "/api/telephony/scripts": () => ({ body: { scripts: [] } }),
- "/api/telephony/calls": () => ({ body: { calls: [] } }),
- };
-}
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-describe("ApiKeysView — Antigravity (Google subscription) OAuth card", () => {
- it("renders the connected subscription card with email AND a Set-active radio", async () => {
- installFetchMock(routesFor(antigravityDescriptor()));
- renderView();
- // Antigravity lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- await waitFor(() =>
- // The redesign shortens the card title to just "Antigravity"; the
- // subscription billing now lives in the billing badge, not the title.
- expect(screen.getAllByText("Antigravity").length).toBeGreaterThan(0),
- );
-
- // The "Set active" control now lives ON the subscription card, so there is
- // no longer a separate "Antigravity (Google subscription)" provider card
- // below it (consolidated — one card per CLI that both connects and selects).
- expect(screen.queryByText("Antigravity (Google subscription)")).toBeNull();
- expect(screen.getByText(/google-user@example\.com/)).toBeTruthy();
- expect(screen.getByRole("radio")).toBeTruthy();
- });
-
- it("switches the subagent to Antigravity when connected", async () => {
- const { calls } = installFetchMock(routesFor(antigravityDescriptor()));
- renderView();
- // Antigravity lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- await waitFor(() => screen.getByRole("radio"));
- fireEvent.click(screen.getByRole("radio"));
-
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/jarvis-agent/switch") &&
- c.method === "POST" &&
- (c.body as { provider?: string })?.provider === "antigravity",
- ),
- ).toBe(true),
- );
- });
-
- it("shows the Connect button while not logged in and starts login", async () => {
- const { calls } = installFetchMock(routesFor(antigravityNotConnected()));
- renderView();
- // Antigravity lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- await waitFor(() =>
- expect(screen.getByText("Connect")).toBeTruthy(),
- );
-
- fireEvent.click(screen.getByText("Connect"));
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/antigravity/login") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-
- it("disables the Connect button and shows the install hint when no CLI is installed", async () => {
- installFetchMock(routesFor(antigravityMissing()));
- renderView();
- // Antigravity lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- const connectBtn = await waitFor(() =>
- screen.getByText("Connect"),
- );
- expect((connectBtn.closest("button") as HTMLButtonElement).disabled).toBe(true);
- // The install hint sits in the row body; open the row first. The row
- // has no login yet, so the click only opens it — no switch.
- fireEvent.click(screen.getAllByText("Antigravity")[0]);
- expect(
- await screen.findByText("Install Antigravity or the Gemini CLI before connecting."),
- ).toBeTruthy();
- });
-
- it("does not show Ready when a Gemini key exists but the CLI is missing", async () => {
- const routes = routesFor(antigravityMissing());
- routes["/api/jarvis-agent/status"] = () => ({
- body: {
- ...JARVIS_AGENT_EMPTY,
- mapping: [
- {
- ...JARVIS_AGENT_EMPTY.mapping[0],
- key_set: false,
- api_key_set: true,
- is_active_brain: true,
- },
- ],
- },
- });
- installFetchMock(routes);
- renderView();
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- // The honest word for a missing CLI: not "open" (vague) and never "ready".
- await waitFor(() => expect(screen.getByText("not installed")).toBeTruthy());
- expect(screen.queryByText("connected")).toBeNull();
- expect(screen.queryByText("active")).toBeNull();
- expect(screen.queryByRole("radio")).toBeNull();
- expect(
- screen.getByText("Install Antigravity or the Gemini CLI before connecting."),
- ).toBeTruthy();
- });
-
- it("disconnects via POST /api/antigravity/logout", async () => {
- const { calls } = installFetchMock(routesFor(antigravityDescriptor()));
- renderView();
- // Antigravity lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- const disconnect = await waitFor(() => screen.getByText("Disconnect"));
- fireEvent.click(disconnect);
-
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/antigravity/logout") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx
deleted file mode 100644
index 335b1b04e6..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.codex.test.tsx
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * Component tests for Codex in ApiKeysView.
- *
- * Codex is a ChatGPT/Codex-login worker for Subagents only. It must not render
- * as an activatable main Brain card; the login and active toggle live in the
- * Subagent section.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import {
- cleanup,
- fireEvent,
- render,
- screen,
- waitFor,
-} from "@testing-library/react";
-
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-// ApiKeysView now reads the live `[voice].mode` (for the Pipeline|Realtime
-// mode switch's "Active" badge only) via useVoiceMode, which needs a
-// QueryClientProvider. These tests render ApiKeysView standalone, so the
-// hook is mocked — the mode switch itself is exercised by
-// ApiKeysView.two-mode.test.tsx.
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: false,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-interface RouteResult {
- status?: number;
- body: unknown;
-}
-
-function installFetchMock(routes: Record<string, () => RouteResult>) {
- const calls: { url: string; method: string; body: unknown }[] = [];
- const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
- const url = String(input);
- const method = (init?.method ?? "GET").toUpperCase();
- let body: unknown = null;
- if (typeof init?.body === "string") {
- try {
- body = JSON.parse(init.body);
- } catch {
- body = init.body;
- }
- }
- calls.push({ url, method, body });
- const prefixes = Object.keys(routes).sort((a, b) => b.length - a.length);
- for (const prefix of prefixes) {
- if (url.startsWith(prefix)) {
- const { status = 200, body: resBody } = routes[prefix]();
- return {
- ok: status >= 200 && status < 300,
- status,
- statusText: status >= 200 && status < 300 ? "OK" : "ERR",
- json: async () => resBody,
- text: async () => JSON.stringify(resBody),
- } as Response;
- }
- }
- throw new Error(`unexpected fetch ${url}`);
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
- Object.assign(navigator, {
- clipboard: { writeText: vi.fn(async () => undefined) },
- });
- return { calls };
-}
-
-function codexStatus(overrides: Record<string, unknown> = {}) {
- return {
- installed: true,
- connected: true,
- mode: "chatgpt",
- message: "Connected via ChatGPT ([email protected]).",
- version: "codex-cli 0.137.0",
- account_label: "ChatGPT/Codex-Login",
- user_email: "[email protected]",
- binary_path: "codex",
- error: null,
- ...overrides,
- };
-}
-
-function codexDescriptor(overrides: Record<string, unknown> = {}) {
- return {
- id: "codex",
- label: "OpenAI Codex",
- tier: "brain",
- auth_mode: "codex",
- secret_keys: ["codex_openai_api_key"],
- secrets_set: { codex_openai_api_key: false },
- dashboard_url: "https://platform.openai.com/api-keys",
- login_cli: ["codex", "login"],
- install_hint: "npm i -g @openai/codex",
- credential_path_hint: null,
- configured: true,
- active: false,
- brain_switchable: false,
- cli_installed: true,
- codex_brain_ready: true,
- codex_status: codexStatus(),
- ...overrides,
- };
-}
-
-function codexDescriptorNotConnected() {
- return codexDescriptor({
- configured: false,
- codex_status: codexStatus({
- connected: false,
- mode: "not_connected",
- message: "Codex is installed but not logged in.",
- account_label: null,
- user_email: null,
- }),
- });
-}
-
-const JARVIS_AGENT_CODEX = {
- configured: true,
- enabled: false,
- binary_path: "",
- binary_detected: null,
- version_pin: null,
- time_cap_min: null,
- concurrency: null,
- state_dir_root: null,
- brain_primary: "gemini",
- provider_slug: null,
- model_override: null,
- sub_model_override: null,
- model_resolved: null,
- mapping: [
- {
- jarvis: "openai-codex",
- openclaw: "codex-cli (direct)",
- env_var: "ChatGPT-OAuth",
- env_fallback: "OPENAI_API_KEY",
- key_set: true,
- is_active_brain: false,
- },
- ],
-};
-
-const TELEPHONY_STATUS_EMPTY = {
- available: false,
- configured: false,
- enabled: false,
- account_sid_masked: "",
- phone_number: "",
- public_base_url: "",
- webhook_url: "",
- auth_token_set: false,
- twilio_reachable: false,
- twilio_error: null,
- tts_provider: "",
- tts_voice: "",
- active_calls: 0,
- max_call_seconds: 600,
-};
-const TELEPHONY_CONFIG_EMPTY = {
- enabled: false,
- account_sid: "",
- phone_number: "",
- public_base_url: "",
- greeting: "",
- language_code: "de-DE",
- fallback_mode: "media",
- max_call_seconds: 600,
- auth_token_set: false,
-};
-
-function routesFor(
- provider: Record<string, unknown>,
-): Record<string, () => RouteResult> {
- return {
- "/api/providers": () => ({ body: { providers: [provider] } }),
- "/api/jarvis-agent/status": () => ({ body: JARVIS_AGENT_CODEX }),
- "/api/codex/status": () => ({
- body: provider.codex_status ?? {},
- }),
- "/api/antigravity/status": () => ({ body: {} }),
- "/api/jarvis-agent/switch": () => ({
- body: { ok: true, active: "openai-codex", persisted: true },
- }),
- "/api/codex/login": () => ({
- body: { ok: true, pid: 123, message: "Codex login was started" },
- }),
- "/api/codex/logout": () => ({
- body: { ok: true, message: "Codex was disconnected" },
- }),
- "/api/brain/switch": () => ({
- status: 500,
- body: { detail: "Codex must not use brain switch" },
- }),
- "/api/telephony/status": () => ({ body: TELEPHONY_STATUS_EMPTY }),
- "/api/telephony/config": () => ({ body: TELEPHONY_CONFIG_EMPTY }),
- "/api/telephony/scripts": () => ({ body: { scripts: [] } }),
- "/api/telephony/calls": () => ({ body: { calls: [] } }),
- };
-}
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-describe("ApiKeysView - Codex is subagent-only", () => {
- it("does not render Codex as a Brain provider card", async () => {
- installFetchMock(routesFor(codexDescriptor()));
- renderView();
- // Codex lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- // The redesign shortens the card title to just "OpenAI Codex"; the
- // subscription-vs-API billing now lives in the billing badge, not the title.
- await waitFor(() => expect(screen.getByText("OpenAI Codex")).toBeTruthy());
-
- expect(screen.queryByText("ChatGPT / Codex login")).toBeNull();
- expect(screen.getByText(/chatgpt-user@example\.com/)).toBeTruthy();
- });
-
- it("switches the subagent to Codex without calling brain switch", async () => {
- const { calls } = installFetchMock(routesFor(codexDescriptor()));
- renderView();
- // Codex lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- await waitFor(() => screen.getByRole("radio"));
- fireEvent.click(screen.getByRole("radio"));
-
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/jarvis-agent/switch") &&
- c.method === "POST" &&
- (c.body as { provider?: string })?.provider === "openai-codex",
- ),
- ).toBe(true),
- );
- expect(calls.some((c) => c.url.startsWith("/api/brain/switch"))).toBe(false);
- });
-
- it("shows the Connect button while not logged in and starts login", async () => {
- const { calls } = installFetchMock(routesFor(codexDescriptorNotConnected()));
- renderView();
- // Codex lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- const connect = await waitFor(() => screen.getByText("Connect"));
- fireEvent.click(connect);
-
- await waitFor(() =>
- expect(
- calls.some(
- (c) => c.url.startsWith("/api/codex/login") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-
- it("disconnects via POST /api/codex/logout", async () => {
- const { calls } = installFetchMock(routesFor(codexDescriptor()));
- renderView();
- // Codex lives in the "Subagents" category tab now; open it first.
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
-
- const disconnect = await waitFor(() => screen.getByText("Disconnect"));
- fireEvent.click(disconnect);
-
- await waitFor(() =>
- expect(
- calls.some(
- (c) => c.url.startsWith("/api/codex/logout") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.grok-build.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.grok-build.test.tsx
deleted file mode 100644
index 70878dc0ff..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.grok-build.test.tsx
+++ /dev/null
@@ -1,293 +0,0 @@
-/**
- * Component tests for Grok Build in ApiKeysView.
- *
- * Grok Build is an xAI-subscription worker for Subagents only. It must not
- * render as an activatable main Brain card; the SuperGrok login and active
- * toggle live in the Subagent section.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import {
- cleanup,
- fireEvent,
- render,
- screen,
- waitFor,
-} from "@testing-library/react";
-
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: false,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-interface RouteResult {
- status?: number;
- body: unknown;
-}
-
-function installFetchMock(routes: Record<string, () => RouteResult>) {
- const calls: { url: string; method: string; body: unknown }[] = [];
- const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
- const url = String(input);
- const method = (init?.method ?? "GET").toUpperCase();
- let body: unknown = null;
- if (typeof init?.body === "string") {
- try {
- body = JSON.parse(init.body);
- } catch {
- body = init.body;
- }
- }
- calls.push({ url, method, body });
- const prefixes = Object.keys(routes).sort((a, b) => b.length - a.length);
- for (const prefix of prefixes) {
- if (url.startsWith(prefix)) {
- const { status = 200, body: resBody } = routes[prefix]();
- return {
- ok: status >= 200 && status < 300,
- status,
- statusText: status >= 200 && status < 300 ? "OK" : "ERR",
- json: async () => resBody,
- text: async () => JSON.stringify(resBody),
- } as Response;
- }
- }
- throw new Error(`unexpected fetch ${url}`);
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
- Object.assign(navigator, {
- clipboard: { writeText: vi.fn(async () => undefined) },
- });
- return { fetchMock, calls };
-}
-
-function grokBuildDescriptor(overrides: Record<string, unknown> = {}) {
- return {
- id: "grok-build",
- label: "Grok Build (xAI subscription)",
- tier: "brain",
- auth_mode: "grok_build",
- secret_keys: [],
- secrets_set: {},
- dashboard_url: null,
- login_cli: ["grok", "login"],
- install_hint: "irm https://x.ai/cli/install.ps1 | iex",
- credential_path_hint: "~/.grok/auth.json",
- configured: true,
- active: false,
- brain_switchable: false,
- cli_installed: true,
- grok_build_status: {
- installed: true,
- connected: true,
- mode: "subscription",
- message: "Connected via SuperGrok / X Premium+",
- version: "grok 0.2.0",
- user_email: "[email protected]",
- binary_path: "grok",
- error: null,
- },
- ...overrides,
- };
-}
-
-const JARVIS_AGENT_EMPTY = {
- configured: true,
- enabled: false,
- binary_path: "",
- binary_detected: null,
- version_pin: null,
- time_cap_min: null,
- concurrency: null,
- state_dir_root: null,
- brain_primary: "gemini",
- provider_slug: null,
- model_override: null,
- model_resolved: null,
- mapping: [
- {
- jarvis: "grok-build",
- openclaw: "grok-cli (direct)",
- env_var: "SuperGrok-OAuth",
- env_fallback: null,
- key_set: true,
- api_key_set: false,
- dedicated_key_set: false,
- shared_key_set: false,
- oauth_connected: true,
- credential_source: "oauth",
- secret_key: null,
- dashboard_url: null,
- credential_help: null,
- is_active_brain: false,
- billing: "subscription",
- label: "Grok Build",
- },
- ],
-};
-
-const TELEPHONY_STATUS_EMPTY = {
- available: false,
- configured: false,
- enabled: false,
- account_sid_masked: "",
- phone_number: "",
- public_base_url: "",
- webhook_url: "",
- auth_token_set: false,
- twilio_reachable: false,
- twilio_error: null,
- tts_provider: "",
- tts_voice: "",
- active_calls: 0,
- max_call_seconds: 600,
-};
-const TELEPHONY_CONFIG_EMPTY = {
- enabled: false,
- account_sid: "",
- phone_number: "",
- public_base_url: "",
- greeting: "",
- language_code: "de-DE",
- fallback_mode: "media",
- max_call_seconds: 600,
- auth_token_set: false,
-};
-
-function routesFor(
- provider: Record<string, unknown>,
-): Record<string, () => RouteResult> {
- return {
- "/api/providers": () => ({ body: { providers: [provider] } }),
- "/api/jarvis-agent/status": () => ({ body: JARVIS_AGENT_EMPTY }),
- "/api/codex/status": () => ({ body: {} }),
- "/api/antigravity/status": () => ({ body: {} }),
- "/api/claude/status": () => ({ body: {} }),
- "/api/grok-build/status": () => ({
- body: provider.grok_build_status ?? {},
- }),
- "/api/jarvis-agent/switch": () => ({
- body: { ok: true, active: "grok-build", persisted: true },
- }),
- "/api/grok-build/login": () => ({
- body: { ok: true, pid: 123, message: "Grok Build login was started" },
- }),
- "/api/grok-build/logout": () => ({
- body: { ok: true, message: "Grok Build was disconnected" },
- }),
- "/api/telephony/status": () => ({ body: TELEPHONY_STATUS_EMPTY }),
- "/api/telephony/config": () => ({ body: TELEPHONY_CONFIG_EMPTY }),
- "/api/telephony/scripts": () => ({ body: { scripts: [] } }),
- "/api/telephony/calls": () => ({ body: { calls: [] } }),
- };
-}
-
-function grokBuildNotConnected() {
- return grokBuildDescriptor({
- grok_build_status: {
- installed: true,
- connected: false,
- mode: "unknown",
- message: "Grok Build login not connected",
- version: "grok 0.2.0",
- user_email: null,
- binary_path: "grok",
- error: null,
- },
- });
-}
-
-describe("ApiKeysView — Grok Build (xAI subscription) OAuth card", () => {
- afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
- });
-
- it("renders the connected subscription card with email AND a Set-active radio", async () => {
- installFetchMock(routesFor(grokBuildDescriptor()));
- renderView();
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
- await waitFor(() => expect(screen.getByText("Grok Build")).toBeTruthy());
- expect(screen.getByText(/ada@example\.com/)).toBeTruthy();
- expect(screen.getByRole("radio")).toBeTruthy();
- });
-
- it("switches the subagent to Grok Build when connected", async () => {
- const { calls } = installFetchMock(routesFor(grokBuildDescriptor()));
- renderView();
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
- await waitFor(() => screen.getByRole("radio"));
- fireEvent.click(screen.getByRole("radio"));
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/jarvis-agent/switch") &&
- c.method === "POST" &&
- (c.body as { provider?: string })?.provider === "grok-build",
- ),
- ).toBe(true),
- );
- });
-
- it("shows the Connect button while not logged in and starts login", async () => {
- const mapping = {
- ...JARVIS_AGENT_EMPTY,
- mapping: [
- {
- ...JARVIS_AGENT_EMPTY.mapping[0],
- key_set: false,
- oauth_connected: false,
- },
- ],
- };
- const { calls } = installFetchMock({
- ...routesFor(grokBuildNotConnected()),
- "/api/jarvis-agent/status": () => ({ body: mapping }),
- });
- renderView();
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
- await waitFor(() => expect(screen.getByText("Connect")).toBeTruthy());
- fireEvent.click(screen.getByText("Connect"));
- await waitFor(() =>
- expect(
- calls.some(
- (c) => c.url.startsWith("/api/grok-build/login") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-
- it("disconnects via POST /api/grok-build/logout", async () => {
- const { calls } = installFetchMock(routesFor(grokBuildDescriptor()));
- renderView();
- fireEvent.click(screen.getByRole("tab", { name: /-agents$/i }));
- const disconnect = await waitFor(() => screen.getByText("Disconnect"));
- fireEvent.click(disconnect);
- await waitFor(() =>
- expect(
- calls.some(
- (c) =>
- c.url.startsWith("/api/grok-build/logout") && c.method === "POST",
- ),
- ).toBe(true),
- );
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.local-mode.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.local-mode.test.tsx
deleted file mode 100644
index f0d49189e3..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.local-mode.test.tsx
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Component tests for the Local Mode switch on the API-Keys screen.
- *
- * The switch answers a specific complaint: an install that went down the local
- * path landed in a console full of hosted cards, with no obvious, reversible
- * control over that. So the tests pin the reversibility as hard as the
- * filtering — the header control has to be present, readable, and able to put
- * every card back with one click.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
-import type { ProviderDescriptor } from "@/hooks/useProviders";
-
-function card(
- id: string,
- label: string,
- billing: ProviderDescriptor["billing"],
- active = false,
-): ProviderDescriptor {
- return {
- id,
- label,
- tier: "brain",
- auth_mode: billing === "local" ? "none" : "api_key",
- secret_keys: billing === "local" ? [] : [`${id}_api_key`],
- secrets_set: {},
- dashboard_url: null,
- login_cli: null,
- install_hint: null,
- credential_path_hint: null,
- configured: false,
- active,
- cli_installed: null,
- credential_help: null,
- signup_url: null,
- billing,
- alt_credential: null,
- };
-}
-
-let mockProviders: ProviderDescriptor[] = [];
-
-vi.mock("@/hooks/useProviders", async (importOriginal) => {
- const actual = await importOriginal<typeof import("@/hooks/useProviders")>();
- return {
- ...actual,
- useProviders: () => ({
- providers: mockProviders,
- loading: false,
- error: null,
- refetch: vi.fn(),
- setActiveOptimistic: vi.fn(),
- }),
- useSectionHealth: () => ({ health: {}, reload: vi.fn() }),
- };
-});
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: true,
- statusKnown: true,
- connecting: false,
- requiresWebRtcOffer: false,
- transportOfferReady: null,
- transportOfferDetail: "",
- transportIssue: null,
- sessionActive: false,
- activeSessionMode: null,
- activeSessionProvider: "",
- activeSessionModel: "",
- transitioning: false,
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-import { setLocalMode } from "@/lib/localMode";
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-afterEach(() => {
- cleanup();
- vi.clearAllMocks();
- setLocalMode(false);
- window.localStorage.clear();
- mockProviders = [];
-});
-
-describe("ApiKeysView local mode", () => {
- it("sits in the header next to the engine switch and starts off", () => {
- render(<ApiKeysView />);
-
- const control = screen.getByTestId("local-mode-switch");
- expect(control.closest("header")).not.toBeNull();
- expect(control.getAttribute("aria-pressed")).toBe("false");
- expect(screen.getByTestId("voice-engine-header-control")).toBeTruthy();
- expect(screen.queryByTestId("local-mode-notice")).toBeNull();
- });
-
- it("hides hosted provider cards when switched on, and restores them when off", () => {
- mockProviders = [
- card("openai", "OpenAI", "api"),
- card("ollama", "Ollama", "local"),
- ];
- render(<ApiKeysView />);
-
- expect(screen.getByText("OpenAI")).toBeTruthy();
-
- fireEvent.click(screen.getByTestId("local-mode-switch"));
-
- expect(screen.queryByText("OpenAI")).toBeNull();
- expect(screen.getByText("Ollama")).toBeTruthy();
- expect(screen.getByTestId("local-mode-switch").getAttribute("aria-pressed")).toBe(
- "true",
- );
-
- fireEvent.click(screen.getByTestId("local-mode-switch"));
-
- expect(screen.getByText("OpenAI")).toBeTruthy();
- expect(screen.queryByTestId("local-mode-notice")).toBeNull();
- });
-
- it("says how many cards it hid and offers a way back to all of them", () => {
- mockProviders = [
- card("openai", "OpenAI", "api"),
- card("gemini", "Gemini", "api"),
- card("ollama", "Ollama", "local"),
- ];
- render(<ApiKeysView />);
-
- fireEvent.click(screen.getByTestId("local-mode-switch"));
-
- const notice = screen.getByTestId("local-mode-notice");
- expect(notice.textContent).toContain("2");
-
- fireEvent.click(screen.getByText("Show all providers"));
-
- expect(screen.getByText("OpenAI")).toBeTruthy();
- expect(screen.queryByTestId("local-mode-notice")).toBeNull();
- });
-
- it("keeps the running hosted provider visible so the tier is never blank", () => {
- mockProviders = [
- card("openai", "OpenAI", "api", true),
- card("ollama", "Ollama", "local"),
- ];
- render(<ApiKeysView />);
-
- fireEvent.click(screen.getByTestId("local-mode-switch"));
-
- expect(screen.getByText("OpenAI")).toBeTruthy();
- // Nothing was hidden, so there is nothing to explain.
- expect(screen.queryByTestId("local-mode-notice")).toBeNull();
- });
-
- it("survives a remount, because it is a stored preference", () => {
- mockProviders = [
- card("openai", "OpenAI", "api"),
- card("ollama", "Ollama", "local"),
- ];
- const first = render(<ApiKeysView />);
- fireEvent.click(screen.getByTestId("local-mode-switch"));
- first.unmount();
-
- render(<ApiKeysView />);
- expect(screen.getByTestId("local-mode-switch").getAttribute("aria-pressed")).toBe(
- "true",
- );
- expect(screen.queryByText("OpenAI")).toBeNull();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime.test.tsx
deleted file mode 100644
index 6b349e009c..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.realtime.test.tsx
+++ /dev/null
@@ -1,340 +0,0 @@
-/**
- * The API Keys page is realtime-only: no Pipeline|Realtime switch, no
- * pipeline tiers, no Local Mode toggle. These tests pin the tab set, the
- * provider list (one click on a provider with a saved key makes it the voice),
- * the experimental acknowledgement, and the way back onto Realtime for an
- * install still pinned to the retired pipeline engine.
- */
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
-
-const setVoiceMode = vi.fn();
-let mockProviders: unknown[] = [];
-let mockHealth: Record<string, unknown> = {};
-let voiceState: Record<string, unknown> = {};
-
-vi.mock("@/hooks/useProviders", async (importOriginal) => ({
- ...(await importOriginal<typeof import("@/hooks/useProviders")>()),
- useProviders: () => ({
- providers: mockProviders,
- loading: false,
- error: null,
- refetch: vi.fn(),
- setActiveOptimistic: vi.fn(),
- }),
- useSectionHealth: () => ({ health: mockHealth }),
-}));
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "realtime",
- realtimeAvailable: true,
- statusKnown: true,
- requiresWebRtcOffer: false,
- transportOfferReady: null,
- transportOfferDetail: "",
- transportIssue: null,
- activeProvider: "openai-live",
- activeProviderLabel: "OpenAI GPT-Live",
- activeModel: "gpt-live-1",
- sessionActive: false,
- activeSessionMode: null,
- connecting: false,
- lastStartError: null,
- setMode: setVoiceMode,
- isLoading: false,
- isSaving: false,
- ...voiceState,
- }),
-}));
-
-import { ApiKeysView } from "@/views/ApiKeysView";
-import { clearApiKeysTabRequest, requestApiKeysTab } from "@/lib/apiKeysTab";
-
-const BASE = {
- tier: "realtime",
- auth_mode: "api_key",
- dashboard_url: null,
- login_cli: null,
- install_hint: null,
- credential_path_hint: null,
- cli_installed: null,
- credential_help: null,
- signup_url: null,
- billing: "api",
- alt_credential: null,
- configuration_surface: "provider",
-};
-
-const LIVE = {
- ...BASE,
- id: "openai-live",
- label: "OpenAI GPT-Live",
- configuration_surface: "live",
- secret_keys: ["openai_api_key"],
- secrets_set: { openai_api_key: true },
- configured: true,
- active: true,
-};
-
-const GEMINI = {
- ...BASE,
- id: "gemini-live",
- label: "Gemini Live",
- secret_keys: ["realtime_gemini_api_key"],
- secrets_set: { realtime_gemini_api_key: true },
- configured: true,
- active: false,
-};
-
-const VERTEX = {
- ...BASE,
- id: "vertex-live",
- label: "Vertex AI Live",
- secret_keys: ["realtime_vertex_api_key"],
- secrets_set: { realtime_vertex_api_key: false },
- configured: false,
- active: false,
-};
-
-const LOCAL = {
- ...BASE,
- id: "local-realtime",
- label: "Local voice",
- auth_mode: "none",
- billing: "local",
- secret_keys: [],
- secrets_set: {},
- configured: true,
- active: false,
- experimental: true,
-};
-
-const PIPELINE_BRAIN = {
- ...BASE,
- id: "openrouter",
- label: "OpenRouter",
- tier: "brain",
- secret_keys: ["OPENROUTER_API_KEY"],
- secrets_set: { OPENROUTER_API_KEY: true },
- configured: true,
- active: true,
-};
-
-const LIVE_PROFILE = {
- key_ready: true,
- active: true,
- agent_configured: true,
- profile: {
- model: "gpt-live-1",
- voice: "gleam",
- backend_model: "gpt-6-luna",
- reasoning_effort: "medium",
- web_search: true,
- instructions: "",
- backend_instructions: "",
- configured: true,
- },
-};
-
-const requests: { url: string; method: string; body: unknown }[] = [];
-
-function installFetch() {
- requests.length = 0;
- vi.stubGlobal(
- "fetch",
- vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
- const url = String(input);
- const method = (init?.method ?? "GET").toUpperCase();
- requests.push({ url, method, body: init?.body ? JSON.parse(String(init.body)) : null });
- const body = url.startsWith("/api/live/profile")
- ? LIVE_PROFILE
- : url.startsWith("/api/live/options")
- ? { models: [{ id: "gpt-6-luna", label: "gpt-6-luna" }], voices: ["gleam"], efforts: ["", "medium"] }
- : url.includes("/realtime-options")
- ? { provider: "x", models: [], voices: [], current_model: "", current_voice: "", preview_available: false }
- : url.startsWith("/api/realtime/switch")
- ? { active: "x", restart_required: false }
- : url.startsWith("/api/jarvis-agent/status")
- ? { mapping: [], brain_primary: "" }
- : {};
- return {
- ok: true,
- status: 200,
- json: async () => body,
- text: async () => JSON.stringify(body),
- } as Response;
- }),
- );
-}
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-beforeEach(() => {
- mockProviders = [LIVE, GEMINI, VERTEX, LOCAL, PIPELINE_BRAIN];
- mockHealth = {};
- voiceState = {};
- installFetch();
- try {
- window.localStorage.clear();
- } catch {
- // jsdom always has storage; nothing to clear otherwise.
- }
-});
-
-afterEach(() => {
- cleanup();
- vi.clearAllMocks();
- vi.unstubAllGlobals();
- clearApiKeysTabRequest();
-});
-
-describe("ApiKeysView — realtime only", () => {
- it("offers exactly the realtime, agents, key and advanced tabs", () => {
- renderView();
- const names = screen.getAllByRole("tab").map((tab) => tab.textContent);
- expect(names).toHaveLength(4);
- expect(screen.getByRole("tab", { name: /^realtime$/i }).getAttribute("aria-selected")).toBe("true");
- expect(screen.getByRole("tab", { name: /-agents$/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /key$/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /^advanced$/i })).toBeTruthy();
- for (const gone of [/^brain$/i, /voice input/i, /voice output/i, /wording/i, /tool model/i]) {
- expect(screen.queryByRole("tab", { name: gone })).toBeNull();
- }
- });
-
- it("has no Pipeline switch and no Local Mode toggle", () => {
- renderView();
- expect(screen.queryByTestId("voice-engine-header-control")).toBeNull();
- expect(screen.queryByTestId("local-mode-switch")).toBeNull();
- expect(screen.queryByText(/pipeline/i)).toBeNull();
- });
-
- it("lists only realtime providers, with the active one marked", () => {
- renderView();
- const list = screen.getByTestId("realtime-provider-list");
- expect(within(list).getAllByRole("button")).toHaveLength(5);
- expect(screen.getByTestId("realtime-provider-openai-live-subscription").textContent).toContain("GPT Subscription");
- expect(screen.queryByTestId("realtime-provider-openrouter")).toBeNull();
- expect(screen.getByTestId("realtime-provider-openai-live").dataset.active).toBe("true");
- expect(screen.getByTestId("realtime-provider-gemini-live").dataset.active).toBe("false");
- });
-
- it("says what the voice runs on right now", () => {
- renderView();
- const card = screen.getByTestId("voice-now");
- expect(card.textContent).toContain("OpenAI GPT-Live");
- expect(card.textContent).toContain("gpt-live-1");
- expect(screen.getByTestId("voice-now-state").textContent).toMatch(/ready for your next call/i);
- });
-
- it("switches the voice with one click on a provider whose key is saved", async () => {
- renderView();
- fireEvent.click(screen.getByTestId("realtime-provider-gemini-live"));
- await waitFor(() =>
- expect(requests.some((r) => r.url === "/api/realtime/switch")).toBe(true),
- );
- const call = requests.find((r) => r.url === "/api/realtime/switch");
- expect(call?.body).toMatchObject({ provider: "gemini-live", persist: true, accept_experimental: false });
- // The voice already runs on Realtime, so the engine is left alone.
- expect(setVoiceMode).not.toHaveBeenCalled();
- });
-
- it("only opens the settings of a provider that has no key yet", () => {
- renderView();
- fireEvent.click(screen.getByTestId("realtime-provider-vertex-live"));
- expect(screen.getByTestId("realtime-settings-vertex-live")).toBeTruthy();
- expect(screen.getByTestId("realtime-provider-vertex-live").getAttribute("aria-pressed")).toBe("true");
- expect(requests.some((r) => r.url === "/api/realtime/switch")).toBe(false);
- });
-
- it("asks once before an experimental provider becomes the voice", async () => {
- renderView();
- fireEvent.click(screen.getByTestId("realtime-provider-local-realtime"));
- const dialog = await screen.findByTestId("realtime-consent-dialog");
- expect(requests.some((r) => r.url === "/api/realtime/switch")).toBe(false);
- fireEvent.click(within(dialog).getByRole("button", { name: /yes/i }));
- await waitFor(() =>
- expect(requests.find((r) => r.url === "/api/realtime/switch")?.body).toMatchObject({
- provider: "local-realtime",
- accept_experimental: true,
- }),
- );
- expect(window.localStorage.getItem("jarvis.experimentalConsent.local-realtime")).toBe("1");
- });
-
- it("re-selects GPT-Live by saving its stored profile", async () => {
- mockProviders = [
- { ...LIVE, active: false },
- { ...GEMINI, active: true },
- VERTEX,
- LOCAL,
- ];
- renderView();
- // The profile has to have arrived before a click can switch to it.
- await waitFor(() => expect(requests.some((r) => r.url === "/api/live/profile")).toBe(true));
- await act(async () => {
- await Promise.resolve();
- });
- fireEvent.click(screen.getByTestId("realtime-provider-openai-live"));
- await waitFor(() =>
- expect(requests.some((r) => r.url === "/api/live/profile" && r.method === "PUT")).toBe(true),
- );
- const put = requests.find((r) => r.url === "/api/live/profile" && r.method === "PUT");
- expect(put?.body).toMatchObject({ backend_model: "gpt-6-luna", configured: true });
- });
-});
-
-describe("ApiKeysView — an install still on the pipeline engine", () => {
- it("offers one click back onto Realtime", () => {
- voiceState = { mode: "pipeline" };
- renderView();
- expect(screen.getByTestId("voice-now").textContent).toMatch(/realtime is off/i);
- fireEvent.click(screen.getByTestId("voice-now-turn-on"));
- expect(setVoiceMode).toHaveBeenCalledWith("realtime");
- });
-
- it("treats a click on the provider already in place as 'use it'", () => {
- voiceState = { mode: "pipeline" };
- renderView();
- fireEvent.click(screen.getByTestId("realtime-provider-openai-live"));
- expect(setVoiceMode).toHaveBeenCalledWith("realtime");
- expect(requests.some((r) => r.method === "PUT" || r.url === "/api/realtime/switch")).toBe(false);
- });
-
- it("moves the engine to Realtime when a provider is picked", async () => {
- voiceState = { mode: "pipeline" };
- renderView();
- fireEvent.click(screen.getByTestId("realtime-provider-gemini-live"));
- await waitFor(() => expect(setVoiceMode).toHaveBeenCalledWith("realtime"));
- });
-
- it("explains a call that fell back off Realtime", () => {
- voiceState = { sessionActive: true, activeSessionMode: "pipeline" };
- renderView();
- expect(screen.getByTestId("voice-now-state").textContent).toMatch(/backup voice path/i);
- expect(screen.getByTestId("voice-now-note-backup")).toBeTruthy();
- });
-});
-
-describe("ApiKeysView — tab requests", () => {
- it("opens the tab the first-run guide asks for", () => {
- requestApiKeysTab("subagents");
- renderView();
- expect(screen.getByRole("tab", { name: /-agents$/i }).getAttribute("aria-selected")).toBe("true");
- });
-
- it("falls back to Realtime for a retired pipeline tab", () => {
- requestApiKeysTab("brain");
- renderView();
- expect(screen.getByRole("tab", { name: /^realtime$/i }).getAttribute("aria-selected")).toBe("true");
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx
deleted file mode 100644
index cbb91838b8..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.section-health.test.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * Component tests for the API-Keys section-health tab indicators.
- *
- * The tab bar shows a dot per tab: amber when the section still has to be set
- * up ("needs_setup"), red when it is set up but failing a live check
- * ("error"). "ok" / "unknown" stay silent. These tests pin that the dot and
- * its plain-language tooltip render from the /api/providers/section-health
- * rollup, that the red state drills down onto the failing provider, and that
- * sections the page no longer shows (the retired pipeline tiers) never light
- * a tab.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { cleanup, render, screen, waitFor } from "@testing-library/react";
-
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "realtime",
- realtimeAvailable: true,
- statusKnown: true,
- sessionActive: false,
- activeSessionMode: null,
- connecting: false,
- lastStartError: null,
- activeModel: "",
- setMode: vi.fn(),
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-interface RouteResult {
- status?: number;
- body: unknown;
-}
-
-function installFetchMock(routes: Record<string, () => RouteResult>) {
- const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
- const url = String(input);
- const prefixes = Object.keys(routes).sort((a, b) => b.length - a.length);
- for (const prefix of prefixes) {
- if (url.startsWith(prefix)) {
- const { status: code = 200, body } = routes[prefix]();
- return {
- ok: code >= 200 && code < 300,
- status: code,
- statusText: code >= 200 && code < 300 ? "OK" : "ERR",
- json: async () => body,
- text: async () => JSON.stringify(body),
- } as Response;
- }
- }
- throw new Error(`unexpected fetch ${url}`);
- });
- (globalThis as unknown as { fetch: typeof fetch }).fetch =
- fetchMock as unknown as typeof fetch;
-}
-
-function renderView() {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(
- <QueryClientProvider client={client}>
- <ApiKeysView />
- </QueryClientProvider>,
- );
-}
-
-// An active, configured realtime provider — the shape the drill-down banner
-// must land on when its live check fails.
-const ACTIVE_REALTIME = {
- id: "gemini-live",
- label: "Gemini Live",
- tier: "realtime",
- auth_mode: "api_key",
- secret_keys: ["realtime_gemini_api_key"],
- secrets_set: { realtime_gemini_api_key: true },
- dashboard_url: null,
- login_cli: null,
- install_hint: null,
- credential_path_hint: null,
- configured: true,
- active: true,
- cli_installed: null,
- credential_help: null,
- signup_url: null,
- billing: "api",
- alt_credential: null,
- configuration_surface: "provider",
-};
-
-function health(sections: Record<string, unknown>) {
- return {
- sections: {
- brain: { status: "error", reason: "bad_key", detail: "OpenRouter: key invalid", subject_id: "openrouter" },
- stt: { status: "error", reason: "bad_key", detail: "Groq STT: key invalid", subject_id: "groq-api" },
- realtime: { status: "ok", reason: "ok", detail: "Gemini Live: ok", subject_id: "gemini-live" },
- subagents: { status: "ok", reason: "ok", detail: "", subject_id: null },
- advanced: { status: "unknown", reason: "unknown", detail: "", subject_id: null },
- ...sections,
- },
- checked_at: 0,
- cached: false,
- };
-}
-
-function routes(sectionHealth: unknown) {
- return {
- "/api/providers/section-health": () => ({ body: sectionHealth }),
- "/api/providers/gemini-live/realtime-options": () => ({
- body: { provider: "gemini-live", models: [], voices: [], current_model: "", current_voice: "", preview_available: false },
- }),
- "/api/providers": () => ({ body: { providers: [ACTIVE_REALTIME] } }),
- "/api/jarvis-agent/status": () => ({ body: { mapping: [], brain_primary: "" } }),
- };
-}
-
-afterEach(() => {
- cleanup();
- vi.restoreAllMocks();
-});
-
-describe("ApiKeysView — section-health tab indicators", () => {
- it("marks a not-set-up tab amber ('Setup needed')", async () => {
- installFetchMock(
- routes(health({ subagents: { status: "needs_setup", reason: "not_configured", detail: "No agent", subject_id: null } })),
- );
- renderView();
- await waitFor(() =>
- expect(screen.getByRole("tab", { name: /-agents.*Setup needed/i })).toBeTruthy(),
- );
- });
-
- it("marks a broken tab red ('Not working') with the cause in the tooltip", async () => {
- installFetchMock(
- routes(health({ realtime: { status: "error", reason: "no_credits", detail: "Gemini Live: out of credit", subject_id: "gemini-live" } })),
- );
- renderView();
- const tab = await waitFor(() => screen.getByRole("tab", { name: /Realtime.*Not working/i }));
- expect(tab.getAttribute("title")).toMatch(/out of credit/i);
- });
-
- it("never lights a tab for the retired pipeline tiers", async () => {
- installFetchMock(routes(health({})));
- renderView();
- await waitFor(() => screen.getByTestId("realtime-provider-gemini-live"));
- // brain and stt are failing in the rollup, but the page shows neither.
- for (const tab of screen.getAllByRole("tab")) {
- expect(tab.getAttribute("title")).toBeNull();
- }
- });
-
- it("drills the error onto the failing provider with the cause in plain text", async () => {
- installFetchMock(
- routes(health({ realtime: { status: "error", reason: "rate_limited", detail: "Gemini Live: rate limited", subject_id: "gemini-live" } })),
- );
- renderView();
- const banner = await waitFor(() => screen.getByTestId("realtime-health-error-gemini-live"));
- expect(banner.textContent).toMatch(/Not working/i);
- expect(banner.textContent).toMatch(/rate limited/i);
- });
-
- it("does not mark the provider red when it is healthy", async () => {
- installFetchMock(routes(health({})));
- renderView();
- await waitFor(() => screen.getByTestId("realtime-provider-gemini-live"));
- expect(screen.queryByTestId("realtime-health-error-gemini-live")).toBeNull();
- });
-
- it("never attributes an obsolete failure of another provider to the active one", async () => {
- installFetchMock(
- routes(health({ realtime: { status: "error", reason: "timeout", detail: "OpenAI GPT-Live: timeout", subject_id: "openai-live" } })),
- );
- renderView();
- const tab = await waitFor(() => screen.getByRole("tab", { name: /^Realtime$/i }));
- expect(tab.getAttribute("title")).toBeNull();
- expect(screen.queryByTestId("realtime-health-error-gemini-live")).toBeNull();
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx
deleted file mode 100644
index a23520842e..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.two-mode.test.tsx
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * Component tests for the Pipeline|Realtime segmented switch on the
- * API-Keys screen.
- *
- * Feature A (supersedes D1): the segment is a real mode control. Clicking a
- * segment still switches the local VIEW, but now ALSO persists
- * `[voice].mode` via `useVoiceMode().setMode` — Pipeline always, Realtime
- * only when `realtimeAvailable` is true (a key is actually configured for
- * some realtime family). These tests pin (1) the mode-derived tab sets and
- * (2) the setMode call pattern for both availability states.
- */
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
-import type { ReactElement } from "react";
-
-function renderKeys(ui: ReactElement = <ApiKeysView />) {
- const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
- return render(<QueryClientProvider client={client}>{ui}</QueryClientProvider>);
-}
-
-// Mock the data hooks so the view renders deterministically, without a
-// network round-trip.
-vi.mock("@/hooks/useProviders", () => ({
- sectionHealthForSubject: (
- health: { subject_id?: string } | undefined,
- subjectId?: string,
- ) => (subjectId && health?.subject_id === subjectId ? health : undefined),
- useProviders: () => ({
- providers: [],
- loading: false,
- error: null,
- refetch: vi.fn(),
- setActiveOptimistic: vi.fn(),
- }),
- useSectionHealth: () => ({ health: {} }),
-}));
-
-// The real `useVoiceMode` hook (jarvis/ui/web/frontend/src/hooks/useVoiceMode.ts)
-// returns { mode, realtimeAvailable, setMode, isLoading, isSaving } — mock that
-// exact shape so the "Active" badge + the setMode assertions below are real.
-// `mockRealtimeAvailable` is mutable per-test (declared via `let` above the
-// `vi.mock` call, matching this file's existing hoisting pattern) so the
-// "realtime unavailable" describe block below can flip it.
-let mockRealtimeAvailable = true;
-let mockVoiceMode = "pipeline";
-let mockSessionActive = false;
-let mockActiveSessionMode: "pipeline" | "realtime" | null = null;
-let mockTransitioning = false;
-const putVoiceMode = vi.fn();
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: mockVoiceMode,
- realtimeAvailable: mockRealtimeAvailable,
- statusKnown: true,
- sessionActive: mockSessionActive,
- activeSessionMode: mockActiveSessionMode,
- activeSessionProvider: "",
- activeSessionModel: "",
- transitioning: mockTransitioning,
- setMode: putVoiceMode,
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-afterEach(() => {
- cleanup();
- vi.clearAllMocks();
- mockRealtimeAvailable = true;
- mockVoiceMode = "pipeline";
- mockSessionActive = false;
- mockActiveSessionMode = null;
- mockTransitioning = false;
-});
-
-describe("ApiKeysView two-mode", () => {
- it("keeps mode controls in the header and voice setup in the scrolling content", () => {
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
-
- const headerControl = screen.getByTestId("voice-engine-header-control");
- const providerScroll = screen.getByTestId("api-keys-provider-scroll");
- const context = screen.getByRole("tabpanel", { name: "Voice & thinking" });
- const categoryTabs = screen.getByTestId("api-keys-category-tabs");
-
- expect(headerControl.closest("header")).not.toBeNull();
- expect(providerScroll.contains(context)).toBe(true);
- expect(providerScroll.className).toContain("min-h-0");
- expect(categoryTabs.className).toContain("overflow-x-auto");
- expect(screen.getByRole("tablist").className).toContain("min-w-max");
- expect(screen.queryByTestId("voice-engine-context")).toBeNull();
- });
-
- it("never offers a separate Tool Model in either voice mode", () => {
- renderKeys();
- expect(screen.queryByRole("tab", { name: /tool model/i })).toBeNull();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
- expect(screen.queryByRole("tab", { name: /tool model/i })).toBeNull();
- expect(screen.getByText(/Text chat and background tasks use your selection in Agents/)).toBeTruthy();
- });
-
- it("defaults to Pipeline mode showing Brain/Voice/Subagents tabs, no Realtime tab", () => {
- renderKeys();
- expect(screen.getByRole("tab", { name: /brain/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /voice output/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /voice input/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /-agents$/i })).toBeTruthy();
- // The dedicated key tab is named after the assistant ({name} token; the
- // uncached test default resolves to "Assistant").
- expect(screen.getByRole("tab", { name: /assistant key/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /advanced/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /realtime/i })).toBeNull();
- });
-
- it("shows the segmented Pipeline|Realtime switch with an Active badge on the live mode", () => {
- renderKeys();
- const pipelineSegment = screen.getByRole("button", { name: /pipeline/i });
- const realtimeSegment = screen.getByRole("button", { name: /^realtime/i });
- expect(pipelineSegment).toBeTruthy();
- expect(realtimeSegment).toBeTruthy();
- // The live [voice].mode from the mocked useVoiceMode is "pipeline", so
- // only the Pipeline segment carries the "Active" badge.
- expect(pipelineSegment.textContent).toMatch(/active/i);
- expect(realtimeSegment.textContent).not.toMatch(/active/i);
- });
-
- it("marks Realtime as recommended and Pipeline as not recommended", () => {
- renderKeys();
- const pipelineSegment = screen.getByRole("button", { name: /pipeline/i });
- const realtimeSegment = screen.getByRole("button", { name: /^realtime/i });
- expect(pipelineSegment.textContent).toMatch(/not recommended/i);
- expect(realtimeSegment.textContent).toMatch(/recommended/i);
- expect(realtimeSegment.textContent).not.toMatch(/not recommended/i);
- });
-
- it("keeps the highlighted header segment aligned with the selected provider view", () => {
- renderKeys();
- const thumb = screen.getByTestId("voice-engine-selection-thumb");
-
- expect(thumb.style.transform).toBe("translateX(100%)");
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
-
- expect(screen.getByRole("button", { name: /^realtime/i }).getAttribute("aria-pressed"))
- .toBe("true");
- expect(thumb.style.transform).toBe("translateX(0%)");
- });
-
- it("offers one provider setup instead of the legacy recommendation block", () => {
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
- expect(screen.getByRole("group", { name: "Voice provider settings" })).toBeTruthy();
- expect(screen.queryByText(/personal recommendation/i)).toBeNull();
- });
-
- it("shows when the selected Realtime mode is still served by Pipeline", () => {
- mockVoiceMode = "realtime";
- mockSessionActive = true;
- mockActiveSessionMode = "pipeline";
-
- renderKeys();
-
- expect(screen.getByTestId("voice-engine-runtime-status").textContent).toMatch(
- /fell back to Pipeline/i,
- );
- });
-
- it("switching to Realtime mode shows only Realtime/Subagents/Advanced and persists voice-mode (available)", () => {
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i })); // the segment
-
- expect(screen.getByRole("tab", { name: /realtime/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /-agents$/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /assistant key/i })).toBeTruthy();
- expect(screen.getByRole("tab", { name: /advanced/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /^brain$/i })).toBeNull();
- expect(screen.queryByRole("tab", { name: /voice output/i })).toBeNull();
- expect(screen.queryByRole("tab", { name: /voice input/i })).toBeNull();
-
- // Feature A (supersedes D1): with a realtime provider actually reachable
- // (mocked realtimeAvailable=true), the segment now persists the mode.
- expect(putVoiceMode).toHaveBeenCalledWith("realtime");
- });
-
- it("switching back to Pipeline restores the five pipeline tabs and always persists voice-mode", () => {
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
- putVoiceMode.mockClear();
- fireEvent.click(screen.getByRole("button", { name: /pipeline/i }));
-
- expect(screen.getByRole("tab", { name: /brain/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /realtime/i })).toBeNull();
- // Pipeline always persists — it is always reachable (no key gate needed).
- expect(putVoiceMode).toHaveBeenCalledWith("pipeline");
- });
-});
-
-describe("ApiKeysView two-mode — realtime unavailable (no key in any family)", () => {
- it("does not label unavailable configured Realtime as live", () => {
- mockVoiceMode = "realtime";
- mockRealtimeAvailable = false;
- renderKeys();
-
- const realtimeSegment = screen.getByRole("button", { name: /^realtime/i });
- expect(realtimeSegment.textContent).not.toMatch(/active/i);
- expect(realtimeSegment.getAttribute("data-live")).toBe("false");
- expect(screen.getByTestId("voice-engine-selection-thumb")).toBeTruthy();
- });
-
- it("switching to Realtime still switches the view, but does NOT persist voice-mode", () => {
- mockRealtimeAvailable = false;
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
-
- // The view still switches, so the user can add a key from the Realtime tab.
- expect(screen.getByRole("tab", { name: /realtime/i })).toBeTruthy();
- // But nothing is reachable yet — never pin [voice].mode to a dead engine.
- expect(putVoiceMode).not.toHaveBeenCalled();
- });
-
- it("switching back to Pipeline still persists voice-mode even when realtime is unavailable", () => {
- mockRealtimeAvailable = false;
- renderKeys();
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
- putVoiceMode.mockClear();
- fireEvent.click(screen.getByRole("button", { name: /pipeline/i }));
-
- expect(putVoiceMode).toHaveBeenCalledWith("pipeline");
- });
-});
diff --git a/jarvis/ui/web/frontend/src/views/ApiKeysView.unified-model.test.tsx b/jarvis/ui/web/frontend/src/views/ApiKeysView.unified-model.test.tsx
deleted file mode 100644
index 64305670ed..0000000000
--- a/jarvis/ui/web/frontend/src/views/ApiKeysView.unified-model.test.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
-
-const setVoiceMode = vi.fn();
-
-vi.mock("@/hooks/useProviders", () => ({
- sectionHealthForSubject: () => undefined,
- useProviders: () => ({
- providers: [],
- loading: false,
- error: null,
- refetch: vi.fn(),
- setActiveOptimistic: vi.fn(),
- }),
- useSectionHealth: () => ({ health: {} }),
-}));
-
-vi.mock("@/hooks/useVoiceMode", () => ({
- useVoiceMode: () => ({
- mode: "pipeline",
- realtimeAvailable: true,
- setMode: setVoiceMode,
- isLoading: false,
- isSaving: false,
- }),
-}));
-
-import { ApiKeysView } from "@/views/ApiKeysView";
-
-afterEach(() => {
- cleanup();
- vi.clearAllMocks();
-});
-
-describe("ApiKeysView model selection", () => {
- it("uses the active voice engine without a separate computer-use model tab", () => {
- render(<ApiKeysView />);
-
- expect(screen.getByRole("tab", { name: /^brain$/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /computer.use|tool model/i })).toBeNull();
-
- fireEvent.click(screen.getByRole("button", { name: /^realtime/i }));
-
- expect(screen.getByRole("tab", { name: /^realtime$/i })).toBeTruthy();
- expect(screen.queryByRole("tab", { name: /computer.use|tool model/i })).toBeNull();
- expect(screen.queryByTestId("recommended-setup-panel")).toBeNull();
- expect(setVoiceMode).toHaveBeenCalledWith("realtime");
- });
-});