Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Keep the template's signing steps when bulk send adds options
Matt Van Horn0d71a5f163d0
diff --git a/src/lib/bulk-send.dbtest.ts b/src/lib/bulk-send.dbtest.tsindex d7546a3..fd7f593 100644--- a/src/lib/bulk-send.dbtest.ts+++ b/src/lib/bulk-send.dbtest.ts@@ -135,7 +135,10 @@ function field(const options = () => ({ database, storageService });-async function createTwoRoleTemplate(userId: string) {+async function createTwoRoleTemplate(+ userId: string,+ { sameStep = false }: { sameStep?: boolean } = {},+) {const draft = await createDraftEnvelope(userId,{@@ -150,8 +153,16 @@ async function createTwoRoleTemplate(userId: string) {envelopeId,{signers: [- { email: "[email protected]", name: "Riley Recipient" },- { email: "[email protected]", name: "Casey Second" },+ {+ email: "[email protected]",+ name: "Riley Recipient",+ ...(sameStep ? { signingStep: 1 } : {}),+ },+ {+ email: "[email protected]",+ name: "Casey Second",+ ...(sameStep ? { signingStep: 1 } : {}),+ },],},database,@@ -451,6 +462,43 @@ test("a 3-row batch creates and sends three envelopes with the template's fields);});+test("copy recipients and email codes keep the template's shared signing step", async () => {+ const userId = await createUser();+ const template = await createTwoRoleTemplate(userId, { sameStep: true });+ const result = await bulkSendFromTemplate(+ userId,+ template.id,+ confirmBody(+ twoRoleCsv([+ [+ "Tess Step",+ `tess-step-${randomUUID()}@example.test`,+ "Lou Step",+ `lou-step-${randomUUID()}@example.test`,+ "Lease",+ ],+ ]),+ {+ copyRecipients: [+ { email: `copy-${randomUUID()}@example.test`, name: "Copy" },+ ],+ requireEmailCode: true,+ },+ ),+ { ...options(), sender: senderFor(userId) },+ );++ assert.equal(result.rows[0]?.status, "sent");+ const steps = await database.query<{ signing_step: number | null }>(+ `select signing_step from signers where envelope_id = $1 and role = 'signer' order by sign_order`,+ [result.rows[0]?.envelopeId],+ );+ assert.deepEqual(+ steps.rows.map((row) => row.signing_step),+ [1, 1],+ );+});+test("a bad row is skipped while the rest send", async () => {const userId = await createUser();const template = await createOneRoleTemplate(userId);diff --git a/src/lib/bulk-send.ts b/src/lib/bulk-send.tsindex ce423e6..4a28e8c 100644--- a/src/lib/bulk-send.ts+++ b/src/lib/bulk-send.ts@@ -619,6 +619,8 @@ async function sendOneRow(name: signer.name,requireEmailCode,signatureMeaning,+ // Signers who share a step keep signing at the same time.+ signingStep: signer.step,})),},database,