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 @@ -22,6 +22,13 @@ const ModerationConsoleTableRow = ({ report, onClick, isDesktopOrLarger }: Moder
return room.fname || room.name;
});

const normalizeMessage = () => {
if (message.startsWith('[ ](')) {
csuadev marked this conversation as resolved.
Show resolved Hide resolved
return message.split('\n')[1];
}
return message;
};

const formatDateAndTime = useFormatDateAndTime();

const concatenatedRoomNames = roomNames.join(', ');
Expand All @@ -31,7 +38,7 @@ 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>{normalizeMessage()}</GenericTableCell>
<GenericTableCell withTruncatedText>{concatenatedRoomNames}</GenericTableCell>
<GenericTableCell withTruncatedText>{formatDateAndTime(ts)}</GenericTableCell>
<GenericTableCell withTruncatedText>{count}</GenericTableCell>
Expand Down
63 changes: 63 additions & 0 deletions apps/meteor/tests/e2e/message-moderation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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;

const singleMessage = "Message to report";
const quotedMessage = "Quoted message to report";

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.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 user1Channel.content.lastUserMessage.hover();
await user1Channel.content.btnOptionQuoteMessage.click();
await user1Channel.content.sendMessage(quotedMessage);
await expect(user1Channel.content.lastUserMessage).toContainText(quotedMessage);

await user1Page.close();
});

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

test.describe('Admin Moderation', async () => {
test('User can report a given 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 expect(poModeration.findRowByName(quotedMessage)).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
37 changes: 37 additions & 0 deletions apps/meteor/tests/e2e/page-objects/moderation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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');
}

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