Skip to content

chore(site): add e2e tests for groups #12866

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

Merged
merged 11 commits into from
Apr 5, 2024
Merged
Next Next commit
Add create group test
  • Loading branch information
BrunoQuaresma committed Apr 4, 2024
commit f9c376cb51a14204ec4a2315c76bbc455172ee36
27 changes: 27 additions & 0 deletions site/e2e/tests/groups/createGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from "@playwright/test";
import { randomName } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => await beforeCoderTest(page));

test("create group", async ({ page, baseURL }) => {
await page.goto(`${baseURL}/groups`, { waitUntil: "domcontentloaded" });
await expect(page).toHaveTitle("Groups - Coder");

await page.getByRole("button", { name: "Create group" }).click();
await expect(page).toHaveTitle("Create Group - Coder");

const name = randomName();
const groupValues = {
name: name,
displayName: `Display Name for ${name}`,
avatarURL: "/emojis/1f60d.png",
};

await page.getByLabel("Name", { exact: true }).fill(groupValues.name);
await page.getByLabel("Display Name").fill(groupValues.displayName);
await page.getByLabel("Avatar URL").fill(groupValues.avatarURL);
await page.getByRole("button", { name: "Submit" }).click();
await expect(page).toHaveTitle(`${groupValues.displayName} - Coder`);
await expect(page.getByText(groupValues.displayName)).toBeVisible();
});
11 changes: 7 additions & 4 deletions site/src/pages/UsersPage/UsersLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import GroupAdd from "@mui/icons-material/GroupAddOutlined";
import PersonAdd from "@mui/icons-material/PersonAddOutlined";
import Button from "@mui/material/Button";
import Link from "@mui/material/Link";
import { type FC, Suspense } from "react";
import {
Link as RouterLink,
Expand Down Expand Up @@ -43,9 +42,13 @@ export const UsersLayout: FC = () => {
</Button>
)}
{canCreateGroup && isTemplateRBACEnabled && (
<Link component={RouterLink} to="/groups/create">
<Button startIcon={<GroupAdd />}>Create group</Button>
</Link>
<Button
component={RouterLink}
startIcon={<GroupAdd />}
to="/groups/create"
>
Create group
</Button>
)}
</>
}
Expand Down