/** * Redirects E2E Tests * * Tests creating, editing, and deleting URL redirects, * plus the 404 tracking tab. */ import { test, expect } from "../fixtures"; test.describe("Redirects", () => { test.beforeEach(async ({ admin }) => { await admin.devBypassAuth(); }); test.describe("Empty state", () => { test("displays redirects page with empty state", async ({ admin, page }) => { await admin.goto("/redirects"); await admin.waitForShell(); await admin.waitForLoading(); // Should show the page heading await admin.expectPageTitle("Redirects"); // Should have the "New Redirect" button await expect(page.getByRole("button", { name: "New Redirect" })).toBeVisible(); // Should show empty state text await expect(page.locator("text=No redirects yet")).toBeVisible(); }); }); test.describe("CRUD", () => { test("creates a redirect", async ({ admin, page }) => { await admin.goto("/redirects"); await admin.waitForShell(); await admin.waitForLoading(); // Open create dialog await page.getByRole("button", { name: "New Redirect" }).click(); await expect(page.locator('[role="dialog"]')).toBeVisible(); // Fill form const dialog = page.locator('[role="dialog"]'); await dialog.locator('input[placeholder*="old-page"]').fill("/old-page"); await dialog.locator('input[placeholder*="new-page"]').fill("/new-page"); // Status code defaults to 301 -- leave it // Submit await dialog.getByRole("button", { name: "Create" }).click(); // Dialog should close await expect(page.locator('[role="dialog"]')).not.toBeVisible({ timeout: 10000 }); // Redirect should appear in the list await expect(page.locator("text=/old-page").first()).toBeVisible(); await expect(page.locator("text=/new-page").first()).toBeVisible(); }); test("edits a redirect", async ({ admin, page }) => { await admin.goto("/redirects"); await admin.waitForShell(); await admin.waitForLoading(); // Create a redirect first await page.getByRole("button", { name: "New Redirect" }).click(); const createDialog = page.locator('[role="dialog"]'); await createDialog.locator('input[placeholder*="old-page"]').fill("/edit-source"); await createDialog.locator('input[placeholder*="new-page"]').fill("/edit-dest-original"); await createDialog.getByRole("button", { name: "Create" }).click(); await expect(page.locator('[role="dialog"]')).not.toBeVisible({ timeout: 10000 }); // Wait for the redirect to appear await expect(page.locator("text=/edit-source").first()).toBeVisible(); // Click the edit button on that row (use .first() to avoid ancestor div ambiguity). // Kumo 2.x renders