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
125 lines
4.4 KiB
TypeScript
125 lines
4.4 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { Users } from './fixtures/userStates';
|
|
import { AdminModeration, HomeChannel } from './page-objects';
|
|
import { ReportMessageModal } from './page-objects/fragments';
|
|
import { createTargetChannel, deleteChannel } from './utils';
|
|
import { test, expect } from './utils/test';
|
|
|
|
test.use({ storageState: Users.user1.state });
|
|
|
|
test.describe.serial('report message', () => {
|
|
let poHomeChannel: HomeChannel;
|
|
let adminHomeChannel: HomeChannel;
|
|
let targetChannel: string;
|
|
let adminPage: Page;
|
|
let reportModal: ReportMessageModal;
|
|
|
|
test.beforeAll(async ({ api, browser }) => {
|
|
targetChannel = await createTargetChannel(api, { members: ['user1', 'admin'] });
|
|
adminPage = await browser.newPage({ storageState: Users.admin.state });
|
|
reportModal = new ReportMessageModal(adminPage);
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await Promise.all([
|
|
api.post('/moderation.user.deleteReportedMessages', {
|
|
userId: 'user1',
|
|
}),
|
|
deleteChannel(api, targetChannel),
|
|
adminPage.close(),
|
|
]);
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
poHomeChannel = new HomeChannel(page);
|
|
adminHomeChannel = new HomeChannel(adminPage);
|
|
|
|
await poHomeChannel.gotoChannel(targetChannel);
|
|
await adminHomeChannel.gotoChannel(targetChannel);
|
|
});
|
|
|
|
test('should show report message option in message menu for other users messages', async () => {
|
|
await test.step('send message as user1', async () => {
|
|
const testMessage = faker.lorem.sentence();
|
|
await poHomeChannel.content.sendMessage(testMessage);
|
|
});
|
|
|
|
await test.step('verify report option is visible for the other user', async () => {
|
|
await adminHomeChannel.content.openLastMessageMenu();
|
|
await expect(adminPage.getByRole('menuitem', { name: 'Report' })).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test('should not show report message option in message menu for own messages', async ({ page }) => {
|
|
await test.step('send message as user1', async () => {
|
|
const testMessage = faker.lorem.sentence();
|
|
await poHomeChannel.content.sendMessage(testMessage);
|
|
});
|
|
|
|
await test.step('verify report option is not visible for own message', async () => {
|
|
await poHomeChannel.content.openLastMessageMenu();
|
|
await expect(page.getByRole('menuitem', { name: 'Report' })).not.toBeVisible();
|
|
});
|
|
});
|
|
|
|
test('should validate empty report description', async () => {
|
|
await test.step('send message as user1', async () => {
|
|
const testMessage = faker.lorem.sentence();
|
|
await poHomeChannel.content.sendMessage(testMessage);
|
|
});
|
|
|
|
await test.step('try to submit empty report', async () => {
|
|
await adminHomeChannel.content.openLastMessageMenu();
|
|
await adminPage.getByRole('menuitem', { name: 'Report' }).click();
|
|
await reportModal.submitReport();
|
|
});
|
|
});
|
|
|
|
test('should be able to cancel reporting a message', async () => {
|
|
await test.step('send message as user1', async () => {
|
|
const testMessage = faker.lorem.sentence();
|
|
await poHomeChannel.content.sendMessage(testMessage);
|
|
});
|
|
|
|
await test.step('open and cancel report modal', async () => {
|
|
await adminHomeChannel.content.openLastMessageMenu();
|
|
await adminPage.getByRole('menuitem', { name: 'Report' }).click();
|
|
await reportModal.cancelReport();
|
|
});
|
|
});
|
|
|
|
test('should successfully report a message and verify its appearance in moderation console', async () => {
|
|
let testMessage: string;
|
|
let reportDescription: string;
|
|
|
|
await test.step('send message as user1', async () => {
|
|
testMessage = faker.lorem.sentence();
|
|
await poHomeChannel.content.sendMessage(testMessage);
|
|
});
|
|
|
|
await test.step('report message as the other user', async () => {
|
|
reportDescription = faker.lorem.sentence();
|
|
|
|
await adminHomeChannel.content.openLastMessageMenu();
|
|
await adminPage.getByRole('menuitem', { name: 'Report' }).click();
|
|
await reportModal.submitReport(reportDescription);
|
|
});
|
|
|
|
await test.step('verify report in moderation console', async () => {
|
|
await new AdminModeration(adminPage).gotoMessages();
|
|
|
|
await expect(adminPage.getByRole('tab', { name: 'Reported messages' })).toBeVisible();
|
|
const reportedUserLink = adminPage.getByRole('table').getByRole('link', { name: 'user1' });
|
|
await expect(reportedUserLink).toBeVisible();
|
|
await reportedUserLink.click();
|
|
|
|
await expect(adminPage.getByText(testMessage)).toBeVisible();
|
|
|
|
await adminPage.getByRole('button', { name: 'Show reports' }).click();
|
|
await expect(adminPage.getByText(reportDescription)).toBeVisible();
|
|
});
|
|
});
|
|
});
|