test(llc): migrate the stream_chat test suite to the stream_chat_test algebra - #2954
Draft
VelikovPetar wants to merge 100 commits into
Draft
VelikovPetar wants to merge 100 commits into
VelikovPetar wants to merge 100 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…Enabled Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # melos.yaml
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ream_chat_test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…at_test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…_test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…chat_test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…_state_test monolith Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…_test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… depending on order Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…tream_chat_test doubles Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…Json restores Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…tialized channels Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…endEvent tests had Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ainst state Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ction_test Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…he error Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ckage widened it Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…el role in emitted messages Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ation claims Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… config Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… whole 0.1.0 surface Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… instead of a default Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…client sendEvent Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… not an isolation boundary Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…API call Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…iry error Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…at other tests Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…sting guides Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
stream_chat test suite to the stream_chat_test harness
stream_chat test suite to the stream_chat_test harnessstream_chat test suite to the stream_chat_test algebra
VelikovPetar
changed the base branch from
feat/stream-chat-test-package
to
master
September 11, 2026 18:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Depends on #2950 (
test(repo): add \stream_chat_test` package). This branch is built onfeat/stream-chat-test-package, so the diff below carries that package (4 files, ~1.9k lines) in addition to the migration. Merge #2950 first — once it lands, this diff reduces to the migration alone. Both branches carry the latestmaster`.Rewrites the
stream_chattest suite on top of thechatClientTest/channelTestharness from #2950, and deletes the three monolithic test files it replaces.
What changes
channel_client_state_test.dart(164 tests) → 21 files undertest/src/client/channel/state/channel_test.dart(186 tests) → 28 files undertest/src/client/channel/client_test.dart(~200 tests) → 16 files astest/src/client/client_*_test.darttest/src/fakes.dartandtest/src/matchers.dartdeleted,test/src/mocks.dartshrunk to the seven doubles that live below the harness seam(HTTP client, Dio, logger, token/connection-id managers, WS channel/sink, general API).
STYLE_GUIDE.md/TESTING.mddocument the harness and the three conventions itdepends on (exact-argument stubbing, deterministic fixtures, UTC in emitted events).
The tests now run a real
StreamChatClientwith three seams replaced — REST API,WebSocket transport, persistence — so event decoding, channel state, the retry queue,
the delivery reporter and reconnection all execute production code. Several tests
consequently reach a layer deeper than before: they stub
api.message.sendMessagerather than
client.sendMessage, putting the client→API translation under test too.Evidence
lib/lines coveredverify(...).called(n)verifyNoMoreInteractionsany(...)wildcard matchersexpectLatercounterpart here; verified by runner-level enumeration, not by grep.
?? DateTime.now()/?? Uuid().v4()default initializers in
poll.dartandmessage_reminder.dart, no longer reachedbecause fixtures pass ids and timestamps explicitly. That is the trade that makes
equality-based mock matching deterministic.
mastercame from a test that built a client without achatApi, sending a real request tochat.stream-io-api.comon every run. The defaultREST wiring those calls incidentally covered is now pinned by
client_default_wiring_test.dartwith a stubbedHttpClientAdapter.Intentional deviations
setUp/tearDown and zero tests); the rest cover
channel.config, the auth interceptor'snon-token-expiry passthrough, the default REST wiring, and the retry queue giving up
when the policy declines.
non-retriable ones, matching their titles.
channel.onasserted event identity, which held only because the event never leftthe process. Events now round-trip through real JSON decoding, so it asserts every
field the event carries instead.
client_reconnection_test.dartis a deliberate carve-out on a hand-rolled fake socket:the anonymous-token user id cannot pass the fake server's connect-URI validation, and
the reconnect-recovery tests need to drop an established connection. Both are documented
in the file, and a self-test in the harness fails the moment the gap closes.
Follow-ups (not in this PR)
deterministic fix needs a seam to advance them.
mockFailedAuth's token-expiry refresh branch is documented but not yet exercised.Bugs this surfaced (pre-existing on
master, filed separately)RetryQueuecan re-send the same message an arbitrary number of times:Message.createdAtfalls back to a fresh
DateTime.now()on every read when neither timestamp is set, whichmakes the queue's heap comparator non-reflexive, so
remove()silently fails.ChannelClientState.activeLiveLocationsformessages outside the loaded window —
locationExpiredResolverreroutes the event and thechannel handler no-ops on a
_findLocationMessagemiss.Both were invisible on
masterbecause its tests mockedStreamChatClient, so no eventresolvers or heap invariants ran.