Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package/src/mock-builders/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type MockUser = Pick<UserResponse, 'id'> & Partial<UserResponse>;
// Tests reach into private/internal StreamChat fields to set up a mocked
// authenticated client without going through the real network handshake.
type MockableStreamChat = StreamChat & {
connectionId?: string;
user?: OwnUserResponse;
_user?: OwnUserResponse;
userToken?: string;
Expand All @@ -28,7 +27,10 @@ type MockableStreamChat = StreamChat & {
export const setUser = (client: StreamChat, user: MockUser): Promise<void> =>
new Promise<void>((resolve) => {
const c = client as MockableStreamChat;
c.connectionId = 'dumm_connection_id';
// v10 keeps the connection id on `client.connectionIdManager`; requests that register a
// watch/presence subscription await it, so a mocked connect has to publish one or every
// `queryChannels()`/`channel.watch()` in the tests throws.
c.connectionIdManager.resolveConnectionId('dumm_connection_id');
// `userID` is now a read-only getter derived from `user.id`, so setting `user` is enough.
c.user = { ...user, mutes: [] } as unknown as OwnUserResponse;
c._user = { ...c.user };
Expand Down
Loading