FakeChataptorClient class
Domain-level fake for ChataptorClient.
Designed for merchants writing widget tests of their host app — never
exposes transport, HTTP, or serialization concerns. For low-level
protocol-layer tests of the SDK itself, reach for FakeChatTransport
instead.
The fake does not implement every ChataptorClient member — it covers the surface exercised by the drop-in widgets and by typical merchant host-app tests (connect / disconnect / sendMessage / clearSession / identify, plus the corresponding streams). Additional members are added as the real counterparts ship.
- Implemented types
Constructors
- FakeChataptorClient({ConnectionState initialConnectionState = const Disconnected(DisconnectReason.userRequested), AgentInfo? initialAgent})
-
Creates a FakeChataptorClient in
initialConnectionState(defaults toDisconnected(userRequested)), optionally with aninitialAgent.
Properties
- config → ChataptorConfig
-
The active configuration. Most fields are immutable for the lifetime
of the client, but ChataptorConfig.customer may be swapped at
runtime via identify; reading config always returns the current
value.
no setterinherited
-
connectionState
→ Stream<
ConnectionState> -
Stream of connection state updates.
no setteroverride
- currentConnectionState → ConnectionState?
-
Synchronous read of the current connection state.
no setteroverride
-
currentMessages
→ List<
Message> -
Snapshot of all messages received in this session, sorted oldest-first.
no setteroverride
-
currentOnlineAgents
→ List<
AgentInfo> -
Snapshot of agents currently reported as online for this site, in
arrival order. The list is capped on the wire and typically holds
at most a handful of entries.
no setterinherited
- currentSiteConfig → SiteConfig?
-
Last SiteConfig received from the backend on
site:Xchannel join.no setterinherited - debugAgent → AgentInfo?
-
Exposed for internal testing only.
no setterinherited
- debugStorage → ChataptorStorage
-
Exposed for internal testing only.
no setterinherited
-
errors
→ Stream<
ChataptorError> -
Stream of non-fatal errors emitted by the client.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- inject ↔ FakeChataptorClientInject
-
Scripted-event injection API.
latefinal
-
messages
→ Stream<
Message> -
Stream of incoming messages (agent → customer) and locally sent
messages (customer → agent) — the Flutter layer uses this to drive the
message list.
no setteroverride
-
onlineAgentsStream
→ Stream<
List< AgentInfo> > -
Stream of online-agent snapshots. Emits a fresh list each time the
backend pushes
agent:availableoragents:offline. Replays the current snapshot to new listeners.no setterinherited - recorded → FakeChataptorClientRecorded
-
Observable record of calls.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
siteConfigStream
→ Stream<
SiteConfig> -
Stream of SiteConfig updates. Emits once per successful
site:Xjoin. Replays the current value to new listeners.no setterinherited
Methods
-
clearSession(
) → Future< void> -
Clears the local session: deletes the stored guest ID and disconnects if
currently connected. The next connect call will create a new anonymous
identity and open a fresh conversation on the backend.
override
-
connect(
) → Future< void> -
Opens the WebSocket, joins the site channel, creates a conversation, and
joins the conversation channel. Connected is emitted only after the
full handshake completes. Idempotent.
override
-
disconnect(
) → Future< void> -
Closes the WebSocket. Idempotent.
override
-
dispose(
) → Future< void> -
Releases every resource. After dispose the client is unusable.
override
-
identify(
CustomerIdentity newIdentity) → Future< void> -
Migrates the current session to a new CustomerIdentity.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
override
-
sendMessage(
String text, {Map< String, dynamic> ? metadata}) → Future<SendResult> -
Sends a text
text. Runs thebeforeSendinterceptor if set, then pushes the payload over the transport. Returns a SendResult reflecting the outcome.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited