fix: make navigation no-focus by default
- Change nav open and open-wait to avoid activating newly created tabs unless --focus is explicitly requested. - Send background=true for default opens so older or remote extensions also avoid stealing focus even if they ignore the new focus flag. - Remove the redundant --bg flag from navigation and search CLI commands now that no-focus/background behavior is the default. - Thread focus support through the sync SDK, async SDK, tab helpers, and workflow decorators. - Update README and demo usage to document the new default and --focus opt-in. - Bump package and extension metadata to 0.12.3. - Add regression coverage for CLI help, wire payloads, and extension behavior.
This commit is contained in:
@@ -346,14 +346,43 @@ def test_cli_perf_profile_ultra():
|
||||
from browser_cli.commands.navigate import nav_group
|
||||
|
||||
def test_cli_nav_open():
|
||||
result = _run(nav_group, ["open", "https://example.com"], {"id": 42, "url": "https://example.com"})
|
||||
assert result.exit_code == 0
|
||||
assert "Opened" in result.output
|
||||
with patch("browser_cli.send_command", return_value={"id": 42, "url": "https://example.com"}) as send_command:
|
||||
result = CliRunner().invoke(nav_group, ["open", "https://example.com"])
|
||||
|
||||
def test_cli_nav_open_bg():
|
||||
result = _run(nav_group, ["open", "https://example.com", "--bg"], {"id": 42})
|
||||
assert result.exit_code == 0
|
||||
assert "Opened" in result.output
|
||||
send_command.assert_called_once_with(
|
||||
"navigate.open",
|
||||
{"url": "https://example.com", "background": True, "focus": False, "window": None, "group": None},
|
||||
profile=None,
|
||||
remote=None,
|
||||
key=None,
|
||||
)
|
||||
|
||||
def test_cli_nav_open_has_no_bg_option():
|
||||
result = CliRunner().invoke(nav_group, ["open", "--help"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "--bg" not in result.output
|
||||
|
||||
def test_cli_nav_open_wait_has_no_bg_option():
|
||||
result = CliRunner().invoke(nav_group, ["open-wait", "--help"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "--bg" not in result.output
|
||||
|
||||
def test_cli_nav_open_focus_is_explicit():
|
||||
with patch("browser_cli.send_command", return_value={"id": 42}) as send_command:
|
||||
result = CliRunner().invoke(nav_group, ["open", "https://example.com", "--focus"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
send_command.assert_called_once_with(
|
||||
"navigate.open",
|
||||
{"url": "https://example.com", "background": False, "focus": True, "window": None, "group": None},
|
||||
profile=None,
|
||||
remote=None,
|
||||
key=None,
|
||||
)
|
||||
|
||||
def test_cli_nav_open_with_group():
|
||||
result = _run(nav_group, ["open", "https://example.com", "--group", "work"], {"id": 42})
|
||||
@@ -412,6 +441,18 @@ def test_cli_nav_wait():
|
||||
assert result.exit_code == 0
|
||||
assert "Ready" in result.output
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# search commands
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from browser_cli.commands.search import search_group
|
||||
|
||||
def test_cli_search_has_no_bg_option():
|
||||
result = CliRunner().invoke(search_group, ["google", "--help"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "--bg" not in result.output
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# navigate commands — with tab_id argument
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user