Show total items to scan in progress overlay

- Add total_items parameter to broadcast_scan_started and broadcast_scan_progress
- Pass total from SeriesApp to WebSocket broadcasts in AnimeService
- Update JS overlay to show progress bar and current/total count
- Add CSS for progress bar styling
- Add unit tests for new total_items parameter
- All 1024 tests passing
This commit is contained in:
2025-12-24 20:54:27 +01:00
parent a24f07a36e
commit 72ac201153
10 changed files with 212 additions and 16 deletions

View File

@@ -438,6 +438,23 @@ class TestWebSocketService:
"""Test broadcasting scan started event."""
connection_id = "test-conn"
directory = "/home/user/anime"
total_items = 42
await service.connect(mock_websocket, connection_id)
await service.broadcast_scan_started(directory, total_items)
assert mock_websocket.send_json.called
call_args = mock_websocket.send_json.call_args[0][0]
assert call_args["type"] == "scan_started"
assert call_args["data"]["directory"] == directory
assert call_args["data"]["total_items"] == total_items
assert "timestamp" in call_args
@pytest.mark.asyncio
async def test_broadcast_scan_started_default_total(self, service, mock_websocket):
"""Test broadcasting scan started event with default total_items."""
connection_id = "test-conn"
directory = "/home/user/anime"
await service.connect(mock_websocket, connection_id)
await service.broadcast_scan_started(directory)
@@ -446,6 +463,7 @@ class TestWebSocketService:
call_args = mock_websocket.send_json.call_args[0][0]
assert call_args["type"] == "scan_started"
assert call_args["data"]["directory"] == directory
assert call_args["data"]["total_items"] == 0
assert "timestamp" in call_args
@pytest.mark.asyncio
@@ -455,6 +473,29 @@ class TestWebSocketService:
directories_scanned = 25
files_found = 150
current_directory = "/home/user/anime/Attack on Titan"
total_items = 100
await service.connect(mock_websocket, connection_id)
await service.broadcast_scan_progress(
directories_scanned, files_found, current_directory, total_items
)
assert mock_websocket.send_json.called
call_args = mock_websocket.send_json.call_args[0][0]
assert call_args["type"] == "scan_progress"
assert call_args["data"]["directories_scanned"] == directories_scanned
assert call_args["data"]["files_found"] == files_found
assert call_args["data"]["current_directory"] == current_directory
assert call_args["data"]["total_items"] == total_items
assert "timestamp" in call_args
@pytest.mark.asyncio
async def test_broadcast_scan_progress_default_total(self, service, mock_websocket):
"""Test broadcasting scan progress event with default total_items."""
connection_id = "test-conn"
directories_scanned = 25
files_found = 150
current_directory = "/home/user/anime/Attack on Titan"
await service.connect(mock_websocket, connection_id)
await service.broadcast_scan_progress(
@@ -467,6 +508,7 @@ class TestWebSocketService:
assert call_args["data"]["directories_scanned"] == directories_scanned
assert call_args["data"]["files_found"] == files_found
assert call_args["data"]["current_directory"] == current_directory
assert call_args["data"]["total_items"] == 0
assert "timestamp" in call_args
@pytest.mark.asyncio