Skip to content

Commit fb94129

Browse files
committed
test: add e2e tests for Reply in DM permission visibility
1 parent 69e575d commit fb94129

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

apps/meteor/tests/e2e/permissions.spec.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Users } from './fixtures/userStates';
22
import { HomeChannel } from './page-objects';
3-
import { createTargetChannel } from './utils';
3+
import { createTargetChannel, sendTargetChannelMessage } from './utils';
44
import { test, expect } from './utils/test';
55

66
test.use({ storageState: Users.user2.state });
@@ -186,6 +186,47 @@ test.describe.serial('permissions', () => {
186186
});
187187
});
188188

189+
test.describe.serial('Reply in direct message', () => {
190+
let replyDMChannel: string;
191+
192+
test.beforeAll(async ({ api }) => {
193+
replyDMChannel = await createTargetChannel(api, { members: ['user2'] });
194+
await sendTargetChannelMessage(api, replyDMChannel, { msg: 'message from admin for reply in DM' });
195+
});
196+
197+
test('expect option (reply in direct message) not be visible without create-d permission and no existing DM', async ({ page, api }) => {
198+
expect((await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: ['admin'] }] })).status()).toBe(200);
199+
200+
await poHomeChannel.navbar.openChat(replyDMChannel);
201+
202+
await expect(page.locator('.rcx-message', { hasText: 'message from admin for reply in DM' })).not.toHaveAttribute(
203+
'aria-busy',
204+
'true',
205+
);
206+
207+
await poHomeChannel.content.openLastMessageMenu();
208+
await expect(page.locator('role=menuitem[name="Reply in direct message"]')).toBeHidden();
209+
});
210+
211+
test('expect option (reply in direct message) be visible and redirect to DM', async ({ page, api }) => {
212+
expect(
213+
(await api.post('/permissions.update', { permissions: [{ _id: 'create-d', roles: ['admin', 'user', 'bot', 'app'] }] })).status(),
214+
).toBe(200);
215+
216+
await poHomeChannel.navbar.openChat(replyDMChannel);
217+
218+
await expect(page.locator('.rcx-message', { hasText: 'message from admin for reply in DM' })).not.toHaveAttribute(
219+
'aria-busy',
220+
'true',
221+
);
222+
223+
await poHomeChannel.content.openLastMessageMenu();
224+
await page.locator('role=menuitem[name="Reply in direct message"]').click();
225+
226+
await expect(page).toHaveURL(/.*reply/);
227+
});
228+
});
229+
189230
test.describe.serial('Filter words', () => {
190231
test.beforeAll(async ({ api }) => {
191232
const statusCode1 = (await api.post('/settings/Message_AllowBadWordsFilter', { value: true })).status();

0 commit comments

Comments
 (0)