Files
coder/site/e2e/tests/updateTemplate.spec.ts
T
Jake Howell 15a2bab1cd feat: migrate from <GlobalSnackbar /> to sonner (#22258)
Replaces our custom `<GlobalSnackbar />` (MUI Snackbar + event emitter)
with [`sonner`](https://github.com/emilkowalski/sonner). Deletes
`GlobalSnackbar/`, the custom event emitter infra, and migrates ~80
source files to `toast.success()` / `toast.error()` from `sonner`.

- ~47 error toasts now surface API error detail via
`getErrorDetail(error)` in the toast description, not just a generic
message. Coincides with #22229.
- Toast messages follow an `{Action} "{entity}" {result}.` format (e.g.
`User "alice" suspended successfully.`) since toasts persist across
navigation now.
- 17 uses of `toast.promise()` for loading → success → error lifecycle.
- Some toasts include action buttons for quick navigation (e.g. "View
task", "View template").
- Multiple toasts can stack and display simultaneously.

---------

Co-authored-by: Kayla はな <mckayla@hey.com>
2026-02-26 02:42:34 +11: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(/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);
});