Files
coder/site/e2e/tests/organizations.spec.ts
T
Jake HowellandKayla はな 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

58 lines
2.1 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { setupApiCalls } from "../api";
import { expectUrl } from "../expectUrl";
import { login, randomName, requiresLicense } from "../helpers";
import { beforeCoderTest } from "../hooks";
test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
await setupApiCalls(page);
});
test("create and delete organization", async ({ page }) => {
requiresLicense();
// Create an organization
await page.goto("/organizations/new", {
waitUntil: "domcontentloaded",
});
const name = randomName();
await page.getByLabel("Slug").fill(name);
await page.getByLabel("Display name").fill(`Org ${name}`);
await page.getByLabel("Description").fill(`Org description ${name}`);
await page.getByLabel("Icon", { exact: true }).fill("/emojis/1f957.png");
await page.getByRole("button", { name: /save/i }).click();
// Expect to be redirected to the new organization
await expectUrl(page).toHavePathName(`/organizations/${name}`);
await expect(page.getByText(/created successfully/)).toBeVisible();
await page.goto(`/organizations/${name}/settings`, {
waitUntil: "domcontentloaded",
});
const newName = randomName();
await page.getByLabel("Slug").fill(newName);
await page.getByLabel("Description").fill(`Org description ${newName}`);
await page.getByRole("button", { name: /save/i }).click();
// Expect to be redirected when renaming the organization
await expectUrl(page).toHavePathName(`/organizations/${newName}/settings`);
await expect(page.getByText(/settings updated successfully/)).toBeVisible();
await page.goto(`/organizations/${newName}/settings`, {
waitUntil: "domcontentloaded",
});
// Expect to be redirected when renaming the organization
await expectUrl(page).toHavePathName(`/organizations/${newName}/settings`);
await page.getByRole("button", { name: "Delete this organization" }).click();
const dialog = page.getByTestId("dialog");
await dialog.getByLabel("Name").fill(newName);
await dialog.getByRole("button", { name: "Delete" }).click();
await page.waitForTimeout(1000);
await expect(page.getByText(/deleted successfully/)).toBeVisible();
});