From 1fcd3bbb54122d7cbb9de1ef765eb0942a4e29ba Mon Sep 17 00:00:00 2001 From: Ouroboros <311266734+ouroboros-agent@users.noreply.github.com> Date: Mon, 12 Oct 2026 04:53:10 +0500 Subject: [PATCH] Test canonical browser opt-in in MCP import and Save Retain exact saved-server equality after browser_bridge false normalization; execute stdio-only opt-in and unchanged-metadata controls through the real UI collector. Both engine import consumers now pass after matched base/failing-merge controls. No production code, release metadata, installed target, Settings or Chrome changes. General CI failures remain attributed and unwaived. --- tests/test_mcp_headers_browser.py | 5 ++++- tests/test_mcp_ui_static.py | 34 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/test_mcp_headers_browser.py b/tests/test_mcp_headers_browser.py index 7ce0c607d..2c1069703 100644 --- a/tests/test_mcp_headers_browser.py +++ b/tests/test_mcp_headers_browser.py @@ -764,8 +764,11 @@ def test_mcp_import_replaces_legacy_ui(direct_server_with_data, loopback, engine disk = _disk(data_dir) assert disk["legacy_docs"]["headers"] == {"Authorization": BASIC, "X-Api-Key": CUSTOM} assert disk["legacy_docs"]["auth_token"] == "" and disk["legacy_docs"]["enabled"] is True + # Save normalizes every server's browser opt-in, including unselected import rows. + # HTTP entries remain ordinary MCP connections; the file cannot enable the bridge. assert disk["keep_me"] == {**seed[1], "id": "keep_me", "name": "", "command": "", "args": [], - "auth_header": "Authorization", "auth_token": "", "allowed_tools": []} + "auth_header": "Authorization", "auth_token": "", "allowed_tools": [], + "browser_bridge": False} assert disk["fresh"]["enabled"] is False and disk["fresh"]["url"].endswith("?k=synthetic-query") seen_before = len(http_app.seen) cards.nth(0).locator("[data-mcp-refresh]").click() diff --git a/tests/test_mcp_ui_static.py b/tests/test_mcp_ui_static.py index 4631c0a1a..fc0a94978 100644 --- a/tests/test_mcp_ui_static.py +++ b/tests/test_mcp_ui_static.py @@ -173,6 +173,40 @@ assert.equal(collectMcpSettings().MCP_SERVERS[0].args, 'unsupported'); assert result.returncode == 0, result.stderr +@pytest.mark.serial +@pytest.mark.parametrize("transport,opt_in,expected", [ + ("stdio", True, True), + ("stdio", False, False), + ("streamable_http", True, False), + ("sse", True, False), +]) +def test_mcp_ui_collection_keeps_browser_opt_in_stdio_only(transport, opt_in, expected): + """Run the real Save projection without dropping other server metadata.""" + script = r''' +import assert from 'node:assert/strict'; +import { applyMcpSettings, collectMcpSettings } from './web/modules/mcp_settings.js'; +const host = { innerHTML: '', querySelectorAll: () => [] }; +globalThis.document = { getElementById: (id) => id === 'mcp-servers-list' ? host : null }; +globalThis.fetch = async () => ({ ok: false }); +const [transport, optIn, expected] = JSON.parse(process.argv[1]); +const server = { id: 'kept', enabled: false, transport, command: 'python3', args: ['server.py'], + url: 'https://example.test/mcp', headers: {'X-Keep': 'literal'}, + allowed_tools: ['read'], browser_bridge: optIn, future_field: { retained: true } }; +applyMcpSettings({ MCP_SERVERS: [server] }); +const saved = collectMcpSettings().MCP_SERVERS[0]; +for (const key of Object.keys(server)) { + assert.deepEqual(saved[key], key === 'browser_bridge' ? expected : server[key], key); +} +assert.equal(Object.hasOwn(saved, 'browser_bridge'), true); +''' + import json + + result = subprocess.run([_node_bin(), '--input-type=module', '-e', script, + json.dumps([transport, opt_in, expected])], cwd=REPO_ROOT, + capture_output=True, text=True, timeout=15) + assert result.returncode == 0, result.stderr + + def test_mcp_test_button_preserves_saved_url_only_credentials(): """Exercise the registered click handler, not a copy of its payload expression.""" node = _node_bin()