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 yet; v0.1.0 covers the surface exercised by the drop-in widgets. Additional members will be added when their real counterparts ship.

Implemented types

Constructors

FakeChataptorClient({ConnectionState initialConnectionState = const Disconnected(DisconnectReason.userRequested), AgentInfo? initialAgent})
Creates a FakeChataptorClient in initialConnectionState (defaults to Disconnected(userRequested)), optionally with an initialAgent.

Properties

config ChataptorConfig
The active configuration.
finalinherited
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 the backend reports as currently online for this site, in arrival order (backend caps the list at 5).
no setterinherited
currentSiteConfig SiteConfig?
Last SiteConfig received from the backend on site:X channel 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:available or agents: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:X join. 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
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 the beforeSend interceptor 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