-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Problem
packages/dart_node_ws/test/ws_test.dart has a literal TODO comment on line 11:
//TODO: we need actual web socket server/client interaction tests here.The existing tests only cover:
WebSocketReadyStateenum values (connecting=0, open=1, closing=2, closed=3)createWebSocketServerbasic instantiation (port assignment, close callback)onConnectionhandler registration (no actual connection)
Zero tests for: message sending, message receiving, close events, error handling, JSON messaging, or any real client↔server interaction.
What's Needed
The dart_node_ws package needs actual interaction tests that verify:
- Client connects to server and server receives the connection
- Client sends a message and server receives it
- Server sends a message and client receives it
- JSON message round-trip (sendJson / onMessage parsing)
- Client close triggers server close event with code/reason
- Server close triggers client close event
- Error handler fires on connection errors
- Multiple concurrent clients
A test_server.dart helper already exists at packages/dart_node_ws/test/test_server.dart with echo/JSON support that could be leveraged.
CI Coverage Consideration
The CI workflow (.github/workflows/ci.yml via tools/test.sh) runs dart_node_ws tests as a Tier 2 Node package. Currently this only exercises the shallow unit tests above.
However, other test suites already use dart_node_ws as part of integration tests:
examples/backend/runs aWebSocketServicethat usesdart_node_wsfor real-time task broadcastingexamples/frontend/test/web_app_test.darttests WebSocket-driven UI updates (via mocked browser WebSocket)
These integration tests in other packages should count toward dart_node_ws coverage in CI. The CI pipeline should be updated to aggregate coverage from downstream consumers that exercise dart_node_ws code paths, not just the package's own test directory.
References
packages/dart_node_ws/test/ws_test.dart- current tests (line 11 TODO)packages/dart_node_ws/test/test_server.dart- existing test server helperpackages/dart_node_ws/lib/src/websocket_types.dart- types/API surface to testpackages/dart_node_ws/lib/src/websocket_server.dart- server factory to testexamples/backend/lib/services/websocket_service.dart- real-world usagetools/test.sh- CI test runner