From 2eac94f719f0066e03f00ae6f45d01f2224cf97b Mon Sep 17 00:00:00 2001 From: Paul Huliganga Date: Wed, 25 Mar 2026 11:13:21 -0400 Subject: [PATCH] test: add SMS, i18n, and multi-copy tests for composite envelope builder --- .../DocusignCompositeEnvelopeBuilderTest.cls | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/composite-envelope-builder/force-app/main/default/classes/DocusignCompositeEnvelopeBuilderTest.cls b/composite-envelope-builder/force-app/main/default/classes/DocusignCompositeEnvelopeBuilderTest.cls index cf6db52..3f7fffa 100644 --- a/composite-envelope-builder/force-app/main/default/classes/DocusignCompositeEnvelopeBuilderTest.cls +++ b/composite-envelope-builder/force-app/main/default/classes/DocusignCompositeEnvelopeBuilderTest.cls @@ -291,4 +291,86 @@ private class DocusignCompositeEnvelopeBuilderTest { // Assert System.assertEquals(true, results[0].success, 'Should succeed with truncated subject'); } + + @isTest + static void testSmsDeliveryPath() { + // Arrange - create service coordinator (with email) and recipient (no email) + Contact sc = new Contact(LastName='SC', Email='sc@example.com'); + insert sc; + + Contact dr = new Contact(LastName='DR'); + insert dr; + + // Create a Client Case record linking the lookups used by resolver + Client_Case__c cc = new Client_Case__c(Name='Test Case SMS', Service_Coordinator__c = sc.Id, Docusign_Recipient_1__c = dr.Id); + insert cc; + + // Arrange request with SMS phone for recipient #1 + dfsle.TestUtils.setMock(new dfsle.ESignatureAPIMock()); + DocusignEnvelopeRequest req = new DocusignEnvelopeRequest(); + req.templateIds = new List{'01234567-abcd-ef01-2345-6789abcdef01'}; + req.recordId = cc.Id; + req.recipientSmsPhone = '+15551234567'; + + // Act + Test.startTest(); + List results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List{req}); + Test.stopTest(); + + // Assert - should succeed and produce an envelope id + System.assertEquals(true, results[0].success, 'SMS path should succeed'); + System.assertNotEquals(null, results[0].envelopeId, 'Should have envelope ID for SMS envelope'); + } + + @isTest + static void testSpanishGreetingPath() { + // Arrange - basic happy path but with language set to Spanish + dfsle.TestUtils.setMock(new dfsle.ESignatureAPIMock()); + DocusignEnvelopeRequest req = new DocusignEnvelopeRequest(); + req.templateIds = new List{'01234567-abcd-ef01-2345-6789abcdef01'}; + req.recordId = '001000000ABC123'; + req.language = 'es'; + + // Act + Test.startTest(); + List results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List{req}); + Test.stopTest(); + + // Assert - succeeded; language handling exercised (no exception) + System.assertEquals(true, results[0].success, 'Spanish language path should succeed'); + } + + @isTest + static void testMultiCopyExpansion() { + // Arrange - insert a dfsle configuration that matches the MULTI_COPY_TEMPLATE_NAME + // so the multi-copy expansion logic will detect and duplicate template IDs. + dfsle__EnvelopeConfiguration__c cfg = new dfsle__EnvelopeConfiguration__c( + Name = 'Authorization to Release Information - English', + dfsle__DocuSignId__c = '01234567-abcd-ef01-2345-6789abcdefMC', + dfsle__EmailMessage__c = 'Please sign this release.' + ); + insert cfg; + + // Create contacts and case for recipients + Contact sc = new Contact(LastName='SC', Email='sc@example.com'); + insert sc; + Contact dr = new Contact(LastName='DR', Email='dr@example.com'); + insert dr; + Client_Case__c cc = new Client_Case__c(Name='Test Case Multi', Service_Coordinator__c = sc.Id, Docusign_Recipient_1__c = dr.Id); + insert cc; + + dfsle.TestUtils.setMock(new dfsle.ESignatureAPIMock()); + DocusignEnvelopeRequest req = new DocusignEnvelopeRequest(); + req.templateIds = new List{cfg.dfsle__DocuSignId__c}; + req.recordId = cc.Id; + req.authReleaseFormCopies = 3; + + // Act + Test.startTest(); + List results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List{req}); + Test.stopTest(); + + // Assert - ensure envelope creation succeeded when multi-copy expansion is requested + System.assertEquals(true, results[0].success, 'Multi-copy expansion should succeed'); + } }