@@ -5,6 +5,7 @@ import { act, fireEvent, render, screen } from '@testing-library/react-native';
55import type { Channel } from 'stream-chat' ;
66
77import { ChannelDetailsContextProvider } from '../../../contexts/channelDetailsContext/channelDetailsContext' ;
8+ import { ChatContext } from '../../../contexts/chatContext/ChatContext' ;
89import { WithComponents } from '../../../contexts/componentsContext/ComponentsContext' ;
910import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext' ;
1011import { defaultTheme } from '../../../contexts/themeContext/utils/theme' ;
@@ -59,11 +60,23 @@ const sectionElement = () => (
5960 userLanguage : 'en' ,
6061 } }
6162 >
62- < ChannelDetailsContextProvider value = { { channel } } >
63- < WithComponents overrides = { { ChannelDetailsActionItem : ActionItemProbe } } >
64- < ChannelDetailsActionsSection />
65- </ WithComponents >
66- </ ChannelDetailsContextProvider >
63+ < ChatContext . Provider
64+ value = {
65+ {
66+ client : {
67+ mutedUsers : [ ] ,
68+ on : ( ) => ( { unsubscribe : ( ) => undefined } ) ,
69+ userID : 'me' ,
70+ } ,
71+ } as never
72+ }
73+ >
74+ < ChannelDetailsContextProvider value = { { channel } } >
75+ < WithComponents overrides = { { ChannelDetailsActionItem : ActionItemProbe } } >
76+ < ChannelDetailsActionsSection />
77+ </ WithComponents >
78+ </ ChannelDetailsContextProvider >
79+ </ ChatContext . Provider >
6780 </ TranslationProvider >
6881 </ ThemeProvider >
6982) ;
@@ -256,7 +269,7 @@ describe('ChannelDetailsActionsSection', () => {
256269 it ( 'reflects userMuted state on the muteUser item Switch in direct chats' , ( ) => {
257270 useIsDirectChatSpy . mockReturnValue ( true ) ;
258271 getOtherUserSpy . mockReturnValue ( { user : { id : 'other-user' } } ) ;
259- useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'other-user' } } ] ) ;
272+ useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'other-user' } , user : { id : 'me' } } ] ) ;
260273 useActionItemsSpy . mockReturnValue ( [ buildItem ( { id : 'muteUser' , label : 'Unmute User' } ) ] ) ;
261274 renderSection ( ) ;
262275 const userMuteSwitch = screen . getByTestId ( 'channel-details-action-muteUser-switch' ) ;
@@ -297,7 +310,7 @@ describe('ChannelDetailsActionsSection', () => {
297310 fireEvent ( userMuteSwitch , 'valueChange' , true ) ;
298311 expect ( screen . getByTestId ( 'channel-details-action-muteUser-switch' ) . props . value ) . toBe ( true ) ;
299312 // A server event reports the user as muted before the request resolves.
300- useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'other-user' } } ] ) ;
313+ useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'other-user' } , user : { id : 'me' } } ] ) ;
301314 rerender ( sectionElement ( ) ) ;
302315 // The request fails: revert to the current hook value (true), not !value (false).
303316 act ( ( ) => {
@@ -309,7 +322,7 @@ describe('ChannelDetailsActionsSection', () => {
309322 it ( 'userMuted is false when the other user is not in mutedUsers' , ( ) => {
310323 useIsDirectChatSpy . mockReturnValue ( true ) ;
311324 getOtherUserSpy . mockReturnValue ( { user : { id : 'other-user' } } ) ;
312- useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'someone-else' } } ] ) ;
325+ useMutedUsersSpy . mockReturnValue ( [ { target : { id : 'someone-else' } , user : { id : 'me' } } ] ) ;
313326 useActionItemsSpy . mockReturnValue ( [ buildItem ( { id : 'muteUser' , label : 'Mute User' } ) ] ) ;
314327 renderSection ( ) ;
315328 const userMuteSwitch = screen . getByTestId ( 'channel-details-action-muteUser-switch' ) ;
0 commit comments