Skip to content

Commit ba2f659

Browse files
review: adjust after and before
1 parent e3406da commit ba2f659

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

apps/meteor/tests/end-to-end/api/channels.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Credentials } from '@rocket.chat/api-client';
22
import { TeamType, type IIntegration, type IMessage, type IRoom, type ITeam, type IUser } from '@rocket.chat/core-typings';
33
import { Random } from '@rocket.chat/random';
44
import { expect, assert } from 'chai';
5-
import { after, before, describe, it } from 'mocha';
5+
import { after, before, describe, it, beforeEach } from 'mocha';
66

77
import { getCredentials, api, request, credentials, reservedWords } from '../../data/api-data';
88
import { 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

apps/meteor/tests/end-to-end/api/groups.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Credentials } from '@rocket.chat/api-client';
22
import { TeamType, type IIntegration, type IMessage, type IRoom, type ITeam, type IUser } from '@rocket.chat/core-typings';
33
import { assert, expect } from 'chai';
4-
import { after, before, describe, it } from 'mocha';
4+
import { after, before, describe, it, beforeEach } from 'mocha';
55

66
import { getCredentials, api, request, credentials, apiPrivateChannelName } from '../../data/api-data';
77
import { pinMessage, starMessage, sendMessage, updateMessage } from '../../data/chat.helper';
@@ -1901,6 +1901,11 @@ describe('[Groups]', () => {
19011901
let testUser: TestUser<IUser>;
19021902
let testUserCredentials: Credentials;
19031903

1904+
beforeEach(async () => {
1905+
await updatePermission('create-c', ['admin', 'user']);
1906+
await updatePermission('create-team-channel', ['admin', 'owner', 'moderator']);
1907+
});
1908+
19041909
before(async () => {
19051910
await request
19061911
.post(api('groups.create'))
@@ -1945,6 +1950,8 @@ describe('[Groups]', () => {
19451950
.expect('Content-Type', 'application/json')
19461951
.expect(200);
19471952
await deleteRoom({ type: 'p', roomId: testRegularGroup._id });
1953+
await deleteRoom({ type: 'p', roomId: testTeamGroupForFailure._id });
1954+
await deleteRoom({ type: 'p', roomId: testTeamGroupForSuccess._id });
19481955
await deleteTeam(credentials, team.name);
19491956
await deleteUser(testUser);
19501957
await updatePermission('create-c', ['admin', 'user']);
@@ -1979,7 +1986,6 @@ describe('[Groups]', () => {
19791986
expect(res.body).to.have.property('success', false);
19801987
expect(res.body).to.have.property('errorType', 'error-action-not-allowed');
19811988
});
1982-
await updatePermission('create-c', ['admin', 'user']);
19831989
});
19841990

19851991
it('should fail to change a team main room to channel when user lacks create-c permission', async () => {
@@ -1994,7 +2000,6 @@ describe('[Groups]', () => {
19942000
expect(res.body).to.have.property('success', false);
19952001
expect(res.body).to.have.property('errorType', 'error-action-not-allowed');
19962002
});
1997-
await updatePermission('create-c', ['admin', 'user']);
19982003
});
19992004

20002005
it('should fail to change a team main room to channel when user has create-team-channel but lacks create-c', async () => {
@@ -2010,8 +2015,6 @@ describe('[Groups]', () => {
20102015
expect(res.body).to.have.property('success', false);
20112016
expect(res.body).to.have.property('errorType', 'error-action-not-allowed');
20122017
});
2013-
await updatePermission('create-c', ['admin', 'user']);
2014-
await updatePermission('create-team-channel', ['admin', 'owner', 'moderator']);
20152018
});
20162019

20172020
it('should fail to change a team group to channel when user lacks create-team-channel permission', async () => {
@@ -2026,7 +2029,6 @@ describe('[Groups]', () => {
20262029
expect(res.body).to.have.property('success', false);
20272030
expect(res.body).to.have.property('errorType', 'error-action-not-allowed');
20282031
});
2029-
await updatePermission('create-team-channel', ['admin', 'owner', 'moderator']);
20302032
});
20312033

20322034
it('should succeed changing a team group to channel when user has create-team-channel but not create-c', async () => {
@@ -2043,8 +2045,6 @@ describe('[Groups]', () => {
20432045
expect(res.body).to.have.nested.property('group.t', 'c');
20442046
expect(res.body).to.have.nested.property('group.teamId', team._id);
20452047
});
2046-
await updatePermission('create-c', ['admin', 'user']);
2047-
await updatePermission('create-team-channel', ['admin', 'owner', 'moderator']);
20482048
});
20492049
});
20502050

0 commit comments

Comments
 (0)