The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(settings): cover McpServerPanel's per-OS config paths and embedded mode\n\nThe sibling spec runs every case on macOS (its fixture hardcodes\n`os: 'macos'`), so `configFilePathFor`'s Windows and Linux arms were\nnever executed — lines 59-64 and 67-68, which is why the panel sat at\n68.18% branch coverage. Line 269, the `embedded` wrapper, was unreached\nfor the same reason: nothing rendered the panel with the prop.\n\nThese paths deserve pinning rather than eyeballing. The string is what\nthe "Config file" row shows and what a user is told to edit by hand; a\nwrong one sends them to a file that does not exist and nothing errors,\nbecause the value is only ever displayed. The four clients branch in\nthree different shapes — claude-desktop and zed have three arms each,\ncursor two, codex one — so the table is easy to get subtly wrong.\n\nSix cases in a new spec file: the macOS Application Support locations,\nthe Windows %APPDATA% / %USERPROFILE% backslash paths, the Linux\n~/.config fallthrough, codex asserted OS-independent, an unrecognised OS\nfalling through to Linux rather than rendering blank, and the embedded\nrender.\n\nCoverage: 84.84 -> 98.48% statements, 68.18 -> 88.63% branches,\n88.33 -> 100% lines.\n\nVerified by mutation, one arm at a time: deleting claude-desktop's and\ncursor's Windows returns, zed's macOS return, making codex OS-dependent,\nand widening isMac to `os !== 'windows'` each turned the matching test\nred.\n\nThe embedded case needed rewriting to survive that check. Asserting only\nthat the description was ABSENT when embedded passed even with the\n`embedded` branch deleted — the string it searched for was wrong, so it\nwas never present in either mode, and a negative assertion alone cannot\ndistinguish "correctly hidden" from "never rendered". It now asserts the\ndescription IS rendered normally and is NOT rendered when embedded.\n
M3gA-Mindeee6200b4608
diff --git a/app/src/components/settings/panels/__tests__/McpServerPanel.osPaths.test.tsx b/app/src/components/settings/panels/__tests__/McpServerPanel.osPaths.test.tsxnew file mode 100644index 0000000000..388a0907cb--- /dev/null+++ b/app/src/components/settings/panels/__tests__/McpServerPanel.osPaths.test.tsx@@ -0,0 +1,157 @@+/**+ * McpServerPanel — the per-OS config-file path table, and the embedded render.+ *+ * The sibling `McpServerPanel.test.tsx` runs every case on macOS+ * (`DEFAULT_BINARY_INFO = { os: 'macos' }`), so `configFilePathFor`'s Windows+ * and Linux branches were unexecuted — lines 59-64 and 67-68, the reason the+ * panel sat at 68.18% branch coverage. Line 269, the `embedded` wrapper, was+ * unreached for the same reason: nothing rendered the panel with the prop.+ *+ * These paths are worth pinning rather than eyeballing. The path is what the+ * "Open config file" row shows and what a user is told to edit by hand; a wrong+ * one sends them to a file that does not exist, and nothing errors — the string+ * is just displayed. `configFilePathFor` is a pure `switch` with no test, and+ * three of its four clients branch on OS in different shapes: `claude-desktop`+ * and `zed` have three arms each, `cursor` has two, `codex` has one.+ */+import { cleanup, screen, waitFor } from '@testing-library/react';+import { beforeEach, describe, expect, test, vi } from 'vitest';++import { renderWithProviders } from '../../../../test/test-utils';++const hoisted = vi.hoisted(() => ({ invoke: vi.fn(), isTauri: vi.fn(() => true) }));++vi.mock('../../../../utils/tauriCommands/common', () => ({+ isTauri: hoisted.isTauri,+ safeInvoke: (...args: unknown[]) => hoisted.invoke(...args),+}));++vi.mock('../../hooks/useSettingsNavigation', () => ({+ useSettingsNavigation: () => ({+ navigateBack: vi.fn(),+ navigateToSettings: vi.fn(),+ breadcrumbs: [],+ }),+}));++const BINARY_PATH = '/usr/local/bin/openhuman-core';++async function importPanel() {+ const mod = await import('../McpServerPanel');+ return mod.default;+}++/** Render with the resolver reporting a given OS, then wait for first paint. */+async function renderForOs(os: string, props: { embedded?: boolean } = {}) {+ hoisted.invoke.mockResolvedValue({ path: BINARY_PATH, os });+ const Panel = await importPanel();+ renderWithProviders(<Panel {...props} />);+ await waitFor(() =>+ expect(screen.getByRole('tab', { name: /Claude Desktop/i })).toBeInTheDocument()+ );+}++/** Switch to a client tab and read back the config path the panel displays. */+async function pathForClient(name: RegExp): Promise<string> {+ const tab = screen.getByRole('tab', { name });+ tab.click();+ await waitFor(() => expect(tab).toHaveAttribute('aria-selected', 'true'));+ // Anchor on the "Config file:" label and read its sibling, rather than a CSS+ // class — the panel renders several font-mono spans (tool names, the JSON+ // snippet) and a class-based selector picks up the first of them.+ const label = screen.getByText('Config file:');+ const value = label.nextElementSibling;+ expect(value, 'the config path should sit beside its label').not.toBeNull();+ return value!.textContent ?? '';+}++beforeEach(() => {+ vi.resetModules();+ hoisted.invoke.mockReset();+ hoisted.isTauri.mockReset();+ hoisted.isTauri.mockReturnValue(true);+});++describe('<McpServerPanel /> config paths per OS', () => {+ test('macOS uses the Application Support locations', async () => {+ await renderForOs('macos');+ expect(await pathForClient(/Claude Desktop/i)).toBe(+ '~/Library/Application Support/Claude/claude_desktop_config.json'+ );+ expect(await pathForClient(/Zed/i)).toBe('~/Library/Application Support/Zed/settings.json');+ });++ test('Windows uses %APPDATA% / %USERPROFILE% with backslashes', async () => {+ // The Windows arms are the ones the macOS-only sibling never reached. Note+ // these are backslash paths — asserting the exact string is the point,+ // since a forward-slash regression would still "look like a path".+ await renderForOs('windows');+ expect(await pathForClient(/Claude Desktop/i)).toBe(+ '%APPDATA%\\Claude\\claude_desktop_config.json'+ );+ expect(await pathForClient(/Cursor/i)).toBe('%USERPROFILE%\\.cursor\\mcp.json');+ expect(await pathForClient(/Zed/i)).toBe('%APPDATA%\\Zed\\settings.json');+ });++ test('Linux falls through to the XDG-style ~/.config locations', async () => {+ // Linux is the `return` after both guards — reached by any os that is+ // neither 'macos' nor 'windows'.+ await renderForOs('linux');+ expect(await pathForClient(/Claude Desktop/i)).toBe(+ '~/.config/Claude/claude_desktop_config.json'+ );+ expect(await pathForClient(/Cursor/i)).toBe('~/.cursor/mcp.json');+ expect(await pathForClient(/Zed/i)).toBe('~/.config/zed/settings.json');+ });++ test('codex is OS-independent', async () => {+ // The one client with a single arm: its path must not vary with the OS.+ // Pinning this stops a future edit from "helpfully" adding branches that+ // disagree with where codex actually reads its config.+ await renderForOs('windows');+ expect(await pathForClient(/Codex/i)).toBe('~/.codex/config.json');++ // Tear the first tree down before mounting the second — otherwise both+ // panels are in the document and the label lookup matches two nodes.+ cleanup();+ vi.resetModules();+ await renderForOs('linux');+ expect(await pathForClient(/Codex/i)).toBe('~/.codex/config.json');+ });++ test('an unrecognised OS is treated as Linux rather than blank', async () => {+ // `configFilePathFor` has no default arm per OS — anything not macOS and+ // not Windows takes the final return. A future refactor that returned+ // undefined here would render an empty path with no error.+ await renderForOs('freebsd');+ expect(await pathForClient(/Claude Desktop/i)).toBe(+ '~/.config/Claude/claude_desktop_config.json'+ );+ });++ test('renders the settings description normally but omits it when embedded', async () => {+ // Line 269 — the Connections surface embeds this panel. Both directions+ // are asserted on purpose: an earlier draft only checked that the+ // description was ABSENT when embedded, which passed even with the+ // `embedded` branch deleted, because the string it looked for was wrong+ // and so never present in either mode. A negative assertion alone cannot+ // tell "correctly hidden" from "never rendered".+ const DESCRIPTION = 'Configure external MCP clients to connect to OpenHuman';++ await renderForOs('macos');+ expect(+ screen.getByText(DESCRIPTION),+ 'the settings scaffold renders the panel description'+ ).toBeInTheDocument();++ cleanup();+ vi.resetModules();++ await renderForOs('macos', { embedded: true });+ expect(screen.getByRole('tab', { name: /Claude Desktop/i })).toBeInTheDocument();+ expect(+ screen.queryByText(DESCRIPTION),+ 'embedded mode uses PanelPage, which must not repeat the settings subtitle'+ ).not.toBeInTheDocument();+ });+});