Files
coder/site/e2e/tests/groups/createGroup.spec.ts
T
ケイラ 962608cde0 chore: allow signing in as non-admin users in e2e tests (#15892)
Closes coder/internal#168

Gets rid of the "global state" authentication, and adds a `login` helper
which should be called at the beginning of each test. This means that
not every test needs to authenticated as admin, and we can even have
tests that encompass multiple permission levels.

We also now create more than just the single admin user during setup, so
that we can have a set of users to pick from as appropriate.
2024-12-19 16:16:34 -07:00

36 lines
1.2 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { randomName, requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
});
test("create group", async ({ page, baseURL }) => {
requiresLicense();
await page.goto(`${baseURL}/groups`, { waitUntil: "domcontentloaded" });
await expect(page).toHaveTitle("Groups - Coder");
await page.getByText("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();
await expect(page.getByText("No members yet")).toBeVisible();
});