From 839a3ad50c3f45771977742a81cd9928b9119f3d Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 1 Feb 2026 21:23:22 +0100 Subject: [PATCH] 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 --- tests/integration/test_files_view.py | 25 ++++---- .../test_initial_layout.svg | 62 +++++++++--------- .../test_layout_without_left_panel.svg | 62 +++++++++--------- .../test_layout_without_right_panel.svg | 62 +++++++++--------- tests/unit/test_app.py | 16 ++--- tests/unit/test_services.py | 16 +++-- tests/unit/test_widgets.py | 64 +++++++++---------- 7 files changed, 158 insertions(+), 149 deletions(-) diff --git a/tests/integration/test_files_view.py b/tests/integration/test_files_view.py index f6553ef2..cac3b507 100644 --- a/tests/integration/test_files_view.py +++ b/tests/integration/test_files_view.py @@ -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 diff --git a/tests/snapshots/__snapshots__/test_app_snapshots/test_initial_layout.svg b/tests/snapshots/__snapshots__/test_app_snapshots/test_initial_layout.svg index 433a4ce0..fb3f0e79 100644 --- a/tests/snapshots/__snapshots__/test_app_snapshots/test_initial_layout.svg +++ b/tests/snapshots/__snapshots__/test_app_snapshots/test_initial_layout.svg @@ -39,12 +39,14 @@ .terminal-r5 { fill: #494f59 } .terminal-r6 { fill: #00a3d2 } .terminal-r7 { fill: #58d1eb;font-weight: bold } -.terminal-r8 { fill: #5b616b } -.terminal-r9 { fill: #a8aeba } -.terminal-r10 { fill: #393e48 } -.terminal-r11 { fill: #0a4e66 } -.terminal-r12 { fill: #fa5f8b;font-weight: bold } -.terminal-r13 { fill: #4e535d } +.terminal-r8 { fill: #00ff00 } +.terminal-r9 { fill: #5b616b } +.terminal-r10 { fill: #4d9fb3 } +.terminal-r11 { fill: #a8aeba } +.terminal-r12 { fill: #cf8447 } +.terminal-r13 { fill: #393e48 } +.terminal-r14 { fill: #afb1b5 } +.terminal-r15 { fill: #fa5f8b;font-weight: bold } @@ -176,31 +178,31 @@ - + - + ⭘Clide — Claude Code IDE -FilesGitTreeProblemsTODOsJira -╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━ +FilesGitTreeJiraTODOs (96)Problems (1 +╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━ ▾ clide -├── ▸ dist -├── ▸ docs -├── ▸ src -├── ▸ tests -├── ◦ =0.3.0 -├── ◦ =0.8.0 -├── ◦ CLAUDE.md -├── ◦ Makefile -├── ◦ pyproject.toml -├── ◦ README.md -└── ◦ snapshot_report.htm - - - - - - +├── ▸ .claude +├── ▸ .venv +├── ▸ clideJira integration is +├── ▸ docsdisabled. +├── ▸ logs +├── ▸ testsEnable it in settings with +├── ◦ .coverageCLIDE_JIRA_ENABLED=true +├── ◦ .gitignore +├── ◦ .pre-commit-config. +├── ◦ claude-authentik-cr +├── ◦ CLAUDE.md +├── ◦ firebase-debug.log +├── ◦ Makefile +├── ◦ pyproject.toml +├── ◦ README.md +├── ◦ snapshot_report.htm +└── ◦ TODO.md @@ -217,9 +219,9 @@ -▏ -⎇m▾✓ 0 │ ☐ 39 - ^q Quit  shift+^p Commands  ^p Quick Open  ^b Toggle Sidebar  shift+^b Toggle Context  ^` Toggle Termina▏^p Quick Open + +⎇main▾unstage + alt+q Quit  alt+p Commands  alt+o Quick Open  alt+b Sidebar  alt+shift+b Context  alt+` Terminal  alt+c Compact  f11 Fu diff --git a/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_left_panel.svg b/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_left_panel.svg index 433a4ce0..fb3f0e79 100644 --- a/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_left_panel.svg +++ b/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_left_panel.svg @@ -39,12 +39,14 @@ .terminal-r5 { fill: #494f59 } .terminal-r6 { fill: #00a3d2 } .terminal-r7 { fill: #58d1eb;font-weight: bold } -.terminal-r8 { fill: #5b616b } -.terminal-r9 { fill: #a8aeba } -.terminal-r10 { fill: #393e48 } -.terminal-r11 { fill: #0a4e66 } -.terminal-r12 { fill: #fa5f8b;font-weight: bold } -.terminal-r13 { fill: #4e535d } +.terminal-r8 { fill: #00ff00 } +.terminal-r9 { fill: #5b616b } +.terminal-r10 { fill: #4d9fb3 } +.terminal-r11 { fill: #a8aeba } +.terminal-r12 { fill: #cf8447 } +.terminal-r13 { fill: #393e48 } +.terminal-r14 { fill: #afb1b5 } +.terminal-r15 { fill: #fa5f8b;font-weight: bold } @@ -176,31 +178,31 @@ - + - + ⭘Clide — Claude Code IDE -FilesGitTreeProblemsTODOsJira -╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━ +FilesGitTreeJiraTODOs (96)Problems (1 +╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━ ▾ clide -├── ▸ dist -├── ▸ docs -├── ▸ src -├── ▸ tests -├── ◦ =0.3.0 -├── ◦ =0.8.0 -├── ◦ CLAUDE.md -├── ◦ Makefile -├── ◦ pyproject.toml -├── ◦ README.md -└── ◦ snapshot_report.htm - - - - - - +├── ▸ .claude +├── ▸ .venv +├── ▸ clideJira integration is +├── ▸ docsdisabled. +├── ▸ logs +├── ▸ testsEnable it in settings with +├── ◦ .coverageCLIDE_JIRA_ENABLED=true +├── ◦ .gitignore +├── ◦ .pre-commit-config. +├── ◦ claude-authentik-cr +├── ◦ CLAUDE.md +├── ◦ firebase-debug.log +├── ◦ Makefile +├── ◦ pyproject.toml +├── ◦ README.md +├── ◦ snapshot_report.htm +└── ◦ TODO.md @@ -217,9 +219,9 @@ -▏ -⎇m▾✓ 0 │ ☐ 39 - ^q Quit  shift+^p Commands  ^p Quick Open  ^b Toggle Sidebar  shift+^b Toggle Context  ^` Toggle Termina▏^p Quick Open + +⎇main▾unstage + alt+q Quit  alt+p Commands  alt+o Quick Open  alt+b Sidebar  alt+shift+b Context  alt+` Terminal  alt+c Compact  f11 Fu diff --git a/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_right_panel.svg b/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_right_panel.svg index 433a4ce0..fb3f0e79 100644 --- a/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_right_panel.svg +++ b/tests/snapshots/__snapshots__/test_app_snapshots/test_layout_without_right_panel.svg @@ -39,12 +39,14 @@ .terminal-r5 { fill: #494f59 } .terminal-r6 { fill: #00a3d2 } .terminal-r7 { fill: #58d1eb;font-weight: bold } -.terminal-r8 { fill: #5b616b } -.terminal-r9 { fill: #a8aeba } -.terminal-r10 { fill: #393e48 } -.terminal-r11 { fill: #0a4e66 } -.terminal-r12 { fill: #fa5f8b;font-weight: bold } -.terminal-r13 { fill: #4e535d } +.terminal-r8 { fill: #00ff00 } +.terminal-r9 { fill: #5b616b } +.terminal-r10 { fill: #4d9fb3 } +.terminal-r11 { fill: #a8aeba } +.terminal-r12 { fill: #cf8447 } +.terminal-r13 { fill: #393e48 } +.terminal-r14 { fill: #afb1b5 } +.terminal-r15 { fill: #fa5f8b;font-weight: bold } @@ -176,31 +178,31 @@ - + - + ⭘Clide — Claude Code IDE -FilesGitTreeProblemsTODOsJira -╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━ +FilesGitTreeJiraTODOs (96)Problems (1 +╸━━━━━╺━━━━━━━━━━━━━━━━━━╸━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━ ▾ clide -├── ▸ dist -├── ▸ docs -├── ▸ src -├── ▸ tests -├── ◦ =0.3.0 -├── ◦ =0.8.0 -├── ◦ CLAUDE.md -├── ◦ Makefile -├── ◦ pyproject.toml -├── ◦ README.md -└── ◦ snapshot_report.htm - - - - - - +├── ▸ .claude +├── ▸ .venv +├── ▸ clideJira integration is +├── ▸ docsdisabled. +├── ▸ logs +├── ▸ testsEnable it in settings with +├── ◦ .coverageCLIDE_JIRA_ENABLED=true +├── ◦ .gitignore +├── ◦ .pre-commit-config. +├── ◦ claude-authentik-cr +├── ◦ CLAUDE.md +├── ◦ firebase-debug.log +├── ◦ Makefile +├── ◦ pyproject.toml +├── ◦ README.md +├── ◦ snapshot_report.htm +└── ◦ TODO.md @@ -217,9 +219,9 @@ -▏ -⎇m▾✓ 0 │ ☐ 39 - ^q Quit  shift+^p Commands  ^p Quick Open  ^b Toggle Sidebar  shift+^b Toggle Context  ^` Toggle Termina▏^p Quick Open + +⎇main▾unstage + alt+q Quit  alt+p Commands  alt+o Quick Open  alt+b Sidebar  alt+shift+b Context  alt+` Terminal  alt+c Compact  f11 Fu diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index e1769e02..745d7f2d 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -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: diff --git a/tests/unit/test_services.py b/tests/unit/test_services.py index d127c7d5..4f12c000 100644 --- a/tests/unit/test_services.py +++ b/tests/unit/test_services.py @@ -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 diff --git a/tests/unit/test_widgets.py b/tests/unit/test_widgets.py index a034e6f8..a8a48fc2 100644 --- a/tests/unit/test_widgets.py +++ b/tests/unit/test_widgets.py @@ -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: