test: update tests and snapshots for widget changes
Update test fixtures and snapshots to reflect TileList component and panel widget refactoring. Adjust integration tests for new file browser behavior. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
6293b93d98
commit
839a3ad50c
@@ -47,7 +47,7 @@ def test_directory(tmp_path: Path) -> Path:
|
||||
async def test_files_view_renders(test_directory: Path):
|
||||
"""Test that FilesView renders without errors."""
|
||||
app = FilesViewTestApp(test_directory)
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
files_view = app.query_one("#files", FilesView)
|
||||
assert files_view is not None
|
||||
assert files_view.path == test_directory
|
||||
@@ -56,7 +56,7 @@ async def test_files_view_renders(test_directory: Path):
|
||||
async def test_files_view_shows_files(test_directory: Path):
|
||||
"""Test that FilesView shows files in the directory."""
|
||||
app = FilesViewTestApp(test_directory)
|
||||
async with app.run_test() as pilot:
|
||||
async with app.run_test():
|
||||
files_view = app.query_one("#files", FilesView)
|
||||
# The root should be loaded
|
||||
assert files_view.root is not None
|
||||
@@ -104,9 +104,9 @@ async def test_file_click_emits_event(test_directory: Path):
|
||||
assert any(p.name == "README.md" for p in app.selected_files)
|
||||
|
||||
|
||||
async def test_filter_paths_hides_hidden_files(test_directory: Path):
|
||||
"""Test that hidden files are filtered out."""
|
||||
# Create hidden files/dirs
|
||||
async def test_filter_paths_hides_noisy_dirs(test_directory: Path):
|
||||
"""Test that noisy directories are filtered but hidden files are shown."""
|
||||
# Create hidden files/dirs and noisy dirs
|
||||
(test_directory / ".git").mkdir()
|
||||
(test_directory / ".hidden_file").write_text("hidden")
|
||||
(test_directory / "__pycache__").mkdir()
|
||||
@@ -118,16 +118,17 @@ async def test_filter_paths_hides_hidden_files(test_directory: Path):
|
||||
# Wait for initial load
|
||||
await pilot.pause()
|
||||
|
||||
# Check that hidden items are not in the tree
|
||||
visible_names = {
|
||||
node.data.path.name
|
||||
for node in files_view.root.children
|
||||
if node.data
|
||||
}
|
||||
# Get visible items in the tree
|
||||
visible_names = {node.data.path.name for node in files_view.root.children if node.data}
|
||||
|
||||
# Noisy directories should be filtered out
|
||||
assert ".git" not in visible_names
|
||||
assert ".hidden_file" not in visible_names
|
||||
assert "__pycache__" not in visible_names
|
||||
|
||||
# Hidden files are shown (they'll be dimmed in the UI)
|
||||
assert ".hidden_file" in visible_names
|
||||
|
||||
# Regular files/dirs are shown
|
||||
assert "src" in visible_names
|
||||
assert "README.md" in visible_names
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 39 KiB |
+32
-30
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 39 KiB |
+32
-30
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 39 KiB |
@@ -75,14 +75,14 @@ class TestClideAppBindings:
|
||||
app = ClideApp()
|
||||
bindings = {b.key for b in app.BINDINGS}
|
||||
|
||||
# Check key bindings exist
|
||||
assert "ctrl+q" in bindings
|
||||
assert "ctrl+b" in bindings
|
||||
assert "ctrl+shift+p" in bindings
|
||||
assert "ctrl+`" in bindings
|
||||
assert "ctrl+1" in bindings
|
||||
assert "f11" in bindings
|
||||
assert "escape" in bindings
|
||||
# Check key bindings exist (alt-based per CLAUDE.md design)
|
||||
assert "alt+q" in bindings # Quit
|
||||
assert "alt+b" in bindings # Toggle sidebar
|
||||
assert "alt+p" in bindings # Command palette
|
||||
assert "alt+`" in bindings # Toggle terminal
|
||||
assert "alt+1" in bindings # Focus Claude
|
||||
assert "f11" in bindings # Fullscreen
|
||||
assert "escape" in bindings # Exit fullscreen
|
||||
|
||||
|
||||
class TestClideAppMeta:
|
||||
|
||||
@@ -68,20 +68,20 @@ class TestFileService:
|
||||
test_file.write_text("Hello, World!")
|
||||
|
||||
service = FileService(tmp_path)
|
||||
content = await service.read_file(test_file)
|
||||
content = await service.read_file_async(test_file)
|
||||
assert content == "Hello, World!"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_read_file_not_found(self, tmp_path: Path):
|
||||
service = FileService(tmp_path)
|
||||
with pytest.raises(FileNotFoundError):
|
||||
await service.read_file(tmp_path / "nonexistent.txt")
|
||||
await service.read_file_async(tmp_path / "nonexistent.txt")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_write_file(self, tmp_path: Path):
|
||||
test_file = tmp_path / "output.txt"
|
||||
service = FileService(tmp_path)
|
||||
await service.write_file(test_file, "Test content")
|
||||
await service.write_file_async(test_file, "Test content")
|
||||
assert test_file.read_text() == "Test content"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -97,7 +97,7 @@ class TestFileService:
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_language_typescript(self, tmp_path: Path):
|
||||
service = FileService(tmp_path)
|
||||
assert await service.get_language(Path("component.tsx")) == "tsx"
|
||||
assert await service.get_language(Path("component.tsx")) == "typescript"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_language_unknown(self, tmp_path: Path):
|
||||
@@ -129,12 +129,14 @@ class TestGitService:
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_status(self, service: GitService):
|
||||
with patch.object(service._process, "run") as mock_run:
|
||||
async def mock_status(*args, **kwargs):
|
||||
|
||||
async def mock_status(*args, **_kwargs):
|
||||
if "status" in args:
|
||||
return CommandResult(returncode=0, stdout="", stderr="")
|
||||
elif "branch" in args:
|
||||
return CommandResult(returncode=0, stdout="main\n", stderr="")
|
||||
return CommandResult(returncode=0, stdout="0\t0", stderr="")
|
||||
|
||||
mock_run.side_effect = mock_status
|
||||
status = await service.get_status()
|
||||
assert status is not None
|
||||
@@ -252,7 +254,7 @@ def main():
|
||||
@pytest.mark.asyncio
|
||||
async def test_scan_finds_todos(self, project_with_todos: Path):
|
||||
scanner = TodoScanner(project_with_todos)
|
||||
items, summary = await scanner.scan()
|
||||
items, project_items, summary = await scanner.scan()
|
||||
# Should find TODO, FIXME, and HACK
|
||||
assert len(items) >= 1
|
||||
assert summary.total >= 1
|
||||
@@ -260,7 +262,7 @@ def main():
|
||||
@pytest.mark.asyncio
|
||||
async def test_scan_empty_project(self, tmp_path: Path):
|
||||
scanner = TodoScanner(tmp_path)
|
||||
items, summary = await scanner.scan()
|
||||
items, project_items, summary = await scanner.scan()
|
||||
assert items == []
|
||||
assert summary.total == 0
|
||||
|
||||
|
||||
+32
-32
@@ -13,29 +13,34 @@ from clide.models.todos import TodoItem, TodoType
|
||||
class TestFilesView:
|
||||
"""Tests for FilesView component."""
|
||||
|
||||
def test_filter_paths_excludes_hidden(self, tmp_path: Path):
|
||||
"""Test that hidden files are filtered out."""
|
||||
def test_filter_paths_excludes_noisy_dirs(self, tmp_path: Path):
|
||||
"""Test that noisy directories are filtered out but hidden files are shown."""
|
||||
from clide.widgets.components.files_view import FilesView
|
||||
|
||||
view = FilesView(path=tmp_path)
|
||||
paths = [
|
||||
tmp_path / "visible.py",
|
||||
tmp_path / ".hidden",
|
||||
tmp_path / ".git",
|
||||
tmp_path / "__pycache__",
|
||||
tmp_path / "node_modules",
|
||||
tmp_path / ".venv",
|
||||
tmp_path / ".hidden", # Hidden file - shown (dimmed)
|
||||
tmp_path / ".git", # Noisy dir - filtered
|
||||
tmp_path / "__pycache__", # Noisy dir - filtered
|
||||
tmp_path / "node_modules", # Noisy dir - filtered
|
||||
tmp_path / ".venv", # Dimmed path - shown (dimmed)
|
||||
tmp_path / "src",
|
||||
]
|
||||
filtered = view.filter_paths(paths)
|
||||
|
||||
# Regular files/dirs are shown
|
||||
assert tmp_path / "visible.py" in filtered
|
||||
assert tmp_path / "src" in filtered
|
||||
assert tmp_path / ".hidden" not in filtered
|
||||
|
||||
# Hidden files are shown (will be dimmed in render)
|
||||
assert tmp_path / ".hidden" in filtered
|
||||
assert tmp_path / ".venv" in filtered
|
||||
|
||||
# Noisy directories are filtered out
|
||||
assert tmp_path / ".git" not in filtered
|
||||
assert tmp_path / "__pycache__" not in filtered
|
||||
assert tmp_path / "node_modules" not in filtered
|
||||
assert tmp_path / ".venv" not in filtered
|
||||
|
||||
def test_file_selected_message(self):
|
||||
"""Test FileSelected message."""
|
||||
@@ -150,14 +155,11 @@ class TestGitGraphView:
|
||||
assert len(view._commits) == 1
|
||||
|
||||
def test_graph_symbols(self):
|
||||
"""Test graph drawing symbols."""
|
||||
from clide.widgets.components.git_graph import GitGraphView
|
||||
"""Test graph drawing symbols in CommitItem."""
|
||||
from clide.widgets.components.git_graph import CommitItem
|
||||
|
||||
assert GitGraphView.COMMIT == "●"
|
||||
assert GitGraphView.MERGE == "◆"
|
||||
assert GitGraphView.LINE == "│"
|
||||
assert GitGraphView.BRANCH == "├"
|
||||
assert GitGraphView.JOIN == "┴"
|
||||
assert CommitItem.COMMIT == "●"
|
||||
assert CommitItem.MERGE == "◆"
|
||||
|
||||
def test_commit_selected_message(self):
|
||||
"""Test CommitSelected message."""
|
||||
@@ -173,11 +175,10 @@ class TestGitGraphView:
|
||||
msg = GitGraphView.CommitSelected(commit)
|
||||
assert msg.commit == commit
|
||||
|
||||
def test_format_commit_line(self):
|
||||
"""Test commit line formatting."""
|
||||
from clide.widgets.components.git_graph import GitGraphView
|
||||
def test_commit_item_stores_commit(self):
|
||||
"""Test CommitItem stores commit correctly."""
|
||||
from clide.widgets.components.git_graph import CommitItem
|
||||
|
||||
view = GitGraphView()
|
||||
commit = GitCommit(
|
||||
hash="abc123def456789",
|
||||
short_hash="abc123",
|
||||
@@ -187,16 +188,15 @@ class TestGitGraphView:
|
||||
is_merge=False,
|
||||
refs=(),
|
||||
)
|
||||
line = view._format_commit_line(commit)
|
||||
assert "abc123" in line
|
||||
assert "Test commit message" in line
|
||||
assert "Author" in line
|
||||
item = CommitItem(commit)
|
||||
assert item.commit == commit
|
||||
assert item.commit.short_hash == "abc123"
|
||||
assert item.commit.message == "Test commit message"
|
||||
|
||||
def test_format_merge_commit_line(self):
|
||||
"""Test merge commit line formatting."""
|
||||
from clide.widgets.components.git_graph import GitGraphView
|
||||
def test_commit_item_merge_commit(self):
|
||||
"""Test CommitItem handles merge commit."""
|
||||
from clide.widgets.components.git_graph import CommitItem
|
||||
|
||||
view = GitGraphView()
|
||||
commit = GitCommit(
|
||||
hash="abc123def456789",
|
||||
short_hash="abc123",
|
||||
@@ -206,10 +206,10 @@ class TestGitGraphView:
|
||||
is_merge=True,
|
||||
refs=("main", "HEAD"),
|
||||
)
|
||||
line = view._format_commit_line(commit)
|
||||
assert "◆" in line # Merge symbol
|
||||
assert "main" in line
|
||||
assert "HEAD" in line
|
||||
item = CommitItem(commit)
|
||||
assert item.commit.is_merge is True
|
||||
assert "main" in item.commit.refs
|
||||
assert "HEAD" in item.commit.refs
|
||||
|
||||
|
||||
class TestBranchStatus:
|
||||
|
||||
Reference in New Issue
Block a user