test: verify minProtocol and maxProtocol in connect request#102
test: verify minProtocol and maxProtocol in connect request#102anschmieg wants to merge 11 commits intogrp06:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds missing unit-test coverage to ensure OpenClawGatewayAdapter includes the expected protocol negotiation fields in its WebSocket connect request params, preventing regressions in the connect handshake contract (closes #101).
Changes:
- Added a unit test that inspects the outbound
connectrequest and assertsparams.minProtocol === 3andparams.maxProtocol === 3.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/unit/openclawAdapter.test.ts
Outdated
| ws.on("message", (raw) => { | ||
| const parsed = JSON.parse(String(raw ?? "")); | ||
| if (parsed?.method === "connect") { | ||
| observedMinProtocol = parsed.params?.minProtocol; | ||
| observedMaxProtocol = parsed.params?.maxProtocol; |
There was a problem hiding this comment.
This test asserts params.minProtocol/params.maxProtocol are 3, but it doesn’t verify the PR’s stated requirement that these fields are not nested under a params.protocol object (or that no protocol object is present at all). Consider also asserting that parsed.params.protocol is undefined (or that the only protocol-related keys are minProtocol/maxProtocol) to fully cover the regression described in #101 and the PR description.
- Capture full params object to verify structure - Assert minProtocol and maxProtocol are present - Assert protocol field is undefined (not nested) Addresses Copilot review feedback.
|
@copilot review the last commit that addressed the concerns raised in @copilot's comment |
Problem
The OpenClawGatewayAdapter connect handshake sends minProtocol and maxProtocol in the connect params, but there is no test coverage verifying these fields are included in the actual WebSocket request.
Debugging Context
When Studio failed to connect with a generic "Disconnected" state, I added debug logging to capture the actual WebSocket frames. Without existing tests that verify the exact params structure, I had no reliable way to confirm whether the protocol fields were being sent correctly. The code appeared correct when reading the source, but without a test capturing the actual sent params, I couldn't rule out transpilation issues, bundler behavior, or subtle bugs.
Solution
Adds a test that captures and verifies the connect request params include minProtocol and maxProtocol set to the expected protocol version (3).
Test Coverage
The new test:
Files Changed
References