test: add SMS, i18n, and multi-copy tests for composite envelope builder

This commit is contained in:
Paul Huliganga 2026-03-25 11:13:21 -04:00
parent e8fb53f476
commit 2eac94f719
1 changed files with 82 additions and 0 deletions

View File

@ -291,4 +291,86 @@ private class DocusignCompositeEnvelopeBuilderTest {
// Assert // Assert
System.assertEquals(true, results[0].success, 'Should succeed with truncated subject'); 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<String>{'01234567-abcd-ef01-2345-6789abcdef01'};
req.recordId = cc.Id;
req.recipientSmsPhone = '+15551234567';
// Act
Test.startTest();
List<DocusignEnvelopeResult> results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List<DocusignEnvelopeRequest>{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<String>{'01234567-abcd-ef01-2345-6789abcdef01'};
req.recordId = '001000000ABC123';
req.language = 'es';
// Act
Test.startTest();
List<DocusignEnvelopeResult> results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List<DocusignEnvelopeRequest>{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<String>{cfg.dfsle__DocuSignId__c};
req.recordId = cc.Id;
req.authReleaseFormCopies = 3;
// Act
Test.startTest();
List<DocusignEnvelopeResult> results = DocusignCompositeEnvelopeBuilder.sendCompositeEnvelope(new List<DocusignEnvelopeRequest>{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');
}
} }