Enhance status display and entry details in HostsManagerApp
- Updated header title to "/etc/hosts Manager" and modified subtitle format. - Implemented a dedicated overlay status bar for error messages, ensuring no layout shifts. - Refactored entry details display to use DataTable with labeled rows for improved consistency. - Added CSS styles for the new status bar and DataTable. - Created tests for status bar visibility and DataTable functionality, ensuring all tests pass.
This commit is contained in:
parent
999b949f32
commit
25001042e5
11 changed files with 524 additions and 98 deletions
59
test_status_visibility.py
Normal file
59
test_status_visibility.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test status bar visibility by triggering an error message manually.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import patch, Mock
|
||||
from src.hosts.tui.app import HostsManagerApp
|
||||
|
||||
async def test_status_bar_visibility():
|
||||
"""Test that the status bar becomes visible when an error occurs."""
|
||||
print("Testing status bar visibility...")
|
||||
|
||||
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
|
||||
patch('hosts.tui.app.Config') as mock_config_cls:
|
||||
|
||||
# Set up mocks
|
||||
mock_parser = Mock()
|
||||
mock_config = Mock()
|
||||
mock_parser_cls.return_value = mock_parser
|
||||
mock_config_cls.return_value = mock_config
|
||||
|
||||
# Create app
|
||||
app = HostsManagerApp()
|
||||
|
||||
# Mock the query_one method to capture status bar interactions
|
||||
mock_status_bar = Mock()
|
||||
original_query_one = app.query_one
|
||||
|
||||
def mock_query_one(selector, widget_type=None):
|
||||
if selector == "#status-bar":
|
||||
return mock_status_bar
|
||||
return original_query_one(selector, widget_type)
|
||||
|
||||
app.query_one = mock_query_one
|
||||
|
||||
# Test updating status with error message
|
||||
print("🔧 Triggering error message...")
|
||||
app.update_status("❌ Test error message")
|
||||
|
||||
# Verify status bar operations
|
||||
print("✅ Status bar operations:")
|
||||
print(f" - update() called: {mock_status_bar.update.called}")
|
||||
print(f" - remove_class('hidden') called: {mock_status_bar.remove_class.called}")
|
||||
|
||||
if mock_status_bar.update.called:
|
||||
call_args = mock_status_bar.update.call_args[0]
|
||||
print(f" - Message passed: '{call_args[0]}'")
|
||||
|
||||
# Test clearing status
|
||||
print("\n🔧 Clearing status message...")
|
||||
app._clear_status_message()
|
||||
|
||||
print("✅ Clear operations:")
|
||||
print(f" - update('') called: {mock_status_bar.update.call_count > 1}")
|
||||
print(f" - add_class('hidden') called: {mock_status_bar.add_class.called}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_status_bar_visibility())
|
Loading…
Add table
Add a link
Reference in a new issue