Skip to content

Commit

Permalink
feat: convert report user test to Playwright (#54683)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
  • Loading branch information
Sembauke and ojeytonwilliams committed May 10, 2024
1 parent 074172e commit 3da9d0e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
1 change: 0 additions & 1 deletion client/src/client-only-routes/show-user.tsx
Expand Up @@ -124,7 +124,6 @@ function ShowUser({
<FormGroup controlId='report-user-textarea'>
<ControlLabel>{t('report.what')}</ControlLabel>
<FormControl
data-cy='report-user'
componentClass='textarea'
onChange={handleChange}
placeholder={t('report.details')}
Expand Down
21 changes: 0 additions & 21 deletions cypress/e2e/default/user/report-user.ts

This file was deleted.

31 changes: 31 additions & 0 deletions e2e/report-user.spec.ts
@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.use({ storageState: 'playwright/.auth/certified-user.json' });

// To run this test you will need to run the email server.
// To do this: https://contribute.freecodecamp.org/#/how-to-catch-outgoing-emails-locally?id=using-mailhog

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').nth(1).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 foo@bar.com in copy'
);
});

0 comments on commit 3da9d0e

Please sign in to comment.