Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Break a long unbroken title in dialogs so Send now stays on screen
Claude1c2132ff2ff5
diff --git a/e2e/support/admin-session.ts b/e2e/support/admin-session.tsnew file mode 100644index 0000000..91d743d--- /dev/null+++ b/e2e/support/admin-session.ts@@ -0,0 +1,51 @@+import { expect, type Page } from "@playwright/test";+import pg from "pg";++import { e2eDatabaseUrl } from "../../playwright.config";++// The password every account in signing-flow.spec.ts is made with.+export const E2E_PASSWORD = "correct horse battery staple 42";++/**+ * Signs in as the administrator that the first test in signing-flow.spec.ts+ * sets up. The last test there turns on two-step sign-in for them, so it is+ * turned off again first: these tests are about other things, and a+ * password is enough for them.+ */+export async function signInAsAdministrator(page: Page): Promise<string> {+ const database = new pg.Client({ connectionString: e2eDatabaseUrl });+ let adminEmail = "";++ await database.connect();++ try {+ const admin = await database.query<{ email: string; id: string }>(+ `select id, email from public."user" where role = 'admin' order by "createdAt" limit 1`,+ );++ adminEmail = admin.rows[0]?.email ?? "";++ await database.query(+ `update public."user" set "twoFactorEnabled" = false where id = $1`,+ [admin.rows[0]?.id],+ );+ await database.query(`delete from public."twoFactor" where "userId" = $1`, [+ admin.rows[0]?.id,+ ]);+ await database.query(+ `update public.app_settings set require_two_factor = false`,+ );+ } finally {+ await database.end();+ }++ expect(adminEmail).not.toBe("");++ await page.goto("/login");+ await page.getByLabel("Email").fill(adminEmail);+ await page.getByLabel("Password").fill(E2E_PASSWORD);+ await page.getByRole("button", { name: "Log in" }).click();+ await expect(page).toHaveURL(/\/dashboard$/);++ return adminEmail;+}diff --git a/e2e/wizard-long-title.spec.ts b/e2e/wizard-long-title.spec.tsnew file mode 100644index 0000000..7c9a1ec--- /dev/null+++ b/e2e/wizard-long-title.spec.ts@@ -0,0 +1,69 @@+import { expect, test } from "@playwright/test";++import { signInAsAdministrator } from "./support/admin-session";+import { writeSamplePdf } from "./support/sample-pdf";++// Runs after signing-flow.spec.ts, which sets up the install and its+// administrator.++// 120 letters with no space: a title the form accepts, and one word the+// confirmation dialog has to break.+const LONG_TITLE = "W".repeat(120);++for (const width of [1440, 1024]) {+ test(`a long unbroken title keeps Send now on screen at ${String(width)} px`, async ({+ page,+ }, testInfo) => {+ await page.setViewportSize({ height: 850, width });+ await signInAsAdministrator(page);++ const pdfPath = await writeSamplePdf(testInfo.outputPath("long.pdf"));++ await page.goto("/envelopes/new");+ await page.getByLabel("Envelope title").fill(LONG_TITLE);+ 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("[email protected]");+ await page.getByRole("button", { name: "Next →" }).click();+ await expect(page).toHaveURL(/\/prepare$/);++ await page.getByRole("button", { exact: true, name: "Signature" }).click();++ const placementTarget = page.getByLabel("Place Signature on page 1");+ 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();++ const dialogBox = await confirmation.boundingBox();+ const sendNow = confirmation.getByRole("button", { name: "Send now" });+ const sendBox = await sendNow.boundingBox();++ // The dialog and its button stay inside the window, and the whole+ // title is inside the dialog.+ expect(dialogBox!.x).toBeGreaterThanOrEqual(0);+ expect(dialogBox!.x + dialogBox!.width).toBeLessThanOrEqual(width);+ expect(sendBox!.x + sendBox!.width).toBeLessThanOrEqual(width);+ expect(+ await confirmation.evaluate(+ (element) => element.scrollWidth <= element.clientWidth,+ ),+ ).toBe(true);+ await expect(confirmation).toContainText(LONG_TITLE);+ await sendNow.click({ trial: true });+ });+}diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsxindex ff1ed32..2832f05 100644--- a/src/components/ui/dialog.tsx+++ b/src/components/ui/dialog.tsx@@ -61,7 +61,7 @@ function DialogContent({<DialogPrimitive.Contentdata-slot="dialog-content"className={cn(- "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-5 rounded-3xl bg-[var(--paper-raised)] p-6 text-sm shadow-[0_32px_80px_rgba(28,29,43,0.22)] duration-100 outline-none sm:max-w-md sm:p-8 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] grid-cols-[minmax(0,1fr)] wrap-break-word -translate-x-1/2 -translate-y-1/2 gap-5 rounded-3xl bg-[var(--paper-raised)] p-6 text-sm shadow-[0_32px_80px_rgba(28,29,43,0.22)] duration-100 outline-none sm:max-w-md sm:p-8 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className,)}{...props}