File
Blob: tests/e2e/specs/18-shared-page-cold-deep-link.spec.ts
| 1 | import { |
| 2 | test, |
| 3 | expect, |
| 4 | createShareLink, |
| 5 | createTestPage, |
| 6 | waitForDocEditorReady, |
| 7 | waitForPersistedSnapshot, |
| 8 | } from "../fixtures/bland-test"; |
| 9 | |
| 10 | const SEEDED_BODY_TEXT = "Shared cold deep link preserves existing body content"; |
| 11 | |
| 12 | test.describe("shared page route - cold deep-link", () => { |
| 13 | test("fresh shared load hydrates existing body content without a leading blank block", async ({ |
| 14 | authenticatedPage: { page, accessToken }, |
| 15 | e2eWorkspace, |
| 16 | browser, |
| 17 | }) => { |
| 18 | const sharedPage = await createTestPage(page, accessToken, "Shared Cold Page", e2eWorkspace); |
| 19 | |
| 20 | await page.goto(`/${sharedPage.workspaceSlug}/${sharedPage.pageId}`); |
| 21 | const seedEditor = await waitForDocEditorReady(page, { editable: true }); |
| 22 | await seedEditor.click(); |
| 23 | await page.keyboard.type(SEEDED_BODY_TEXT); |
| 24 | await expect(seedEditor).toContainText(SEEDED_BODY_TEXT); |
| 25 | await waitForPersistedSnapshot(page, accessToken, { ...sharedPage, expectedText: SEEDED_BODY_TEXT }); |
| 26 | |
| 27 | const share = await createShareLink(page, accessToken, sharedPage.pageId, "view"); |
| 28 | const sharedContext = await browser.newContext(); |
| 29 | const sharedPageView = await sharedContext.newPage(); |
| 30 | const pageErrors: string[] = []; |
| 31 | sharedPageView.on("pageerror", (err) => pageErrors.push(err.message)); |
| 32 | |
| 33 | await sharedPageView.goto(`/s/${share.token}`); |
| 34 | |
| 35 | const sharedEditor = sharedPageView.locator(".tiptap[contenteditable='false']"); |
| 36 | await sharedEditor.waitFor({ timeout: 30_000 }); |
| 37 | await expect(sharedEditor).toContainText(SEEDED_BODY_TEXT); |
| 38 | expect(pageErrors).toEqual([]); |
| 39 | |
| 40 | await sharedContext.close(); |
| 41 | }); |
| 42 | |
| 43 | test("shared-root canvas page mounts the canvas surface (not the editor) via the seed path", async ({ |
| 44 | authenticatedPage: { page, accessToken }, |
| 45 | e2eWorkspace, |
| 46 | browser, |
| 47 | }) => { |
| 48 | const canvasPage = await createTestPage(page, accessToken, "Shared Canvas Cold", e2eWorkspace, "canvas"); |
| 49 | const share = await createShareLink(page, accessToken, canvasPage.pageId, "view"); |
| 50 | |
| 51 | const sharedContext = await browser.newContext(); |
| 52 | const sharedPageView = await sharedContext.newPage(); |
| 53 | const pageErrors: string[] = []; |
| 54 | sharedPageView.on("pageerror", (err) => pageErrors.push(err.message)); |
| 55 | |
| 56 | // Critical: share-root seed path (SharedActivePageBoundary) must carry `kind: "canvas"` |
| 57 | // without relying on the live /workspaces/:wid/pages/:pid fetch. |
| 58 | const pageFetches: string[] = []; |
| 59 | sharedPageView.on("request", (req) => { |
| 60 | const url = new URL(req.url()); |
| 61 | if (url.pathname === `/api/v1/workspaces/${canvasPage.workspaceId}/pages/${canvasPage.pageId}`) { |
| 62 | pageFetches.push(req.url()); |
| 63 | } |
| 64 | }); |
| 65 | |
| 66 | await sharedPageView.goto(`/s/${share.token}`); |
| 67 | |
| 68 | await sharedPageView.locator(".excalidraw").waitFor({ state: "attached", timeout: 30_000 }); |
| 69 | await expect(sharedPageView.locator(".tiptap")).toHaveCount(0); |
| 70 | expect(pageErrors).toEqual([]); |
| 71 | |
| 72 | await sharedContext.close(); |
| 73 | }); |
| 74 | }); |