mirror of https://github.com/coder/coder.git
chore: add e2e tests for template permissions (#12731)
This commit is contained in:
parent
eeb3d63be6
commit
1d2d008b45
|
@ -3,7 +3,7 @@ import { Language } from "pages/CreateUserPage/CreateUserForm";
|
|||
import * as constants from "./constants";
|
||||
import { storageState } from "./playwright.config";
|
||||
|
||||
test("setup first user", async ({ page }) => {
|
||||
test("setup deployment", async ({ page }) => {
|
||||
await page.goto("/", { waitUntil: "domcontentloaded" });
|
||||
|
||||
// Setup first user
|
||||
|
|
|
@ -150,6 +150,21 @@ export const createTemplate = async (
|
|||
return name;
|
||||
};
|
||||
|
||||
// createGroup navigates to the /groups/create page and creates a group with a
|
||||
// random name.
|
||||
export const createGroup = async (page: Page): Promise<string> => {
|
||||
await page.goto("/groups/create", { waitUntil: "domcontentloaded" });
|
||||
await expect(page).toHaveURL("/groups/create");
|
||||
|
||||
const name = randomName();
|
||||
await page.getByLabel("Name", { exact: true }).fill(name);
|
||||
await page.getByTestId("form-submit").click();
|
||||
await expect(page).toHaveURL(
|
||||
/\/groups\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,
|
||||
);
|
||||
return name;
|
||||
};
|
||||
|
||||
// sshIntoWorkspace spawns a Coder SSH process and a client connected to it.
|
||||
export const sshIntoWorkspace = async (
|
||||
page: Page,
|
||||
|
|
|
@ -22,7 +22,7 @@ export default defineConfig({
|
|||
testMatch: /.*\.spec\.ts/,
|
||||
dependencies: ["testsSetup"],
|
||||
use: { storageState },
|
||||
timeout: 60_000,
|
||||
timeout: 20_000,
|
||||
},
|
||||
],
|
||||
reporter: [["./reporter.ts"]],
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
import {
|
||||
createGroup,
|
||||
createTemplate,
|
||||
requiresEnterpriseLicense,
|
||||
updateTemplateSettings,
|
||||
|
@ -15,6 +16,32 @@ test("template update with new name redirects on successful submit", async ({
|
|||
});
|
||||
});
|
||||
|
||||
test("add and remove a group", async ({ page }) => {
|
||||
requiresEnterpriseLicense();
|
||||
|
||||
const templateName = await createTemplate(page);
|
||||
const groupName = await createGroup(page);
|
||||
|
||||
await page.goto(`/templates/${templateName}/settings/permissions`, {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await expect(page).toHaveURL(
|
||||
`/templates/${templateName}/settings/permissions`,
|
||||
);
|
||||
|
||||
// Type the first half of the group name
|
||||
await page
|
||||
.getByPlaceholder("Search for user or group", { exact: true })
|
||||
.fill(groupName.slice(0, 4));
|
||||
|
||||
// Select the group from the list and add it
|
||||
await page.getByText(groupName).click();
|
||||
await page.getByText("Add member").click();
|
||||
await expect(
|
||||
page.locator(".MuiTable-root").getByText(groupName),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("require latest version", async ({ page }) => {
|
||||
requiresEnterpriseLicense();
|
||||
|
||||
|
|
Loading…
Reference in New Issue