Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Merge main into the name field (PR #50)
Claude5384c47b0157
diff --cc src/lib/services/pdf-finalize.test.tsindex 1aefd98,1767291..2997e6a--- a/src/lib/services/pdf-finalize.test.ts+++ b/src/lib/services/pdf-finalize.test.ts@@@ -526,40 -527,108 +527,146 @@@ test("numbers and dropdown choices areassert.ok(chosenOnly.byteLength > withoutRadios.byteLength);});+test("a name field is stamped with the name it was filled in with", async () => {+ const fixture = await makeFixture();+ // Not the name on the fixture's signatures, so only the name field can+ // put it on the page.+ const printedName = "Zofia Nowak-Wiśniewska";+ const nameField: FieldRecord = {+ createdAt: 1_800_000_000,+ envelopeId: fixture.envelope.id,+ height: 0.03,+ id: "name-1",+ inputMethod: "auto",+ page: 1,+ required: true,+ signerId: "signer-1",+ submittedAt: 1_800_000_000,+ type: "name",+ updatedAt: 1_800_000_000,+ value: printedName,+ width: 0.3,+ x: 0.1,+ y: 0.5,+ };+ const pdfBytes = await renderFinalizedEnvelopePdf(+ {+ auditEvents: fixture.auditEvents,+ completedAt: fixture.envelope.completedAt!,+ envelope: fixture.envelope,+ fields: [...fixture.fields, nameField],+ signers: fixture.signers,+ sourcePdfKey: fixture.envelope.sourcePdfKey,+ },+ { seal: saveUnsealed, storageService: fixture.storageService },+ );+ const text = (await extractText(pdfBytes)).replace(/\s+/g, " ");++ assert.ok(text.includes(printedName));+});+++ test("a sent row names the sender, not the first signer (issue #52)", async () => {+ const fixture = await makeFixture();+ const auditEvents: AuditEventRecord[] = [+ {+ actorEmail: "[email protected]",+ actorType: "sender",+ createdAt: 1_799_999_000,+ envelopeId: fixture.envelope.id,+ event: "sent",+ id: "event-sent",+ metadata: {+ signerEmail: "[email protected]",+ signerId: "signer-1",+ signerName: SIGNER_NAME,+ },+ },+ {+ actorType: "system",+ createdAt: 1_799_999_100,+ envelopeId: fixture.envelope.id,+ event: "reminded_auto",+ id: "event-reminded",+ metadata: {+ signerEmail: "[email protected]",+ signerId: "signer-1",+ signerName: SIGNER_NAME,+ },+ },+ {+ actorEmail: "[email protected]",+ actorType: "signer",+ createdAt: 1_799_999_200,+ envelopeId: fixture.envelope.id,+ event: "viewed",+ id: "event-viewed",+ metadata: { signerId: "signer-1", signerName: SIGNER_NAME },+ },+ ];+ const render = async (redactForRecipients: boolean) =>+ (+ await extractText(+ await renderEnvelopeCertificatePdf(+ {+ auditEvents,+ envelope: fixture.envelope,+ redactForRecipients,+ signers: fixture.signers,+ },+ { seal: saveUnsealed },+ ),+ )+ ).replace(/\s+/g, " ");++ for (const redacted of [false, true]) {+ const text = await render(redacted);++ assert.ok(!text.includes(`${SIGNER_NAME} <[email protected]>`), text);+ assert.match(text, /sent \| sam@sender\.example/);+ assert.match(text, /reminded_auto \| system/);+ assert.ok(+ text.includes(+ `viewed | ${SIGNER_NAME} <${redacted ? "signer" : "[email protected]"}>`,+ ),+ text,+ );+ }+ });++ test("describeAuditActor keeps the signer's name on the signer's own rows", () => {+ const base = {+ createdAt: 1,+ envelopeId: "envelope-1",+ id: "event-1",+ } as const;++ assert.equal(+ describeAuditActor({+ ...base,+ actorEmail: "[email protected]",+ actorType: "sender",+ event: "reminded_manual",+ metadata: { signerEmail: "[email protected]", signerName: "Priya Patel" },+ }),+ "[email protected]",+ );+ assert.equal(+ describeAuditActor({+ ...base,+ actorEmail: "[email protected]",+ actorType: "signer",+ event: "signed",+ metadata: { signerName: "Priya Patel" },+ }),+ "Priya Patel <[email protected]>",+ );+ assert.equal(+ describeAuditActor({+ ...base,+ actorType: "system",+ event: "expired",+ metadata: { signerEmail: "[email protected]", signerName: "Priya Patel" },+ }),+ "system",+ );+ });