Files
coder/site/e2e/tests/updateTemplate.spec.ts
T
Jaayden Halko d9ef6ed8ae chore: replace MoreMenu with DropdownMenu (#17615)
Replace MoreMenu with DropDownMenu component to match update design
patterns.

Note: This was the result of experimentation using Cursor to make the
changes and Claude Code for fixing tests.

One key takeaway is that verbose e2e logging, especially benign
warnings/errors can confuse Claude Code in running playwright and
confirming its work.


<img width="201" alt="Screenshot 2025-05-01 at 00 00 52"
src="https://github.com/user-attachments/assets/4905582e-902e-4b61-adc8-14cab6bd006b"
/>
<img width="257" alt="Screenshot 2025-05-01 at 00 01 07"
src="https://github.com/user-attachments/assets/5befc420-724a-4c57-9a9d-330a39867fae"
/>
<img width="270" alt="Screenshot 2025-05-01 at 00 01 20"
src="https://github.com/user-attachments/assets/9cbf07cb-7d44-4228-ae6f-216e9f2faed0"
/>
<img width="224" alt="Screenshot 2025-05-01 at 00 01 30"
src="https://github.com/user-attachments/assets/9fe95916-3d9d-4600-9b1f-8a620e152a53"
/>
2025-05-01 13:14:11 -04:00

84 lines
2.4 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { defaultOrganizationName, users } from "../constants";
import { expectUrl } from "../expectUrl";
import {
createGroup,
createTemplate,
login,
requiresLicense,
updateTemplateSettings,
} from "../helpers";
import { beforeCoderTest } from "../hooks";
test.describe.configure({ mode: "parallel" });
test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page, users.templateAdmin);
});
test("template update with new name redirects on successful submit", async ({
page,
}) => {
const templateName = await createTemplate(page);
await updateTemplateSettings(page, templateName, {
name: "new-name",
});
});
test("add and remove a group", async ({ page }) => {
requiresLicense();
await login(page, users.userAdmin);
const orgName = defaultOrganizationName;
const groupName = await createGroup(page, orgName);
await login(page, users.templateAdmin);
const templateName = await createTemplate(page);
await page.goto(
`/templates/${orgName}/${templateName}/settings/permissions`,
{ waitUntil: "domcontentloaded" },
);
// 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();
const row = page.locator(".MuiTableRow-root", { hasText: groupName });
await expect(row).toBeVisible();
// Now remove the group
await row.getByRole("button", { name: "Open menu" }).click();
const menu = page.getByRole("menu");
await menu.getByText("Remove").click();
await expect(page.getByText("Group removed successfully!")).toBeVisible();
await expect(row).not.toBeVisible();
});
test("require latest version", async ({ page }) => {
requiresLicense();
const templateName = await createTemplate(page);
await page.goto(`/templates/${templateName}/settings`, {
waitUntil: "domcontentloaded",
});
await expectUrl(page).toHavePathName(`/templates/${templateName}/settings`);
let checkbox = await page.waitForSelector("#require_active_version");
await checkbox.click();
await page.getByRole("button", { name: /save/i }).click();
await page.goto(`/templates/${templateName}/settings`, {
waitUntil: "domcontentloaded",
});
checkbox = await page.waitForSelector("#require_active_version");
await checkbox.scrollIntoViewIfNeeded();
expect(await checkbox.isChecked()).toBe(true);
});