mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-04 18:06:48 +00:00
test: fix WebSocket chat tests using async approach
Replaced TestClient-based tests with proper async WebSocket testing using httpx_ws and threaded server pattern. TestClient has event loop issues with WebSocket connections that were causing all tests to fail. Changes: - Rewrote all WebSocket tests to use aconnect_ws from httpx_ws - Added chat_appserver fixture using threaded Uvicorn server - Tests now use separate event loop in server thread - All 6 tests now pass without asyncio/event loop errors - Matches existing pattern from test_transcripts_rtc_ws.py Tests validate: - WebSocket connection and echo behavior - Error handling for non-existent transcripts - Multiple sequential messages - Graceful disconnection - WebVTT context generation - Unknown message type handling Closes fn-1.8 (End-to-end testing)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"assignee": null,
|
||||
"assignee": "igor.loskutoff@gmail.com",
|
||||
"claim_note": "",
|
||||
"claimed_at": null,
|
||||
"claimed_at": "2026-01-13T01:10:06.678780Z",
|
||||
"created_at": "2026-01-12T22:41:17.996329Z",
|
||||
"depends_on": [],
|
||||
"epic": "fn-1",
|
||||
"id": "fn-1.8",
|
||||
"priority": null,
|
||||
"spec_path": ".flow/tasks/fn-1.8.md",
|
||||
"status": "todo",
|
||||
"status": "in_progress",
|
||||
"title": "End-to-end testing",
|
||||
"updated_at": "2026-01-12T22:41:17.996509Z"
|
||||
"updated_at": "2026-01-13T01:10:06.678981Z"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,34 @@
|
||||
# fn-1.8 End-to-end testing
|
||||
|
||||
## Description
|
||||
TBD
|
||||
|
||||
Fix WebSocket chat tests to use proper async WebSocket testing approach (matching existing `test_transcripts_rtc_ws.py` pattern) instead of TestClient which has event loop issues.
|
||||
|
||||
## Current State
|
||||
|
||||
- Backend endpoint implemented: `server/reflector/views/transcripts_chat.py`
|
||||
- Frontend components implemented: `useTranscriptChat.ts`, `TranscriptChatModal.tsx`
|
||||
- Integration complete: chat components added to transcript page
|
||||
- Basic tests exist but fail due to TestClient event loop issues
|
||||
|
||||
## Acceptance
|
||||
- [ ] TBD
|
||||
|
||||
- [x] All WebSocket chat tests pass using proper async approach (httpx_ws)
|
||||
- [x] Tests validate: connection, message protocol, context generation, error handling
|
||||
- [x] Tests use threaded server pattern matching `test_transcripts_rtc_ws.py`
|
||||
- [x] No event loop or asyncio errors in test output
|
||||
|
||||
## Done summary
|
||||
TBD
|
||||
|
||||
Fixed WebSocket chat tests by switching from TestClient (which has event loop issues) to proper async testing approach using httpx_ws and threaded server pattern (matching existing test_transcripts_rtc_ws.py).
|
||||
|
||||
All 6 tests now pass:
|
||||
- test_chat_websocket_connection_success: validates WebSocket connection and echo behavior
|
||||
- test_chat_websocket_nonexistent_transcript: validates error handling for invalid transcript
|
||||
- test_chat_websocket_multiple_messages: validates handling multiple sequential messages
|
||||
- test_chat_websocket_disconnect_graceful: validates clean disconnection
|
||||
- test_chat_websocket_context_generation: validates WebVTT context generation with participants/words
|
||||
- test_chat_websocket_unknown_message_type: validates echo behavior for unknown message types
|
||||
|
||||
## Evidence
|
||||
- Commits:
|
||||
|
||||
Reference in New Issue
Block a user