1
11import { test, expect } from "../fixtures";
12import { createPage, createBlock } from "../utils/api";
13import type { PageDto } from "../fixtures";
14
15test.describe("Templates preview — T-141 (read-only snapshot dialog)", () => {
16 test("Preview shows the frozen snapshot (title + blocks); Escape closes", async ({
17 authPage,
18 api,
19 freshWorkspace
20 }) => {
21 const ws = await freshWorkspace("Preview Space");
22 const src = (await createPage(api, ws.id, { title: "Preview Source" })) as PageDto;
23 await createBlock(api, src.id, {
24 type: "PARAGRAPH",
25 content: { text: "preview body text" }
26 });
27
28 const tRes = await api.post(`/api/v1/pages/${src.id}/templates`, {
29 data: { name: "Preview Tpl" }
30 });
31 expect(tRes.status(), await tRes.text()).toBe(201);
32 const tpl = (await tRes.json()) as { id: string };
33
34 await authPage.goto(`/w/${ws.slug}/templates`);
35 const item = authPage.getByTestId(`template-item-${tpl.id}`);
36 await expect(item).toBeVisible({ timeout: 15_000 });
37
38
39 await expect(authPage.getByTestId(`template-preview-${tpl.id}`)).toBeVisible();
40
41
42 await item.getByTestId(`template-preview-${tpl.id}`).click();
43 const body = authPage.getByTestId("template-preview-body");
44 await expect(body).toBeVisible({ timeout: 15_000 });
45
46 await expect(authPage.getByTestId("template-preview-title")).toHaveText("Preview Source");
47 await expect(body.getByText("preview body text")).toBeVisible();
48
49 await expect(body.locator("[contenteditable], input, textarea")).toHaveCount(0);
50
51
52 await authPage.keyboard.press("Escape");
53 await expect(body).toBeHidden({ timeout: 5_000 });
54 });
55});
56