@@ -25,14 +25,15 @@ const createMemberMock = (userId = 'target-user-id'): ChannelMemberResponse =>
2525 user_id : userId ,
2626 } ) as ChannelMemberResponse ;
2727
28- const createChannelMock = ( params ?: { blockedUserIds ?: string [ ] } ) : Channel => {
29- const { blockedUserIds = [ ] } = params ?? { } ;
28+ const createChannelMock = ( params ?: { blockedUserIds ?: string [ ] ; userID ?: string } ) : Channel => {
29+ const { blockedUserIds = [ ] , userID = 'current-user-id' } = params ?? { } ;
3030 return {
3131 getClient : ( ) => ( {
3232 blockedUsers : {
3333 getLatestValue : ( ) => ( { userIds : blockedUserIds } ) ,
3434 subscribeWithSelector : ( ) => ( ) => { } ,
3535 } ,
36+ userID,
3637 } ) ,
3738 } as unknown as Channel ;
3839} ;
@@ -70,6 +71,16 @@ describe('useChannelMemberActionItems', () => {
7071 expect ( result . current . map ( ( item ) => item . label ) ) . toEqual ( [ 'Mute User' , 'Block User' ] ) ;
7172 } ) ;
7273
74+ it ( 'returns no action items when the member is the current user' , ( ) => {
75+ const currentUserChannel = createChannelMock ( { userID : 'target-user-id' } ) ;
76+
77+ const { result } = renderHook ( ( ) =>
78+ useChannelMemberActionItems ( { channel : currentUserChannel , member } ) ,
79+ ) ;
80+
81+ expect ( result . current ) . toEqual ( [ ] ) ;
82+ } ) ;
83+
7384 it ( 'toggles muteUser to unmuteUser when the member is already muted' , ( ) => {
7485 jest
7586 . spyOn ( useMutedUsersModule , 'useMutedUsers' )
@@ -140,6 +151,7 @@ describe('useChannelMemberActionItems', () => {
140151 actions : userActions ,
141152 channel,
142153 isBlocked : false ,
154+ isCurrentUser : false ,
143155 member,
144156 t : expect . any ( Function ) ,
145157 userMuteActive : false ,
@@ -161,6 +173,7 @@ describe('buildDefaultChannelMemberActionItems', () => {
161173 actions,
162174 channel,
163175 isBlocked : false ,
176+ isCurrentUser : false ,
164177 member,
165178 t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
166179 userMuteActive : false ,
@@ -172,12 +185,28 @@ describe('buildDefaultChannelMemberActionItems', () => {
172185 expect ( items . map ( ( item ) => item . type ) ) . toEqual ( [ 'standard' , 'destructive' ] ) ;
173186 } ) ;
174187
188+ it ( 'returns no items when the member is the current user' , ( ) => {
189+ const actions = createUserActions ( ) ;
190+ const items = buildDefaultChannelMemberActionItems ( {
191+ actions,
192+ channel,
193+ isBlocked : false ,
194+ isCurrentUser : true ,
195+ member,
196+ t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
197+ userMuteActive : false ,
198+ } ) ;
199+
200+ expect ( items ) . toEqual ( [ ] ) ;
201+ } ) ;
202+
175203 it ( 'returns unmute/unblock variants when toggles are active' , ( ) => {
176204 const actions = createUserActions ( ) ;
177205 const items = buildDefaultChannelMemberActionItems ( {
178206 actions,
179207 channel,
180208 isBlocked : true ,
209+ isCurrentUser : false ,
181210 member,
182211 t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
183212 userMuteActive : true ,
@@ -194,6 +223,7 @@ describe('buildDefaultChannelMemberActionItems', () => {
194223 actions,
195224 channel,
196225 isBlocked : false ,
226+ isCurrentUser : false ,
197227 member,
198228 t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
199229 userMuteActive : true ,
@@ -209,6 +239,7 @@ describe('buildDefaultChannelMemberActionItems', () => {
209239 actions,
210240 channel,
211241 isBlocked : false ,
242+ isCurrentUser : false ,
212243 member,
213244 t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
214245 userMuteActive : false ,
@@ -219,6 +250,7 @@ describe('buildDefaultChannelMemberActionItems', () => {
219250 actions,
220251 channel,
221252 isBlocked : false ,
253+ isCurrentUser : false ,
222254 member,
223255 t : ( ( value : string ) => value ) as TranslationContextValue [ 't' ] ,
224256 userMuteActive : false ,
0 commit comments