refactor: modularize auth transport and markdown
Testing / remote-protocol-compat (0.9.5) (push) Successful in 1m4s
Testing / test (push) Successful in 1m22s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 1m7s
Package Extension / package-extension (push) Successful in 1m1s
Build & Publish Package / publish (push) Successful in 1m5s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 1m4s
Testing / test (push) Successful in 1m22s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 1m7s
Package Extension / package-extension (push) Successful in 1m1s
Build & Publish Package / publish (push) Successful in 1m5s
- Split auth into focused package modules for agent keys, file keys, signing, and post-quantum transport helpers while keeping the public browser_cli.auth import surface intact. - Move transport encoding internals into a package with separate codec and binary-hoisting helpers, preserving browser_cli.transport compatibility. - Extract remote TCP auth/socket helpers and serve challenge setup out of the runtime paths to make connection handling easier to reason about. - Move the extension markdown extractor into a dedicated content/markdown folder with separate root selection, code normalization, renderer, and utils. - Centralize CLI Rich rendering helpers for tab/window tree and table output, and add rendering tests for the shared builders. - Remove local typing ignores in SDK/decorator/script plumbing and bump the package and extension version to 0.15.3.
This commit is contained in:
@@ -3,6 +3,7 @@ from os import terminal_size
|
||||
from rich.console import Console
|
||||
from rich.tree import Tree
|
||||
|
||||
from browser_cli.models import Tab
|
||||
from browser_cli.commands import rendering
|
||||
|
||||
def test_shorten_uses_ellipsis():
|
||||
@@ -32,3 +33,33 @@ def test_print_tree_uses_detected_width(monkeypatch):
|
||||
monkeypatch.setattr(rendering, "terminal_width", lambda console=None: 132)
|
||||
rendering.print_tree(Tree("Root"))
|
||||
assert widths == [132]
|
||||
|
||||
def test_build_tabs_tree_groups_by_browser_window_and_group():
|
||||
tabs = [
|
||||
Tab(id=1, window_id=5, active=False, muted=False, title="Before", url="https://example.com/before", group_id=None, index=0, browser="work"),
|
||||
Tab(id=2, window_id=5, active=False, muted=False, title="Inside", url="https://example.com/inside", group_id=9, index=1, browser="work"),
|
||||
]
|
||||
groups = [{"id": 9, "windowId": 5, "browser": "work", "title": "Research", "color": "blue", "tabCount": 1, "collapsed": True}]
|
||||
tree = rendering.build_tabs_tree(tabs, groups, console=Console(width=120), show_urls=True)
|
||||
text = "\n".join(str(line) for line in tree.__rich_console__(Console(width=120), Console(width=120).options))
|
||||
assert "work" in text
|
||||
assert "Window 5" in text
|
||||
assert "Research" in text
|
||||
assert "collapsed" in text
|
||||
assert "Inside" in text
|
||||
|
||||
def test_build_windows_tree_keeps_multi_browser_windows_separate():
|
||||
tabs = [
|
||||
Tab(id=1, window_id=5, active=False, muted=False, title="Work Tab", url="https://example.com/work", index=0, browser="work"),
|
||||
Tab(id=2, window_id=5, active=False, muted=False, title="Personal Tab", url="https://example.com/personal", index=0, browser="personal"),
|
||||
]
|
||||
windows = [
|
||||
{"id": 5, "alias": "main", "browser": "work", "tabCount": 1, "state": "normal"},
|
||||
{"id": 5, "alias": "main", "browser": "personal", "tabCount": 1, "state": "normal"},
|
||||
]
|
||||
tree = rendering.build_windows_tree(windows, tabs, console=Console(width=120))
|
||||
text = "\n".join(str(line) for line in tree.__rich_console__(Console(width=120), Console(width=120).options))
|
||||
assert "work: Window 5" in text
|
||||
assert "personal: Window 5" in text
|
||||
assert "Work Tab" in text
|
||||
assert "Personal Tab" in text
|
||||
|
||||
Reference in New Issue
Block a user