Skip to content

Commit

Permalink
test(integration): add cases for editing a community
Browse files Browse the repository at this point in the history
This change adds test cases for seeing or not the edit community button.

I've had to add a label to the button to select it, which also helps make it a little more accessible.

Refs #388, #431
  • Loading branch information
thewilkybarkid committed Dec 14, 2021
1 parent 572d696 commit fa31ef1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
35 changes: 35 additions & 0 deletions integration/src/browser/edit-community.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { expect, test } from './test';
import { screenshot } from './utils';

test.asACommunityModerator(
'can edit a community',
async ({ community, page }) => {
await page.goto(`/communities/${community.slug}`);

const editButton = page.locator('[aria-label="Edit this community"]');

await expect(editButton).toBeVisible();
expect(await screenshot(page, editButton)).toMatchSnapshot(
'edit-button.png',
);

await editButton.click();

const editForm = page.locator('form');

await expect(editForm).toContainText('Enter a description');
expect(await screenshot(page, editForm)).toMatchSnapshot('edit-page.png');
},
);

test.asACommunityMember(
'cannot edit a community',
async ({ community, page }) => {
await page.goto(`/communities/${community.slug}`);

const editButton = page.locator('[aria-label="Edit this community"]');

await expect(page.locator('body')).toContainText(community.name);
await expect(editButton).not.toBeVisible();
},
);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/frontend/components/Community.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export default function Community(props) {
<Box p={4}>
{isOwner ? (
<IconButton
aria-label="Edit this community"
href={`/community-settings/${community.uuid}`}
className={classes.settings}
>
Expand Down

0 comments on commit fa31ef1

Please sign in to comment.