test: add SMS, i18n, and multi-copy tests for composite envelope builder
This commit is contained in:
parent
e8fb53f476
commit
2eac94f719
|
|
@ -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<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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue