diff --git a/.dev.vars.example b/.dev.vars.example index 9c16289..0bb3824 100644 --- a/.dev.vars.example +++ b/.dev.vars.example @@ -7,6 +7,10 @@ BETTER_AUTH_SECRET= # Optional: pins the app's URL. Leave it out to accept any host, for example from your phone. # BETTER_AUTH_URL= +# Optional: a distinct origin routed to this Worker for embedded respondents. Set +# BETTER_AUTH_URL to the owner origin too; each published form must register its exact host. +# FORMS_RESPONDENT_ORIGIN= + # Optional: who may make an account, as whole addresses separated by commas. An entry that # names a domain (@example.org) is ignored: no email is sent yet, so nothing proves who can # read mail there. A listed address belongs to whoever signs up with it first. diff --git a/apps/web/e2e/embed.spec.ts b/apps/web/e2e/embed.spec.ts new file mode 100644 index 0000000..22857a3 --- /dev/null +++ b/apps/web/e2e/embed.spec.ts @@ -0,0 +1,374 @@ +import { fileURLToPath } from "node:url"; +import type { Page } from "@playwright/test"; +import { test as browserTest } from "@playwright/test"; +import { shortFeedback } from "../test/short-feedback"; +import { expect, test } from "./fixtures"; +import { freshId, signUp } from "./owner"; + +const port = Number(process.env.FORMS_E2E_PORT) || 4771; +const owner = `http://localhost:${port}`; +const respondent = `http://127.0.0.1:${port}`; +// The example form names this product origin. The product's documents are mocked by Playwright. +const host = "http://localhost:4771"; +const hostPage = `${host}/synthetic-host`; + +async function serveLoader(page: Page) { + await page.route(`${host}/forms-embed-loader.mjs`, (route) => + route.fulfill({ + path: fileURLToPath(new URL("../../../embed/loader.mjs", import.meta.url)), + contentType: "text/javascript", + }), + ); +} + +test.use({ trace: "off" }); + +test("a host loader opens a sandboxed form with consent, context and a private resume link", async ({ + page, +}) => { + test.setTimeout(120_000); + await page.setViewportSize({ width: 320, height: 700 }); + await page.route(hostPage, (route) => + route.fulfill({ + contentType: "text/html", + body: "