feat(read): target any tab for page info and extraction
- Add --tab option to all extract commands and page info - Thread tab_id through the SDK extract and page namespaces - Route page.info with a tab_id to tabs.status for cross-tab metadata - Accept tab_id in the MCP page_info, extract_text, extract_markdown tools - Forward tabId in the extension page.info and extract.html handlers - Keep the active tab as default when no tab is given - Cover tab-scoped reads in API, CLI, and MCP tests - Bump package and extension version to 0.16.7 - Refresh uv.lock with current dependency versions
This commit is contained in:
+18
-2
@@ -796,13 +796,29 @@ def test_windows_open_passes_url():
|
||||
assert "https://example.com" in result.output
|
||||
send_command.assert_called_once_with("windows.open", {"url": "https://example.com"}, profile=None, remote=None, key=None)
|
||||
|
||||
def test_page_info_command_with_tab():
|
||||
with patch("browser_cli.send_command", return_value={"title": "Example", "url": "https://example.com"}) as send_command:
|
||||
result = CliRunner().invoke(main, ["page", "info", "--tab", "42"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "Example" in result.output
|
||||
send_command.assert_called_once_with("tabs.status", {"tabId": 42}, profile=None, remote=None, key=None)
|
||||
|
||||
def test_extract_markdown_command():
|
||||
with patch("browser_cli.send_command", return_value="# Title") as send_command:
|
||||
result = CliRunner().invoke(main, ["extract", "markdown"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.output == "# Title\n"
|
||||
send_command.assert_called_once_with("extract.markdown", {"selector": None}, profile=None, remote=None, key=None)
|
||||
send_command.assert_called_once_with("extract.markdown", {"selector": None, "tabId": None}, profile=None, remote=None, key=None)
|
||||
|
||||
def test_extract_markdown_command_with_tab():
|
||||
with patch("browser_cli.send_command", return_value="# Title") as send_command:
|
||||
result = CliRunner().invoke(main, ["extract", "markdown", "--tab", "42"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.output == "# Title\n"
|
||||
send_command.assert_called_once_with("extract.markdown", {"selector": None, "tabId": 42}, profile=None, remote=None, key=None)
|
||||
|
||||
def test_extract_markdown_command_with_selector():
|
||||
with patch("browser_cli.send_command", return_value="## Post") as send_command:
|
||||
@@ -810,7 +826,7 @@ def test_extract_markdown_command_with_selector():
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.output == "## Post\n"
|
||||
send_command.assert_called_once_with("extract.markdown", {"selector": "article"}, profile=None, remote=None, key=None)
|
||||
send_command.assert_called_once_with("extract.markdown", {"selector": "article", "tabId": None}, profile=None, remote=None, key=None)
|
||||
|
||||
def test_clean_markdown_output_removes_escaped_underscores_and_dashes():
|
||||
assert _clean_markdown_output(r"hello\_world \- item") == "hello_world - item"
|
||||
|
||||
Reference in New Issue
Block a user