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
121 lines
4.3 KiB
TypeScript
121 lines
4.3 KiB
TypeScript
import { IS_EE } from './config/constants';
|
|
import { Users } from './fixtures/userStates';
|
|
import { HomeChannel } from './page-objects';
|
|
import { Directory } from './page-objects/directory';
|
|
import { createDirectMessage, createTargetChannel, sendTargetChannelMessage } from './utils';
|
|
import { test, expect } from './utils/test';
|
|
|
|
test.use({ storageState: Users.admin.state });
|
|
|
|
test.describe('Preview public channel', () => {
|
|
let poHomeChannel: HomeChannel;
|
|
let poDirectory: Directory;
|
|
let targetChannel: string;
|
|
let targetChannelMessage: string;
|
|
|
|
// Each test navigates to /home by itself after its API setup is done, otherwise the API mutations
|
|
// can race the client boot (initial cached stores sync) and leave the UI stuck on the loading screen
|
|
test.beforeEach(async ({ page }) => {
|
|
poHomeChannel = new HomeChannel(page);
|
|
poDirectory = new Directory(page);
|
|
});
|
|
|
|
test.beforeAll(async ({ api }) => {
|
|
targetChannel = await createTargetChannel(api);
|
|
targetChannelMessage = await sendTargetChannelMessage(api, targetChannel, { msg: 'This message' });
|
|
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] }] });
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await api.post('/channels.delete', { roomName: targetChannel });
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] }] });
|
|
});
|
|
|
|
test.describe('User', () => {
|
|
test.use({ storageState: Users.user1.state });
|
|
|
|
test('should let user preview public rooms messages', async () => {
|
|
await poDirectory.goto();
|
|
await poDirectory.openChannel(targetChannel);
|
|
|
|
await expect(poHomeChannel.content.lastUserMessageBody).toContainText(targetChannelMessage);
|
|
});
|
|
|
|
test('should disable all composer toolbar actions during channel preview', async () => {
|
|
await poDirectory.goto();
|
|
await poDirectory.openChannel(targetChannel);
|
|
await poHomeChannel.content.waitForChannel();
|
|
|
|
await expect(poHomeChannel.composer.btnJoinRoom).toBeVisible();
|
|
|
|
const actions = await poHomeChannel.composer.allPrimaryActions.all();
|
|
await Promise.all(
|
|
actions.map(async (action) => {
|
|
await expect(action).toBeDisabled();
|
|
}),
|
|
);
|
|
});
|
|
|
|
test('should let user view direct rooms', async ({ api }) => {
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin'] }] });
|
|
await createDirectMessage(api);
|
|
|
|
await poHomeChannel.goto();
|
|
|
|
await poHomeChannel.navbar.openChat(Users.user2.data.username);
|
|
|
|
await expect(poHomeChannel.composer.btnJoinRoom).not.toBeVisible();
|
|
await expect(poHomeChannel.composer.inputMessage).toBeEnabled();
|
|
});
|
|
|
|
test('should not let user role preview public rooms', async ({ api }) => {
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin'] }] });
|
|
|
|
await poDirectory.goto();
|
|
await poDirectory.openChannel(targetChannel);
|
|
|
|
await expect(poHomeChannel.btnJoinChannel).toBeVisible();
|
|
await expect(poHomeChannel.content.lastUserMessageBody).not.toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('App', () => {
|
|
test.skip(!IS_EE, 'Premium Only');
|
|
test.use({ storageState: Users.userNotAllowedByApp.state });
|
|
|
|
test('should prevent user from join the room', async ({ api, page }) => {
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] }] });
|
|
|
|
await poDirectory.goto();
|
|
await poDirectory.openChannel(targetChannel);
|
|
|
|
await expect(poHomeChannel.content.lastUserMessageBody).toContainText(targetChannelMessage);
|
|
|
|
await poHomeChannel.composer.btnJoinRoom.click();
|
|
|
|
await expect(
|
|
page.locator('[role="alert"]', {
|
|
hasText: 'TEST OF NOT ALLOWED USER',
|
|
}),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test('should prevent user from join the room without preview permission', async ({ api, page }) => {
|
|
await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin'] }] });
|
|
|
|
await poDirectory.goto();
|
|
await poDirectory.openChannel(targetChannel);
|
|
await expect(poHomeChannel.content.lastUserMessageBody).not.toBeVisible();
|
|
|
|
await poHomeChannel.btnJoinChannel.click();
|
|
|
|
await expect(
|
|
page.locator('[role="alert"]', {
|
|
hasText: 'TEST OF NOT ALLOWED USER',
|
|
}),
|
|
).toBeVisible();
|
|
});
|
|
});
|
|
});
|