fix remote clients command
Testing / test (push) Successful in 25s
Package Extension / package-extension (push) Successful in 9s
Build & Publish Package / publish (push) Successful in 21s

This commit is contained in:
2026-04-30 13:49:32 +02:00
parent 6785b9f70c
commit 2f982fa714
5 changed files with 63 additions and 22 deletions
+27
View File
@@ -1,5 +1,6 @@
from pathlib import Path
from types import SimpleNamespace
import os
import sys
from click.testing import CliRunner
@@ -140,6 +141,32 @@ def test_clients_exits_cleanly_when_registry_is_missing():
assert result.exit_code == 1
assert "No browser clients found" in result.output
def test_clients_remote_uses_remote_endpoint_without_local_registry():
def fake_send_command(command, args=None, profile=None):
assert command == "clients.list"
assert profile is None
return [{"name": "Chrome", "version": "1", "extensionVersion": "2.3.4"}]
with patch.dict(os.environ, {}, clear=True), patch(
"browser_cli.cli.REGISTRY_PATH", Path("/nonexistent/browser-cli-registry.json")
), patch("browser_cli.cli.send_command", side_effect=fake_send_command) as send_command:
result = CliRunner().invoke(main, ["--remote", "127.0.0.1:8765", "--token", "test", "clients"])
assert result.exit_code == 0
send_command.assert_called_once()
assert "remote" in result.output
assert "Chrome" in result.output
assert "2.3.4" in result.output
def test_clients_remote_respects_global_browser_route():
with patch.dict(os.environ, {}, clear=True), patch("browser_cli.cli.send_command", return_value=[]) as send_command:
result = CliRunner().invoke(main, ["--remote", "127.0.0.1:8765", "--browser", "work", "clients"])
assert result.exit_code == 1
send_command.assert_called_once_with("clients.list", profile="work")
def test_clients_shows_named_profile_and_uses_socket_uuid_for_default(tmp_path):
registry_path = tmp_path / "registry.json"
default_socket = tmp_path / "550e8400-e29b-41d4-a716-446655440000.sock"