/** * T-136/T-137 — spaces directory E2E (dev-stack, Playwright, single-origin). * * Origin: `https://notion.filps.com` (Caddy → web :3000 / api :4000). A * localhost origin does NOT work — the API's CORS is pinned to the domain. * * The `/spaces` directory is top-level (outside the [workspace] segment). * Verified end to end through the real browser + API: * - a space the user owns appears in the directory (search narrows it) * - "Archive" (owner) removes it from the default list * - "Show archived" surfaces it with the Archived chip + a Restore action * - "Restore" puts it back in the default list */ import { test, expect } from "../fixtures"; test.describe("Spaces directory — P1 (T-136/T-137)", () => { test("list → archive → archived view → restore round-trip", async ({ authPage, freshWorkspace }) => { const ws = await freshWorkspace("Spaces E2E Roundtrip"); const item = authPage.getByTestId(`space-item-${ws.id}`); // 1. It appears in the directory (search narrows the member-scoped list). await authPage.goto("/spaces"); await expect(authPage.getByRole("heading", { name: /^spaces$/i })).toBeVisible(); await expect(item).toBeVisible({ timeout: 15_000 }); await expect(item).toContainText("Spaces E2E Roundtrip"); // Search narrows to it. await authPage.getByTestId("spaces-search").fill("Spaces E2E Roundtrip"); await expect(item).toBeVisible(); // 2. Archive it (the fixture user is the owner, so the action shows). await item.getByTestId(`space-archive-${ws.id}`).click(); // It disappears from the default (non-archived) list. await expect(item).toHaveCount(0, { timeout: 10_000 }); // 3. "Show archived" surfaces it with the Archived chip + Restore. await authPage.getByTestId("spaces-show-archived").check(); await expect(item).toBeVisible({ timeout: 15_000 }); await expect(item).toContainText("Archived"); await expect(item.getByTestId(`space-restore-${ws.id}`)).toBeVisible(); // 4. Restore it → back in the default list. await item.getByTestId(`space-restore-${ws.id}`).click(); await authPage.getByTestId("spaces-show-archived").uncheck(); await expect(item).toBeVisible({ timeout: 15_000 }); }); });