Skip to content

Commit 704f48b

Browse files
committed
fix: change test position and reduce unnecessary permission api call
1 parent c144392 commit 704f48b

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

apps/meteor/tests/e2e/message-actions.spec.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,34 +165,30 @@ test.describe.serial('message-actions', () => {
165165
test.describe.serial('expect reply in direct message', () => {
166166
test.use({ storageState: Users.user2.state });
167167

168-
let originalCreateDRoles: string[];
168+
let defaultCreateDRoles: string[];
169169

170170
test.beforeAll(async ({ api }) => {
171-
originalCreateDRoles = await getPermissionRoles(api, 'create-d');
171+
defaultCreateDRoles = await getPermissionRoles(api, 'create-d');
172172

173173
await sendTargetChannelMessage(api, targetChannel, { msg: 'message from admin for reply in DM' });
174174
});
175175

176-
test('expect option not be visible without create-d permission and no existing DM', async ({ api }) => {
177-
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: ['admin'] }] })).status()).toBe(200);
178-
176+
test('expect option be visible and redirect to DM', async ({ page }) => {
179177
await poHomeChannel.content.openLastMessageMenu();
180-
await expect(poHomeChannel.content.btnOptionReplyInDm).toBeHidden();
178+
await poHomeChannel.content.btnOptionReplyInDm.click();
179+
180+
await expect(page).toHaveURL(/.*reply/);
181181
});
182182

183-
test('expect option be visible and redirect to DM', async ({ page, api }) => {
184-
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: originalCreateDRoles }] })).status()).toBe(
185-
200,
186-
);
183+
test('expect option not be visible without create-d permission and no existing DM', async ({ api }) => {
184+
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: ['admin'] }] })).status()).toBe(200);
187185

188186
await poHomeChannel.content.openLastMessageMenu();
189-
await poHomeChannel.content.btnOptionReplyInDm.click();
190-
191-
await expect(page).toHaveURL(/.*reply/);
187+
await expect(poHomeChannel.content.btnOptionReplyInDm).toBeHidden();
192188
});
193189

194190
test.afterAll(async ({ api }) => {
195-
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: originalCreateDRoles }] })).status()).toBe(
191+
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: defaultCreateDRoles }] })).status()).toBe(
196192
200,
197193
);
198194
});

0 commit comments

Comments
 (0)