Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove message column on moderation console #32432

Merged
merged 12 commits into from
Jun 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ const ModerationConsoleTable: FC = () => {
>
{t('User')}
</GenericTableHeaderCell>,

<GenericTableHeaderCell
key='reportedMessage'
direction={sortDirection}
active={sortBy === 'reports.description'}
onClick={setSort}
sort='reports.description'
>
{t('Moderation_Reported_message')}
</GenericTableHeaderCell>,
<GenericTableHeaderCell key='room' direction={sortDirection}>
{t('Room')}
</GenericTableHeaderCell>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ModerationConsoleRowProps = {
};

const ModerationConsoleTableRow = ({ report, onClick, isDesktopOrLarger }: ModerationConsoleRowProps): JSX.Element => {
const { userId: _id, rooms, name, count, message, username, ts } = report;
const { userId: _id, rooms, name, count, username, ts } = report;

const roomNames = rooms.map((room) => {
if (room.t === 'd') {
Expand All @@ -31,7 +31,6 @@ const ModerationConsoleTableRow = ({ report, onClick, isDesktopOrLarger }: Moder
<GenericTableCell withTruncatedText>
<UserColumn username={username} name={name} fontSize='micro' size={isDesktopOrLarger ? 'x20' : 'x40'} />
</GenericTableCell>
<GenericTableCell withTruncatedText>{message}</GenericTableCell>
<GenericTableCell withTruncatedText>{concatenatedRoomNames}</GenericTableCell>
<GenericTableCell withTruncatedText>{formatDateAndTime(ts)}</GenericTableCell>
<GenericTableCell withTruncatedText>{count}</GenericTableCell>
Expand Down
61 changes: 61 additions & 0 deletions apps/meteor/tests/e2e/message-moderation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Users } from './fixtures/userStates';
import { Moderation , HomeChannel } from './page-objects';
import { createTargetChannel, deleteChannel } from './utils';
import { test, expect } from './utils/test';

test.use({ storageState: Users.admin.state });

test.describe.serial('Message moderation', () => {
let poModeration: Moderation;
let poHomeChannel: HomeChannel;
let targetChannel: string;

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
poModeration = new Moderation(page);

await page.goto('/home');
});

test.beforeAll(async ({ api }) => {
targetChannel = await createTargetChannel(api);
});

test.describe('Moderation Console', () => {
const singleMessage = "Message to report";

test.beforeAll(async ({ browser }) => {
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage(singleMessage);
await expect(user1Channel.content.lastUserMessage).toContainText(singleMessage);

await user1Page.close();
});

test.afterAll(async ({ api }) => {
await deleteChannel(api, targetChannel);
});

test.describe('Message reporting', async () => {
test('User can report a given text message', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.openLastMessageMenu();
await poModeration.reportMsgButton.click();
await expect(poModeration.reportMessageModal).toBeVisible();
await poModeration.reportMessageReasonText.fill('Reason to report');
await poModeration.reportMessageReasonSubmit.click();
await expect(poModeration.toastSuccess).toBeVisible();
});

test('Admin can see the reported messages', async ({ page }) => {
await page.goto('/admin/moderation/messages');
await expect(poModeration.reportedMessagesTab).toBeVisible();
await poModeration.findRowByName(targetChannel).click();
await expect(poModeration.findLastReportedMessage(singleMessage)).toBeVisible();
});
});
});
csuadev marked this conversation as resolved.
Show resolved Hide resolved
});
csuadev marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions apps/meteor/tests/e2e/page-objects/fragments/home-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class HomeContent {
return this.page.locator('[data-qa-id="edit-message"]');
}

get btnOptionQuoteMessage(): Locator {
return this.page.getByRole('button', { name: 'Quote' });
}

MarcosSpessatto marked this conversation as resolved.
Show resolved Hide resolved
get btnOptionDeleteMessage(): Locator {
return this.page.locator('[data-qa-id="delete-message"]');
}
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './auth';
export * from './home-channel';
export * from './home-discussion';
export * from './home-team';
export * from './moderation';
export * from './omnichannel-agents';
export * from './omnichannel-departments';
export * from './omnichannel-current-chats';
Expand Down
41 changes: 41 additions & 0 deletions apps/meteor/tests/e2e/page-objects/moderation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Locator, Page } from '@playwright/test';

export class Moderation {
private readonly page: Page;

constructor(page: Page) {
this.page = page;
}

get reportedMessagesTab(): Locator {
return this.page.locator('button:has-text("Reported messages")');
}

get reportMsgButton(): Locator {
return this.page.locator('role=menuitem[name="Report"]');
}

get reportMessageModal(): Locator {
return this.page.locator('dialog h2:has-text("Report this message?")');
}

get reportMessageReasonText(): Locator {
return this.page.locator('textarea[name="description"]');
}

get reportMessageReasonSubmit(): Locator {
return this.page.locator('button[type="submit"]');
}

get toastSuccess(): Locator {
return this.page.locator('.rcx-toastbar.rcx-toastbar--success');
}

findLastReportedMessage(quotedMessage: string): Locator {
return this.page.locator(`text=${quotedMessage}`).first();
}

findRowByName(name: string): Locator {
return this.page.locator(`tr:has-text("${name}")`);
}
}
Loading