mirror of
https://github.com/coder/coder.git
synced 2026-06-04 05:28:20 +00:00
962608cde0
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.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { createUser, getCurrentOrgId, setupApiCalls } from "../../api";
|
|
import { login } from "../../helpers";
|
|
import { beforeCoderTest } from "../../hooks";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
beforeCoderTest(page);
|
|
await login(page);
|
|
await setupApiCalls(page);
|
|
});
|
|
|
|
test("remove user", async ({ page, baseURL }) => {
|
|
const orgId = await getCurrentOrgId();
|
|
const user = await createUser(orgId);
|
|
|
|
await page.goto(`${baseURL}/users`, { waitUntil: "domcontentloaded" });
|
|
await expect(page).toHaveTitle("Users - Coder");
|
|
|
|
const userRow = page.getByRole("row", { name: user.email });
|
|
await userRow.getByRole("button", { name: "More options" }).click();
|
|
const menu = page.locator("#more-options");
|
|
await menu.getByText("Delete").click();
|
|
|
|
const dialog = page.getByTestId("dialog");
|
|
await dialog.getByLabel("Name of the user to delete").fill(user.username);
|
|
await dialog.getByRole("button", { name: "Delete" }).click();
|
|
|
|
await expect(page.getByText("Successfully deleted the user.")).toBeVisible();
|
|
});
|