forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport-user.spec.ts
47 lines (39 loc) · 1.33 KB
/
report-user.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { test, expect } from '@playwright/test';
import {
deleteAllEmails,
getAllEmails,
getFirstEmail,
getSubject
} from './utils/mailhog';
test.beforeEach(async () => {
await deleteAllEmails();
});
test('should be possible to report a user from their profile page', async ({
page
}) => {
await page.goto('/twaha');
// If you build the client locally, delete the button click below.
if (!process.env.CI) {
await page.getByRole('button', { name: 'Preview custom 404 page' }).click();
}
await page.getByText("Flag This User's Account for Abuse").click();
await expect(
page.getByText("Do you want to report twaha's portfolio for abuse?")
).toBeVisible();
await page
.getByRole('textbox', { name: 'What would you like to report?' })
.fill('Some details');
await page.getByRole('button', { name: 'Submit the report' }).click();
await expect(page).toHaveURL('/learn');
await expect(page.getByTestId('flash-message')).toBeVisible();
await expect(page.getByTestId('flash-message')).toContainText(
'A report was sent to the team with [email protected] in copy'
);
await expect(async () => {
const emails = await getAllEmails();
expect(emails.items).toHaveLength(1);
expect(getSubject(getFirstEmail(emails))).toBe(
"Abuse Report : Reporting twaha's profile."
);
}).toPass();
});