Skip to content

Add UTS realtime unit and integration test specs#460

Open
paddybyers wants to merge 32 commits intouts-restfrom
uts-realtime
Open

Add UTS realtime unit and integration test specs#460
paddybyers wants to merge 32 commits intouts-restfrom
uts-realtime

Conversation

@paddybyers
Copy link
Copy Markdown
Member

Summary

Portable test specifications (UTS) for the Ably Realtime SDK, covering unit tests and direct sandbox integration tests. This builds on the REST test specs in uts-rest.

Scope

  • Realtime connection lifecycle: connect, disconnect, close, auto-connect, connection state transitions, error handling, heartbeat, fallback hosts, ping, recovery, resume, update events (RTN2–RTN27, RSN1–RSN4)
  • Realtime channels: attach, detach, publish, subscribe, channel state events, channel properties, channel options, server-initiated detach, channel error, channel annotations, message field population, message types, delta decoding, mutable messages, channel connection state interactions (RTL1–RTL23)
  • Realtime auth: connection auth, token renewal, authorize, token revocation (RSA4, RSA8, RSA9, RSA10, RTC8)
  • Realtime presence: enter/update/leave, subscribe, get, history, presence map, presence sync, channel state interactions, re-entry (RTP1–RTP18)
  • Realtime client: client options, time, stats, request (RTC1–RTC17, RTN18)
  • Supporting infrastructure: mock WebSocket helper spec, integration test helpers, CLOSE_CLIENT() cleanup across all specs
  • Integration test policy: integration-testing.md defining the three-tier test structure (unit / integration / integration-proxy)

69 files changed across 31 commits.

Does not include the test proxy framework or proxy-based integration tests — those will be a separate PR.

Test plan

  • Verify all spec files parse correctly and reference valid spec points
  • Cross-check against completion-status.md for coverage gaps
  • Confirm derived test implementations (ably-js, ably-dart) can be generated from these specs

🤖 Generated with Claude Code

paddybyers added 30 commits May 1, 2026 19:58
Add test specs covering connection failures (RTN14/RTN15), open
failures, error reason handling, fallback hosts (RSC15), heartbeats,
update events, whenState helper, and a connection lifecycle integration
test.
Ensure mock WebSocket connections are properly closed in connection
failure and open-failure test specs to prevent resource leaks in tests.
…kill

Separate the mock WebSocket specification into its own file for reuse
across test specs, and add a skill document for writing test specs.
Replace TRY/CATCH error characterisation patterns with declarative
EXPECT_THROW assertions for clearer, more portable test specifications.
…ence

Add UNIQUE_CHANNEL_NAME() calls and randomised channel names throughout
the test specs. Also adds new test specs for channel attach (RTL4),
detach (RTL6), channel options, state events, and channels collection.
Substantially rework the heartbeat test specs for better coverage of
RTN23 (heartbeat monitoring) and extend the mock WebSocket helper with
additional transport simulation capabilities. Update the write-test-spec
skill with improved patterns.
Correct the test approach for RTN15a immediate reconnection behaviour
and update the write-test-spec skill with refined patterns.
Correct small errors in channel_attach and channel_state_events specs.
Add test specs for channel connection state handling, channel error
reporting, server-initiated detach, channel properties (RTL15/RTL16),
connection ID/key (RTN8/RTN9), and connection ping (RTN13). Also adds
a completion-status tracker for spec point coverage.
Add comprehensive test specs covering channel message subscription,
filtering, listener management, and unsubscribe behaviour.
Add test specs covering channel message publishing, including message
encoding, connection state requirements, and error handling.
… specs

Add realtime test spec stubs for stats (RSC6a) and time (RSC16) that
reference the existing REST test specs, since behaviour is identical.
Add test specs covering the Realtime.request() method for making
arbitrary REST requests through the realtime client.
Add test coverage for message queueing during connection state changes,
publish behaviour across different connection states, and message
delivery ordering guarantees.
…istory)

Add specs covering connection state recovery options and realtime
channel history retrieval.
Add specs covering log level configuration, log handler callbacks,
and default logging behaviour for REST and Realtime clients.
Complete the authentication test spec coverage with specs for token
reauth, auth error handling, and edge cases.
Add comprehensive test specs covering presence enter, leave, update,
subscribe, presence map synchronisation, and presence history.
Update test specs to use encode_uri_component() for channel names in
URL paths, ensuring correct handling of special characters. Add a README
documenting the convention and update the write-test-spec skill.
Refine presence test specs based on implementation experience, add
integration test specs for presence operations against a live server,
and fix various issues in the presence specs.
Extend the skill documentation to note the importance of keeping
UTS portable test specs synchronised with language-specific tests.
Add specs covering the batch presence API for retrieving presence
state across multiple channels in a single request.
Add specs covering the revokeTokens API for invalidating issued
authentication tokens.
Add specs covering the handling of channel UPDATE protocol messages,
including resumed and non-resumed flag behaviour.
Add specs covering delta compression for channel messages using the
VCDIFF format, including encoding, decoding, and error recovery.
…connect

Add test specs for channel attributes (RTL15), channel whenState helper,
realtime client timeout configuration, auto-connect behaviour (RTC1b),
and REST channel attributes.
Add specs covering the mutable messages feature including message
update and delete operations, action fields, and event handling.
Add specs covering push notification administration including device
registration management and push channel subscription management.
…P2h2b

Fix several presence test spec issues: correct server echo expectations,
handle wildcard clientId constraints, and fix RTL13b (presence SYNC)
and RTP2h2b (presence re-entry) test logic.
Update REST integration test specs (auth, mutable messages, revoke
tokens) to align assertions with actual Ably sandbox behaviour.
paddybyers and others added 2 commits May 2, 2026 18:08
Realtime clients hold internal timers (retry, heartbeat, suspend) that
keep test processes alive after assertions complete. Every test that
creates a Realtime client must close it to release these handles.

Adds CLOSE_CLIENT(client) after the final assertion in 50 spec files
across realtime unit, integration, rest, and presence test specs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Apply fixes and implementation notes across 22 realtime UTS spec files
based on findings from translating specs to ably-js tests.

Key changes:
- Fix presence assertions (action == ENTER → PRESENT per RTP2d2)
- Add base64 encoding notes for JSON transport in delta decoding specs
- Fix state change filtering in auth reauth tests (RTC8a/RTC8a1)
- Add connectionStateTtl and disconnectedRetryTimeout to specs that
  transition through SUSPENDED or need fake timer precision
- Add implementation notes for echo suppression, NACK alternatives,
  clientId:* restrictions, and REST API numeric action values
- Add missing test sections (RTN14b, RTL5l, RTL5i notes)
- Relax overly specific error code assertions (RSAN1a3)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant