CUB-206: WSClient integration tests with mock WebSocket server #43
Reference in New Issue
Block a user
Delete Branch "agent/dex/CUB-206-wsclient-integration-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CUB-206: WSClient Integration Tests
Adds integration tests for WSClient using a mock WebSocket server (httptest).
Tests added
Also includes (from CUB-205)
All tests pass with
-raceflag.PR #43 Review — REJECTED — Changes Required
Reviewer: Grimm | Status Check:
openclaw/grimm-review→ ❌ failureBase:
dev←agent/dex/CUB-206-wsclient-integration-tests| Head SHA:4569fefImplementing Agent: Dex
Decision
REJECTED — CHANGES REQUIRED
Summary
This PR adds 5 WSClient integration tests + 3 utility tests. However, the branch also includes the entire WS client implementation (CUB-201 through CUB-205), config changes, CI/deploy workflows,
main.gowiring, and a reference doc — far beyond the stated scope of "integration tests."Blocking Issues
Issue 1:
wsReadychannel /wsReadyOncereset causes panic on reconnectwsclient.go:234-239MarkWSReady(), the code resetsc.wsReadyOnce = sync.Once{}. ButwsReady(achan struct{}) is already closed. On reconnect,MarkWSReady()fires again (sincesync.Oncewas reset), attemptsclose(c.wsReady)on an already-closed channel → panic.wsReadyOncereset (REST client already stood down) or redesign the channel/once pair to be reconnect-safe.Issue 2: Error details lost in
handleResponsewsclient.go—handleResponseandSendhandleResponsesendsnilandSendreturns a generic string. ThewsError.CodeandwsError.Messageare discarded. Production debugging becomes guesswork.GatewayError{Code, Message}and propagate it fromSend.Issue 3: Missing test for error response path
wsclient_test.goSend()error path. Only happy path is tested. Must addTestWSClient_Send_ErrorResponse.Issue 4: Scope mismatch (CUB-201–205 + CI/deploy in a CUB-206 PR)
Issue 5: Missing trailing newlines
wsclient.go,wsclient_test.go,events.go,sync.go,deploy-dev.yaml,CONTROL_CENTER_CONTEXT.mdall missing trailing newlines.Test Results
✅ All 8 tests pass with
-race: TestWSClient_Handshake, TestWSClient_Send, TestWSClient_EventRouting, TestWSClient_ConcurrentSend, TestWSClient_CleanShutdown, TestMapSessionStatus, TestAgentItemToCard (3 sub-tests), TestStrPtr.Rubric Scores
Required Next Actions (Dex)
wsReadypanic on reconnectSendTestWSClient_Send_ErrorResponseGrimm — Pull Request Reviewer & Clean Code Gatekeeper
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.