Files
upstream-rocketchat/apps/meteor/tests/e2e/channel-management.spec.ts
upstream-mirror 30810eecd7
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

356 lines
15 KiB
TypeScript

import { faker } from '@faker-js/faker';
import type { Page } from '@playwright/test';
import { IS_EE } from './config/constants';
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { CreateNewDiscussionModal } from './page-objects/fragments';
import { createTargetChannel } from './utils';
import { test, expect } from './utils/test';
test.use({ storageState: Users.admin.state });
test.describe.serial('channel-management', () => {
let poHomeChannel: HomeChannel;
let targetChannel: string;
let discussionName: string;
test.beforeAll(async ({ api }) => {
targetChannel = await createTargetChannel(api);
});
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
await poHomeChannel.goto();
});
// TODO: this should be replaced by a unit test
test('should navigate on toolbar using arrow keys', async ({ page }) => {
const roomHeaderFavoriteBtn = poHomeChannel.getRoomHeaderFavoriteBtn(IS_EE);
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.content.sendMessage('hello composer');
await roomHeaderFavoriteBtn.focus();
await expect(roomHeaderFavoriteBtn).toBeFocused();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('ArrowRight');
await page.keyboard.press('ArrowRight');
await expect(poHomeChannel.roomHeaderToolbar.getByRole('button', { name: 'Threads', exact: true })).toBeFocused();
});
// TODO: this should be replaced by a unit test
test('should move the focus away from toolbar using tab key', async ({ page }) => {
const roomHeaderFavoriteBtn = poHomeChannel.getRoomHeaderFavoriteBtn(IS_EE);
await poHomeChannel.navbar.openChat(targetChannel);
await roomHeaderFavoriteBtn.focus();
await expect(roomHeaderFavoriteBtn).toBeFocused();
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
await expect(poHomeChannel.roomHeaderToolbar.getByRole('button', { name: 'Call' })).not.toBeFocused();
});
test('should add user1 to targetChannel', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.addUser('user1');
await expect(poHomeChannel.tabs.members.memberOption('user1')).toBeVisible();
await expect(poHomeChannel.content.getSystemMessageByText('added user1')).toBeVisible();
});
test('should edit topic of targetChannel', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openRoomInfo();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.editRoom.inputTopic.fill('hello-topic-edited');
await poHomeChannel.tabs.editRoom.btnSave.click();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.roomToolbar.openRoomInfo();
await expect(poHomeChannel.tabs.room.root).toContainText('hello-topic-edited');
await expect(poHomeChannel.content.getSystemMessageByText('changed room topic to hello-topic-edited')).toBeVisible();
});
test('should edit announcement of targetChannel', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openRoomInfo();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.editRoom.inputAnnouncement.fill('hello-announcement-edited');
await poHomeChannel.tabs.editRoom.btnSave.click();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.roomToolbar.openRoomInfo();
await expect(poHomeChannel.tabs.room.root).toContainText('hello-announcement-edited');
await expect(poHomeChannel.content.getSystemMessageByText('changed room announcement to: hello-announcement-edited')).toBeVisible();
});
test('should edit description of targetChannel', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openRoomInfo();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.editRoom.inputDescription.fill('hello-description-edited');
await poHomeChannel.tabs.editRoom.btnSave.click();
await poHomeChannel.toastMessage.dismissToast();
await poHomeChannel.roomToolbar.openRoomInfo();
await expect(poHomeChannel.tabs.room.root).toContainText('hello-description-edited');
await expect(poHomeChannel.content.getSystemMessageByText('changed room description to: hello-description-edited')).toBeVisible();
});
test('should edit name of targetChannel', async ({ page }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openRoomInfo();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.editRoom.inputName.fill(`NAME-EDITED-${targetChannel}`);
await poHomeChannel.tabs.editRoom.btnSave.click();
targetChannel = `NAME-EDITED-${targetChannel}`;
await expect(page.getByRole('main').getByRole('heading', { name: targetChannel })).toBeVisible();
await poHomeChannel.navbar.openChat(targetChannel);
await expect(page).toHaveURL(`/channel/${targetChannel}`);
});
test.skip('should truncate the room name for small screens', async ({ page }) => {
const hugeName = faker.string.alpha(200);
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openRoomInfo();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.editRoom.inputName.fill(hugeName);
await poHomeChannel.tabs.editRoom.btnSave.click();
targetChannel = hugeName;
await page.setViewportSize({ width: 640, height: 460 });
await expect(page.getByRole('heading', { name: hugeName })).toHaveCSS('width', '407px');
});
test('should open sidebar clicking on sidebar toggler', async ({ page }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await page.setViewportSize({ width: 640, height: 460 });
await page.getByRole('button', { name: 'Open sidebar' }).click();
await expect(page.getByRole('navigation', { name: 'Sidebar' })).toBeVisible();
});
test('should open room info when clicking on roomName', async ({ page }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.getBtnOpenRoomInfo(targetChannel).focus();
await expect(poHomeChannel.getBtnOpenRoomInfo(targetChannel)).toBeFocused();
await page.keyboard.press('Space');
await page.getByRole('dialog').waitFor();
await expect(page.getByRole('dialog')).toBeVisible();
});
test('should create a discussion using the message composer', async ({ page }) => {
discussionName = faker.string.uuid();
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.composer.btnMenuMoreActions.click();
await page.getByRole('menuitem', { name: 'Discussion' }).click();
const createDiscussionModal = new CreateNewDiscussionModal(page);
await createDiscussionModal.inputName.fill(discussionName);
await createDiscussionModal.create();
await expect(page.getByRole('heading', { name: discussionName })).toBeVisible();
});
test('should access targetTeam through discussion header', async ({ page }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await page.getByRole('listitem', { name: discussionName }).getByRole('button', { name: 'Reply' }).click();
await page.getByRole('button', { name: `Back to ${targetChannel} channel`, exact: true }).focus();
await expect(page.getByRole('button', { name: `Back to ${targetChannel} channel`, exact: true })).toBeFocused();
await page.keyboard.press('Space');
await expect(page).toHaveURL(`/channel/${targetChannel}`);
});
test('should edit notification preferences of targetChannel', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMoreOptions();
await poHomeChannel.roomToolbar.menuItemNotificationsPreferences.click();
await poHomeChannel.tabs.notificationPreferences.updateAllNotificationPreferences();
await poHomeChannel.tabs.notificationPreferences.btnSave.click();
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Desktop')).toContainText('Mentions');
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Mobile')).toContainText('Mentions');
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Email')).toContainText('Mentions');
});
test.describe.serial('cross user tests', () => {
let user1Page: Page;
test.beforeEach(async ({ browser }) => {
user1Page = await browser.newPage({ storageState: Users.user1.state });
});
test.afterEach(async () => {
await user1Page.close();
});
test('should mute user1', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.muteUser('user1');
await expect(poHomeChannel.content.getSystemMessageByText('muted user1')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await expect(user1Channel.composer.readOnlyFooter).toBeVisible();
});
test('should unmuteUser user1', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.unmuteUser('user1');
await expect(poHomeChannel.content.getSystemMessageByText('unmuted user1')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await expect(user1Channel.composer.inputMessage).toBeVisible();
});
test('should set user1 as moderator', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsModerator('user1');
await expect(poHomeChannel.content.getSystemMessageByText('set user1 as moderator')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await user1Channel.roomToolbar.openRoomInfo();
await expect(user1Channel.tabs.room.btnEdit).toBeVisible();
});
test('should set user1 as owner', async ({ browser }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsOwner('user1');
await expect(poHomeChannel.content.getSystemMessageByText('set user1 as owner')).toBeVisible();
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await user1Channel.roomToolbar.openRoomInfo();
await user1Channel.tabs.room.btnMore.click();
await expect(user1Channel.tabs.room.optionDelete).toBeVisible();
await user1Page.close();
});
test('should ignore user1 messages', async ({ page }) => {
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.ignoreUser('user1');
await poHomeChannel.toastMessage.waitForDisplay({ type: 'success', message: 'User has been ignored' });
await poHomeChannel.tabs.members.userInfo.openMoreActions();
await expect(poHomeChannel.tabs.members.userInfo.menu.getMenuItem('Unignore')).toBeVisible();
await page.keyboard.press('Escape');
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await user1Channel.content.sendMessage('message to check ignore');
await expect(poHomeChannel.content.lastUserMessageBody.getByRole('button', { name: 'This message was ignored' })).toBeVisible();
await user1Channel.content.openReplyInThread();
await user1Channel.content.waitForThread();
await user1Channel.content.toggleAlsoSendThreadToChannel(false);
await user1Channel.content.sendMessageInThread('thread reply from an ignored user');
await poHomeChannel.content.openReplyInThread();
await poHomeChannel.content.waitForThread();
await expect(poHomeChannel.content.threadMessageListItems).toHaveCount(2);
await expect(poHomeChannel.content.ignoredThreadMessages).toHaveCount(2);
await expect(poHomeChannel.content.threadMessageList).not.toContainText('thread reply from an ignored user');
});
test('should unignore single user1 message', async () => {
await poHomeChannel.navbar.openChat(targetChannel);
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await user1Channel.content.sendMessage('only message to be unignored');
await poHomeChannel.navbar.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.content.lastIgnoredUserMessage.click();
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('only message to be unignored');
await user1Channel.content.openReplyInThread();
await user1Channel.content.waitForThread();
await user1Channel.content.toggleAlsoSendThreadToChannel(false);
await user1Channel.content.sendMessageInThread('thread reply that stays ignored');
await user1Channel.content.sendMessageInThread('thread reply to be revealed');
await poHomeChannel.content.openReplyInThread();
await poHomeChannel.content.waitForThread();
await expect(poHomeChannel.content.ignoredThreadMessages).toHaveCount(3);
await poHomeChannel.content.lastIgnoredThreadMessage.click();
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('thread reply to be revealed');
await expect(poHomeChannel.content.ignoredThreadMessages).toHaveCount(2);
});
test('should unignore user1 messages', async ({ page }) => {
const user1Channel = new HomeChannel(user1Page);
await user1Channel.gotoChannel(targetChannel);
await user1Channel.content.sendMessage('message before being unignored');
await poHomeChannel.navbar.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.roomToolbar.openMembersTab();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.unignoreUser('user1');
await poHomeChannel.tabs.members.userInfo.openMoreActions();
await expect(poHomeChannel.tabs.members.userInfo.menu.getMenuItem('Ignore')).toBeVisible();
await page.keyboard.press('Escape');
await user1Channel.content.sendMessage('message after being unignored');
await expect(poHomeChannel.content.nthMessage(-2)).toContainText('message before being unignored');
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('message after being unignored');
});
test('should readOnlyChannel show join button', async () => {
const channelName = faker.string.uuid();
await poHomeChannel.navbar.createNew('Channel', channelName, { private: false, readOnly: true });
const channel = new HomeChannel(user1Page);
await channel.gotoChannel(channelName);
await expect(user1Page.getByRole('button', { name: 'Join', exact: true })).toBeVisible();
});
});
});