Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Test that a long typed signature keeps the dialog on a phone screen, and keep the capture warning
Claude9e9767d42731
diff --git a/docs/development.md b/docs/development.mdindex d82dfb7..da78cbf 100644--- a/docs/development.md+++ b/docs/development.md@@ -106,7 +106,7 @@ SignuDoc sends transactional email through Resend.- `RESEND_FROM_EMAIL` and `SUPPORT_EMAIL` are optional. When set they take the place of the addresses saved in Settings, which then cannot be changed there, and with `SUPPORT_EMAIL` set the setup page does not ask for a support address.- Until a sender address is set, mail goes out from `[email protected]`, which Resend only delivers to the owner of the Resend account.- In hosted mode the support address is also the contact shown on the Terms, Privacy, and Accessibility pages.-- For local development, `EMAIL_DRIVER=capture` writes each email to `.data/outbox` as a JSON file instead of sending it. Open the newest file to find a verification or signing link. Use a delivery provider for deployed sites that need to send email.+- For local development, `EMAIL_DRIVER=capture` writes each email to `.data/outbox` as a JSON file instead of sending it. Open the newest file to find a verification or signing link. Use a delivery provider for deployed sites that need to send email: on a deployed site the capture driver refuses to run, because it delivers no mail.To test a production build on your machine, set `APP_URL=http://localhost:3000` and `EMAIL_DRIVER=capture` in your local `.env`. With the example database password, sign-in also needs a `BETTER_AUTH_SECRET` of at least 32 characters. Generate one with `openssl rand -hex 32` and save its output as `BETTER_AUTH_SECRET` in the same file. Run `npm run build`, then `npm run start`.diff --git a/e2e/signing-flow.spec.ts b/e2e/signing-flow.spec.tsindex 3ac1d0d..8c7c371 100644--- a/e2e/signing-flow.spec.ts+++ b/e2e/signing-flow.spec.ts@@ -869,6 +869,13 @@ test("in Part 11 mode a verified account signs, with its password and a stated m).toBeVisible();// A retention period would delete regulated records on a timer.await expect(page.getByLabel("Days to keep")).toBeDisabled();+ // Part 11 signers need an account, so the sign-up rule covers them too.+ await expect(+ page.getByText("Part 11 mode is on, so this covers signers too."),+ ).toBeVisible();+ await expect(+ page.getByText("People who are sent a document to sign don't need"),+ ).toHaveCount(0);});await test.step("the signer makes an account and confirms their email", async () => {@@ -1064,6 +1071,11 @@ test("in Part 11 mode a verified account signs, with its password and a stated m})).status(),).toBe(200);+ // With the mode off, ordinary signers again need no account.+ await page.goto("/settings");+ await expect(+ page.getByText("People who are sent a document to sign don't need"),+ ).toBeVisible();});});diff --git a/e2e/signing-long-signature.spec.ts b/e2e/signing-long-signature.spec.tsnew file mode 100644index 0000000..170af93--- /dev/null+++ b/e2e/signing-long-signature.spec.ts@@ -0,0 +1,124 @@+import { expect, test } from "@playwright/test";++import { signInAsAdministrator } from "./support/admin-session";+import { extractLink, waitForEmail } from "./support/outbox";+import { writeSamplePdf } from "./support/sample-pdf";++// Runs after signing-flow.spec.ts, which sets up the install and its+// administrator.++const SIGNER_EMAIL = "[email protected]";++test("a long typed signature keeps the signature dialog's buttons on a phone screen", async ({+ browser,+ page,+}, testInfo) => {+ await test.step("the sender sends a signature field", async () => {+ await signInAsAdministrator(page);++ const pdfPath = await writeSamplePdf(+ testInfo.outputPath("long-signature.pdf"),+ );++ await page.goto("/envelopes/new");+ await page.getByLabel("Envelope title").fill("Long typed signature");+ await page.getByLabel("Upload PDF").setInputFiles(pdfPath);+ await page.getByRole("button", { name: "Next ->" }).click();+ await expect(page).toHaveURL(/\/envelopes\/[^/]+\/signers$/);++ await page.getByLabel("Signer 1 name").fill("Wren Wide");+ await page.getByLabel("Signer 1 email").fill(SIGNER_EMAIL);+ await page.getByRole("button", { name: "Next →" }).click();+ await expect(page).toHaveURL(/\/prepare$/);++ const placementTarget = page.getByLabel("Place Signature on page 1");++ await page.getByRole("button", { exact: true, name: "Signature" }).click();++ const box = await placementTarget.boundingBox();++ await placementTarget.click({+ position: { x: box!.width * 0.3, y: box!.height * 0.6 },+ });+ await expect(page.getByRole("status")).toHaveText("Saved");+ await page.getByRole("button", { name: "Next →" }).click();+ await expect(page).toHaveURL(/\/review$/);+ await page.getByRole("button", { name: "Send envelope" }).click();++ const confirmation = page.getByRole("dialog", {+ name: "Send this envelope?",+ });++ await confirmation.getByRole("checkbox").check();+ await confirmation.getByRole("button", { name: "Send now" }).click();+ await expect(page).toHaveURL(/\/envelopes\/[^/]+$/);+ });++ await test.step("an 80-character typed signature stays inside the dialog", async () => {+ const invitation = await waitForEmail({+ template: "signing_invitation",+ to: SIGNER_EMAIL,+ });+ const signerContext = await browser.newContext({+ viewport: { height: 844, width: 390 },+ });+ const signerPage = await signerContext.newPage();++ await signerPage.goto(extractLink(invitation.text, "/sign/"));++ const consent = signerPage.getByRole("dialog", { name: "Before you sign" });++ await consent+ .getByRole("checkbox", {+ name: "I agree to use electronic records and signatures",+ })+ .check();+ await consent.getByRole("button", { name: "Agree and continue" }).click();+ await expect(consent).toBeHidden();++ const field = signerPage.getByRole("button", {+ exact: true,+ name: "Signature",+ });+ const dialog = signerPage.getByRole("dialog", {+ name: "Add your signature",+ });++ await field.click();+ await expect(dialog).toBeVisible();++ const typed = dialog.getByLabel("Type signature");+ const longName = "W".repeat(80);++ await typed.fill(longName);+ await expect(typed).toHaveValue(longName);++ // Nothing in the dialog is wider than the dialog, so it never scrolls+ // sideways and every label stays on the 390 px screen.+ const widths = await dialog.evaluate((element) => ({+ client: element.clientWidth,+ scroll: element.scrollWidth,+ }));++ expect(widths.scroll).toBeLessThanOrEqual(widths.client);++ for (const control of [+ dialog.getByRole("tab", { name: "Type" }),+ dialog.getByRole("tab", { name: "Draw" }),+ dialog.getByRole("button", { name: "Apply signature" }),+ dialog.getByRole("button", { name: "Cancel" }),+ ]) {+ const box = await control.boundingBox();++ expect(box).not.toBeNull();+ expect(box!.x).toBeGreaterThanOrEqual(0);+ expect(box!.x + box!.width).toBeLessThanOrEqual(390);+ }++ // The whole value is still applied.+ await dialog.getByRole("button", { name: "Apply signature" }).click();+ await expect(dialog).toBeHidden();++ await signerContext.close();+ });+});