@@ -2022,6 +2022,51 @@ describe('channel message search', function () {
20222022 expect ( response . results . length ) . to . equal ( 2 ) ;
20232023 } ) ;
20242024
2025+ describe ( 'search by mentioned users' , ( ) => {
2026+ const unique = uuidv4 ( ) ;
2027+ let channel ;
2028+ const tommaso = uuidv4 ( ) ;
2029+ const thierry = uuidv4 ( ) ;
2030+
2031+ let mention ;
2032+ before ( async ( ) => {
2033+ channel = authClient . channel ( 'messaging' , uuidv4 ( ) , {
2034+ unique,
2035+ } ) ;
2036+ await createUsers ( [ tommaso , thierry ] ) ;
2037+ await channel . create ( ) ;
2038+ await channel . sendMessage ( { text : 'regular' } ) ;
2039+ mention = await channel . sendMessage ( {
2040+ text : 'mentions' ,
2041+ mentioned_users : [ tommaso , thierry ] ,
2042+ } ) ;
2043+ } ) ;
2044+
2045+ it ( 'mentioned_users.id $contains tommaso' , async ( ) => {
2046+ const response = await channel . search ( {
2047+ 'mentioned_users.id' : { $contains : tommaso } ,
2048+ } ) ;
2049+ expect ( response . results . length ) . to . equal ( 1 ) ;
2050+ expect ( response . results [ 0 ] . message . id ) . to . equal ( mention . message . id ) ;
2051+ } ) ;
2052+
2053+ it ( 'mentioned_users.id invalid value type' , async ( ) => {
2054+ await expectHTTPErrorCode (
2055+ 400 ,
2056+ channel . search ( { 'mentioned_users.id' : { $contains : [ tommaso ] } } ) ,
2057+ 'StreamChat error code 4: Search failed with error: "field `mentioned_users.id` contains type array. expecting string"' ,
2058+ ) ;
2059+ } ) ;
2060+
2061+ it ( 'mentioned_users.id invalid operator' , async ( ) => {
2062+ await expectHTTPErrorCode (
2063+ 400 ,
2064+ channel . search ( { 'mentioned_users.id' : { $eq : tommaso } } ) ,
2065+ 'StreamChat error code 4: Search failed with error: "mentioned_users.id only supports $contains operator"' ,
2066+ ) ;
2067+ } ) ;
2068+ } ) ;
2069+
20252070 it ( 'query message text and custom field' , async function ( ) {
20262071 const unique = uuidv4 ( ) ;
20272072 const channel = authClient . channel ( 'messaging' , uuidv4 ( ) , {
0 commit comments