@@ -2,7 +2,7 @@ import type { Credentials } from '@rocket.chat/api-client';
22import { TeamType , type IIntegration , type IMessage , type IRoom , type ITeam , type IUser } from '@rocket.chat/core-typings' ;
33import { Random } from '@rocket.chat/random' ;
44import { expect , assert } from 'chai' ;
5- import { after , before , describe , it } from 'mocha' ;
5+ import { after , before , describe , it , beforeEach } from 'mocha' ;
66
77import { getCredentials , api , request , credentials , reservedWords } from '../../data/api-data' ;
88import { pinMessage , sendMessage , starMessage , updateMessage } from '../../data/chat.helper' ;
@@ -3028,6 +3028,11 @@ describe('[Channels]', () => {
30283028 let testUserCredentials : Credentials ;
30293029 const name = `setType-${ Date . now ( ) } ` ;
30303030
3031+ beforeEach ( async ( ) => {
3032+ await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
3033+ await updatePermission ( 'create-team-group' , [ 'admin' , 'owner' , 'moderator' ] ) ;
3034+ } ) ;
3035+
30313036 before ( async ( ) => {
30323037 testChannel = ( await createRoom ( { type : 'c' , name } ) ) . body . channel ;
30333038
@@ -3056,6 +3061,8 @@ describe('[Channels]', () => {
30563061 after ( async ( ) => {
30573062 await deleteRoom ( { type : 'c' , roomId : testChannel . _id } ) ;
30583063 await deleteRoom ( { type : 'c' , roomId : testRegularChannel . _id } ) ;
3064+ await deleteRoom ( { type : 'c' , roomId : testTeamChannelForFailure . _id } ) ;
3065+ await deleteRoom ( { type : 'c' , roomId : testTeamChannelForSuccess . _id } ) ;
30593066 await deleteTeam ( credentials , team . name ) ;
30603067 await deleteUser ( testUser ) ;
30613068 await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
@@ -3095,7 +3102,6 @@ describe('[Channels]', () => {
30953102 expect ( res . body ) . to . have . property ( 'success' , false ) ;
30963103 expect ( res . body ) . to . have . property ( 'errorType' , 'error-action-not-allowed' ) ;
30973104 } ) ;
3098- await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
30993105 } ) ;
31003106
31013107 it ( 'should fail to change a team main room to private when user lacks create-p permission' , async ( ) => {
@@ -3110,7 +3116,6 @@ describe('[Channels]', () => {
31103116 expect ( res . body ) . to . have . property ( 'success' , false ) ;
31113117 expect ( res . body ) . to . have . property ( 'errorType' , 'error-action-not-allowed' ) ;
31123118 } ) ;
3113- await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
31143119 } ) ;
31153120
31163121 it ( 'should fail to change a team main room to private when user has create-team-group but lacks create-p' , async ( ) => {
@@ -3126,8 +3131,6 @@ describe('[Channels]', () => {
31263131 expect ( res . body ) . to . have . property ( 'success' , false ) ;
31273132 expect ( res . body ) . to . have . property ( 'errorType' , 'error-action-not-allowed' ) ;
31283133 } ) ;
3129- await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
3130- await updatePermission ( 'create-team-group' , [ 'admin' , 'owner' , 'moderator' ] ) ;
31313134 } ) ;
31323135
31333136 it ( 'should fail to change a team channel to private when user lacks create-team-group permission' , async ( ) => {
@@ -3142,7 +3145,6 @@ describe('[Channels]', () => {
31423145 expect ( res . body ) . to . have . property ( 'success' , false ) ;
31433146 expect ( res . body ) . to . have . property ( 'errorType' , 'error-action-not-allowed' ) ;
31443147 } ) ;
3145- await updatePermission ( 'create-team-group' , [ 'admin' , 'owner' , 'moderator' ] ) ;
31463148 } ) ;
31473149
31483150 it ( 'should succeed changing a team channel to private when user has create-team-group but not create-p' , async ( ) => {
@@ -3159,8 +3161,6 @@ describe('[Channels]', () => {
31593161 expect ( res . body ) . to . have . nested . property ( 'channel.t' , 'p' ) ;
31603162 expect ( res . body ) . to . have . nested . property ( 'channel.teamId' , team . _id ) ;
31613163 } ) ;
3162- await updatePermission ( 'create-p' , [ 'admin' , 'user' ] ) ;
3163- await updatePermission ( 'create-team-group' , [ 'admin' , 'owner' , 'moderator' ] ) ;
31643164 } ) ;
31653165 } ) ;
31663166
0 commit comments