@@ -215,6 +215,7 @@ describe('miscellaneous', () => {
215215 describe ( '/directory' , ( ) => {
216216 let user : TestUser < IUser > ;
217217 let testChannel : IRoom ;
218+ let testGroup : IRoom ;
218219 let normalUserCredentials : Credentials ;
219220 const teamName = `new-team-name-${ Date . now ( ) } ` as const ;
220221 let teamCreated : ITeam ;
@@ -223,15 +224,19 @@ describe('miscellaneous', () => {
223224 await updatePermission ( 'create-team' , [ 'admin' , 'user' ] ) ;
224225 user = await createUser ( ) ;
225226 normalUserCredentials = await doLogin ( user . username , password ) ;
226- testChannel = ( await createRoom ( { name : `channel.test.${ Date . now ( ) } ` , type : 'c' } ) ) . body . channel ;
227- teamCreated = await createTeam ( normalUserCredentials , teamName , TEAM_TYPE . PUBLIC ) ;
227+ [ testChannel , testGroup , teamCreated ] = await Promise . all ( [
228+ createRoom ( { name : `channel.test.${ Date . now ( ) } ` , type : 'c' } ) . then ( ( res ) => res . body . channel ) ,
229+ createRoom ( { name : `group.test.${ Date . now ( ) } ` , type : 'p' } ) . then ( ( res ) => res . body . group ) ,
230+ createTeam ( normalUserCredentials , teamName , TEAM_TYPE . PUBLIC ) ,
231+ ] ) ;
228232 } ) ;
229233
230234 after ( async ( ) => {
231235 await Promise . all ( [
232236 deleteTeam ( normalUserCredentials , teamName ) ,
233237 deleteUser ( user ) ,
234238 deleteRoom ( { type : 'c' , roomId : testChannel . _id } ) ,
239+ deleteRoom ( { type : 'p' , roomId : testGroup . _id } ) ,
235240 updatePermission ( 'create-team' , [ 'admin' , 'user' ] ) ,
236241 ] ) ;
237242 } ) ;
@@ -308,6 +313,31 @@ describe('miscellaneous', () => {
308313 } )
309314 . end ( done ) ;
310315 } ) ;
316+
317+ it ( 'should return private group when search by channel and execute successfully' , async ( ) => {
318+ await request
319+ . get ( api ( 'directory' ) )
320+ . set ( credentials )
321+ . query ( {
322+ text : testGroup . name ,
323+ type : 'channels' ,
324+ } )
325+ . expect ( 'Content-Type' , 'application/json' )
326+ . expect ( 200 )
327+ . expect ( ( res ) => {
328+ expect ( res . body ) . to . have . property ( 'success' , true ) ;
329+ expect ( res . body ) . to . have . property ( 'offset' ) ;
330+ expect ( res . body ) . to . have . property ( 'total' ) ;
331+ expect ( res . body ) . to . have . property ( 'count' ) ;
332+ expect ( res . body ) . to . have . property ( 'result' ) . and . to . be . an ( 'array' ) ;
333+ expect ( res . body . result [ 0 ] ) . to . have . property ( '_id' , testGroup . _id ) ;
334+ expect ( res . body . result [ 0 ] ) . to . have . property ( 't' , 'p' ) ;
335+ expect ( res . body . result [ 0 ] ) . to . have . property ( 'name' ) ;
336+ expect ( res . body . result [ 0 ] ) . to . have . property ( 'usersCount' ) . and . to . be . an ( 'number' ) ;
337+ expect ( res . body . result [ 0 ] ) . to . have . property ( 'ts' ) ;
338+ } ) ;
339+ } ) ;
340+
311341 it ( 'should return an array(result) when search by channel with sort params correctly and execute successfully' , ( done ) => {
312342 void request
313343 . get ( api ( 'directory' ) )
0 commit comments