fix(clients): flatten scoped remote output
- Render explicit --remote clients results with profile-only labels. - Suppress remote host group headers for scoped client queries. - Keep global and mixed client listings grouped by host. - Update client and CLI tests for scoped remote rendering. - Bump browser-cli and extension versions to 0.16.5.
This commit is contained in:
+34
-11
@@ -294,29 +294,52 @@ def test_clients_reads_registry_with_trailing_garbage(tmp_path):
|
||||
assert "0.8.2" in result.output
|
||||
|
||||
def test_clients_remote_uses_remote_endpoint_without_local_registry():
|
||||
def fake_send_command(command, args=None, profile=None, remote=None, key=None):
|
||||
assert command == "clients.list"
|
||||
assert profile is None
|
||||
assert remote == "127.0.0.1:8765"
|
||||
return [{"name": "Chrome", "version": "1", "extensionVersion": "2.3.4"}]
|
||||
target = BrowserTarget(
|
||||
profile="work",
|
||||
display_name="127.0.0.1:work",
|
||||
socket_path="",
|
||||
remote="127.0.0.1:8765",
|
||||
browser_name="Chrome",
|
||||
display_group="127.0.0.1",
|
||||
version="1",
|
||||
extension_version="2.3.4",
|
||||
)
|
||||
|
||||
with patch.dict(os.environ, {}, clear=True), patch(
|
||||
"browser_cli.commands.clients.REGISTRY_PATH", Path("/nonexistent/browser-cli-registry.json")
|
||||
), patch("browser_cli.client.core.send_command", side_effect=fake_send_command) as send_command:
|
||||
), patch("browser_cli.client.core.remote_browser_targets", return_value=[target]), patch(
|
||||
"browser_cli.client.core.send_command"
|
||||
) as send_command:
|
||||
result = CliRunner().invoke(main, ["--remote", "127.0.0.1:8765", "clients"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
send_command.assert_called_once()
|
||||
assert "remote" in result.output
|
||||
send_command.assert_not_called()
|
||||
assert "work" in result.output
|
||||
assert "127.0.0.1" not 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.client.core.send_command", return_value=[]) as send_command:
|
||||
target = BrowserTarget(
|
||||
profile="work",
|
||||
display_name="127.0.0.1:work",
|
||||
socket_path="",
|
||||
remote="127.0.0.1:8765",
|
||||
browser_name="Chrome",
|
||||
display_group="127.0.0.1",
|
||||
version="1",
|
||||
extension_version="2.3.4",
|
||||
)
|
||||
|
||||
with patch.dict(os.environ, {}, clear=True), patch(
|
||||
"browser_cli.client.core.remote_browser_targets", return_value=[target]
|
||||
), patch("browser_cli.client.core.send_command") 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", remote="127.0.0.1:8765", key=None)
|
||||
assert result.exit_code == 0
|
||||
send_command.assert_not_called()
|
||||
assert "work" in result.output
|
||||
assert "127.0.0.1" not in result.output
|
||||
|
||||
def test_clients_browser_alias_resolves_to_remote():
|
||||
"""--browser <host> without --remote resolves the alias, fetches all targets from that remote,
|
||||
|
||||
Reference in New Issue
Block a user