Skip to content

test: expand websocket connection and payload parser coverage#8

Draft
musfaagv wants to merge 1 commit into
codex/task-title-18x8u2from
codex/add-tests-for-websocket-connection-and-payload
Draft

test: expand websocket connection and payload parser coverage#8
musfaagv wants to merge 1 commit into
codex/task-title-18x8u2from
codex/add-tests-for-websocket-connection-and-payload

Conversation

@musfaagv
Copy link
Copy Markdown
Owner

Motivation

  • Improve test coverage and reliability for WebSocket-related UI and connection logic to prevent regressions when switching data sources and handling JSON WS payloads.
  • Verify the Connect modal exposes the WebSocket tab and that the connect flow uses the URL input as expected.
  • Ensure the WebSocket payload parser maps ultrasonic payloads to chart data safely and doesn't crash on invalid input.

Description

  • Updated src/components/__tests__/ConnectModal.test.tsx to explicitly assert the WebSocket tab is present/selectable, verify the WebSocket URL input default value, and confirm the onConnectWebSocket callback is invoked with the updated URL.
  • Rewrote src/hooks/__tests__/useDataConnection.test.ts to mock useWebSocket (and useSerial/generator) with deterministic state and spies, and added transition tests for generator -> websocket, serial -> websocket, disconnect, plus write() behavior (successful when websocket-connected, throws when disconnected).
  • Extended src/utils/__tests__/wsPayload.test.ts to assert valid ultrasonic JSON maps to chart values [cm, inch] and to assert invalid payloads are handled safely (no crash and return null).

Testing

  • Ran the targeted test suite with npm test -- src/components/__tests__/ConnectModal.test.tsx src/hooks/__tests__/useDataConnection.test.ts src/utils/__tests__/wsPayload.test.ts.
  • All targeted tests passed: 3 test files executed and 11 tests passed (no failures).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant