MockMessagesApi class
Properties
failNextUpdateWith
↔ ChatFailure ?
When set, the next update call fails with this failure and leaves
the store untouched, then clears itself. Lets a test drive the paths
that only one specific server refusal reaches — an edit turned down
with EditWindowExpiredFailure behaves nothing like an edit that hit
a flaky network.
getter/setter pair
hashCode
→ int
The hash code for this object.
no setter inherited
markRoomAsDeliveredCalls
→ List <({String lastDeliveredMessageId , String roomId } ) >
Records each markRoomAsDelivered invocation as a (roomId, lastDeliveredMessageId) tuple so tests can assert how the adapter
confirms delivery and with which cursor.
final
markRoomAsReadCalls
→ List <({String ? lastReadMessageId , String roomId } ) >
Records each markRoomAsRead invocation as a (roomId, lastReadMessageId) tuple so tests can assert how often the
adapter flushed read receipts and against which high-water
mark. Cleared via resetMarkRoomAsReadCalls .
final
runtimeType
→ Type
A representation of the runtime type of the object.
no setter inherited
throwNextList
↔ bool
When true, the next list call made with
cachePolicy: CachePolicy.networkOnly throws (rather than returning
a failed ChatResult ), then resets to false. Lets tests exercise the
"an awaited call inside a flow threw" path — e.g. ChatUiAdapter.resync
reverting its debounce seal on an exception, not just on isFailure.
getter/setter pair
Methods
addReaction (String roomId , String messageId , {required String emoji })
→ Future <ChatResult <void > >
Adds emoji as the current user's reaction to messageId via the
canonical reactions endpoint (POST /rooms/{roomId}/messages/{messageId}/reactions).
override
cancelScheduled (String roomId , String scheduledId )
→ Future <ChatResult <void > >
Cancels a previously scheduled message.
override
clearChat (String roomId )
→ Future <ChatResult <void > >
Clears chat history for the current user (client-side only).
Marks all messages as read and hides messages sent before now.
override
delete (String roomId , String messageId )
→ Future <ChatResult <void > >
Deletes a message from a room.
override
deleteReaction (String roomId , String messageId , {String ? emoji })
→ Future <ChatResult <void > >
Removes the current user's reaction from a message.
override
get (String roomId , String messageId )
→ Future <ChatResult <ChatMessage > >
Fetches a single message by ID.
override
getClearedAt (String roomId )
→ Future <ChatResult <DateTime ? > >
Returns the timestamp at which the user cleared this room's chat,
or ChatSuccess(null) if the chat was never cleared. Wrapped in
ChatResult so a cache I/O failure surfaces explicitly instead of
being conflated with "never cleared".
override
getReactions (String roomId , String messageId , {bool forceRefresh = false , CachePolicy ? cachePolicy })
→ Future <ChatResult <List <AggregatedReaction > > >
Gets aggregated reactions (emoji counts and user lists) for a message.
override
getRoomReceipts (String roomId )
→ Future <ChatResult <ChatPaginatedResponse <ReadReceipt > > >
Lists read receipts for all members of a room.
override
getThread (String roomId , String messageId , { })
→ Future <ChatResult <ChatPaginatedResponse <ChatMessage > > >
Fetches the thread (replies) for a given parent message.
override
list (String roomId , {bool ? unreadOnly , CachePolicy ? cachePolicy })
→ Future <ChatResult <ChatPaginatedResponse <ChatMessage > > >
Lists messages in a room with bidirectional cursor pagination.
override
listPins (String roomId , { })
→ Future <ChatResult <ChatPaginatedResponse <MessagePin > > >
Lists all pinned messages in a room.
override
listReports (String roomId , { })
→ Future <ChatResult <ChatPaginatedResponse <MessageReport > > >
Lists reports filed against messages in a room.
override
listScheduled (String roomId )
→ Future <ChatResult <ChatPaginatedResponse <ScheduledMessage > > >
Lists scheduled (not yet sent) messages in a room.
override
listStarred ({})
→ Future <ChatResult <ChatPaginatedResponse <StarredMessage > > >
Lists the current user's starred messages across all rooms, most
recent first.
override
markRoomAsDelivered (String roomId , {required String lastDeliveredMessageId })
→ Future <ChatResult <void > >
Confirms delivery of every message in roomId up to and including
lastDeliveredMessageId (the delivered cursor — WhatsApp's double
gray tick).
override
markRoomAsRead (String roomId , {String ? lastReadMessageId })
→ Future <ChatResult <void > >
Marks all messages in a room as read, optionally up to a specific message.
override
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinMessage (String roomId , String messageId )
→ Future <ChatResult <void > >
Pins a message in a room so it appears in the pinned list.
override
report (String roomId , String messageId , {required String reason })
→ Future <ChatResult <void > >
Reports a message for moderation.
override
resetMarkRoomAsDeliveredCalls ()
→ void
Clears the markRoomAsDeliveredCalls history.
resetMarkRoomAsReadCalls ()
→ void
Clears the markRoomAsReadCalls history. Convenient at the
start of a test stage that wants to isolate a specific flush.
schedule (String roomId , {required DateTime sendAt , String ? text , Map <String , dynamic > ? metadata })
→ Future <ChatResult <ScheduledMessage > >
Schedules a message to be sent at a future time.
override
search (String query , {String ? roomId , })
→ Future <ChatResult <ChatPaginatedResponse <ChatMessage > > >
Full-text search of messages, server-side.
override
send (String roomId , {String ? text , MessageType messageType = MessageType.regular , String ? referencedMessageId , String ? reaction , String ? attachmentUrl , String ? attachmentId , String ? sourceRoomId , Map <String , dynamic > ? metadata , String ? tempId , String ? clientMessageId })
→ Future <ChatResult <ChatMessage > >
Sends a message via REST. Returns the created message with server-assigned ID.
override
sendReceipt (String roomId , String messageId , {ReceiptStatus status = ReceiptStatus.read })
→ Future <ChatResult <void > >
Sends a delivery or read receipt for a specific message.
override
sendTyping (String roomId , {ChatActivity activity = ChatActivity.startsTyping })
→ Future <ChatResult <void > >
Sends a typing indicator (start or stop) to a room.
override
sendViaWs (String roomId , {String ? text , MessageType messageType = MessageType.regular , String ? referencedMessageId , String ? reaction , String ? attachmentUrl , String ? attachmentId , String ? sourceRoomId , Map <String , dynamic > ? metadata })
→ Future <ChatResult <ChatMessage > >
Sends a message preferring the WebSocket transport when available.
override
setLocalClearedAt (String roomId , DateTime clearedAt )
→ Future <ChatResult <void > >
Pure-local counterpart to clearChat : sets the clear-chat cutoff
without also calling markRoomAsRead server-side. Used by
ChatRoomsController.delete (WhatsApp "Delete chat"), which — unlike
clearChat — must stay purely local and never fail on account of
connectivity (deleting a chat has no server-side counterpart at all).
No-op (never throws) when no local datasource is configured.
override
starMessage (String roomId , String messageId )
→ Future <ChatResult <void > >
Stars (bookmarks) a message for the current user only.
override
toString ()
→ String
A string representation of this object.
inherited
unpinMessage (String roomId , String messageId )
→ Future <ChatResult <void > >
Unpins a message from a room.
override
unstarMessage (String roomId , String messageId )
→ Future <ChatResult <void > >
Removes the current user's star from a message.
override
update (String roomId , String messageId , {required String text , Map <String , dynamic > ? metadata })
→ Future <ChatResult <void > >
Edits the text of an existing message.
override