fix: progress broadcasts now use correct WebSocket room names

- Fixed room name mismatch: ProgressService was broadcasting to
  'download_progress' but JS clients join 'downloads' room
- Added _get_room_for_progress_type() mapping function
- Updated all progress methods to use correct room names
- Added 13 new tests for room name mapping and broadcast verification
- Updated existing tests to expect correct room names
- Fixed JS clients to join valid rooms (downloads, queue, scan)
This commit is contained in:
2025-12-16 19:21:30 +01:00
parent 4c9bf6b982
commit 700f491ef9
7 changed files with 490 additions and 17 deletions

View File

@@ -180,9 +180,9 @@ class TestDownloadProgressIntegration:
connection_id = "test_client_1"
await websocket_service.connect(mock_ws, connection_id)
# Join the queue_progress room to receive queue updates
# Join the queue room to receive queue updates
await websocket_service.manager.join_room(
connection_id, "queue_progress"
connection_id, "queue"
)
# Subscribe to progress events and forward to WebSocket
@@ -254,12 +254,12 @@ class TestDownloadProgressIntegration:
await websocket_service.connect(client1, "client1")
await websocket_service.connect(client2, "client2")
# Join both clients to the queue_progress room
# Join both clients to the queue room
await websocket_service.manager.join_room(
"client1", "queue_progress"
"client1", "queue"
)
await websocket_service.manager.join_room(
"client2", "queue_progress"
"client2", "queue"
)
# Subscribe to progress events and forward to WebSocket

View File

@@ -325,8 +325,9 @@ class TestWebSocketScanIntegration:
assert len(broadcasts) >= 2 # At least start and complete
# Check for scan progress broadcasts
# Room name is 'scan' for SCAN type progress
scan_broadcasts = [
b for b in broadcasts if b["room"] == "scan_progress"
b for b in broadcasts if b["room"] == "scan"
]
assert len(scan_broadcasts) >= 2
@@ -379,8 +380,9 @@ class TestWebSocketScanIntegration:
await anime_service.rescan()
# Verify failure broadcast
# Room name is 'scan' for SCAN type progress
scan_broadcasts = [
b for b in broadcasts if b["room"] == "scan_progress"
b for b in broadcasts if b["room"] == "scan"
]
assert len(scan_broadcasts) >= 2 # Start and fail
@@ -438,7 +440,7 @@ class TestWebSocketProgressIntegration:
start_broadcast = broadcasts[0]
assert start_broadcast["data"]["status"] == "started"
assert start_broadcast["room"] == "download_progress"
assert start_broadcast["room"] == "downloads" # Room name for DOWNLOAD type
update_broadcast = broadcasts[1]
assert update_broadcast["data"]["status"] == "in_progress"