10 KiB
Deployment & Testing Guide
Quick reference for deploying the Salesforce Composite Envelope Builder to your org and running tests.
Shell Note: Commands below show both Bash/WSL and PowerShell variants for Windows Terminal. Choose the one that matches your environment. The
sfCLI commands are identical across both shells.
Quick Start (Recommended)
Deploy + Test in One Script
Bash/WSL:
cd /home/paulh/.openclaw/workspace/projects/salesforce-composite-envelope-builder/composite-envelope-builder
bash deploy-to-dev-org.sh
PowerShell (Windows Terminal):
cd "$env:USERPROFILE\.openclaw\workspace\projects\salesforce-composite-envelope-builder\composite-envelope-builder"
bash deploy-to-dev-org.sh
# Or if you prefer native PowerShell (not WSL):
# .\deploy-to-dev-org.sh (requires WSL bash available)
This script handles:
- ✅ Org authorization (opens browser login)
- ✅ Code deployment
- ✅ Unit test execution with code coverage
- ✅ Human-readable results
Manual Commands
1. Authorize Your Org (First Time Only)
Bash/WSL:
# For Developer Edition
sf org login web --alias dev-org --instance-url https://login.salesforce.com
# For Sandbox
sf org login web --alias sandbox-org --instance-url https://test.salesforce.com
PowerShell (Windows Terminal):
# For Developer Edition
sf org login web --alias dev-org --instance-url https://login.salesforce.com
# For Sandbox
sf org login web --alias sandbox-org --instance-url https://test.salesforce.com
You'll be redirected to Salesforce login. Once authorized, the org alias is saved for future deploys.
2. Deploy Code
Bash/WSL:
cd /home/paulh/.openclaw/workspace/projects/salesforce-composite-envelope-builder/composite-envelope-builder
sf project deploy start --target-org dev-org
PowerShell (Windows Terminal):
cd "$env:USERPROFILE\.openclaw\workspace\projects\salesforce-composite-envelope-builder\composite-envelope-builder"
sf project deploy start --target-org dev-org
Options:
--target-org dev-org— Use the authorized org alias (replace with your alias if different)--wait 10— Wait up to 10 minutes for deployment to complete
3. Run Tests
Run ALL unit tests with code coverage:
Bash/WSL:
sf apex run test --wait 10 --result-format human --code-coverage --target-org dev-org
PowerShell:
sf apex run test --wait 10 --result-format human --code-coverage --target-org dev-org
Run ONLY the new handler tests:
Bash/WSL:
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --wait 10 --result-format human --target-org dev-org
PowerShell:
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --wait 10 --result-format human --target-org dev-org
Run specific test methods:
Bash/WSL:
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --method-names testValidateRequest_Success --wait 10 --result-format human --target-org dev-org
PowerShell:
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --method-names testValidateRequest_Success --wait 10 --result-format human --target-org dev-org
Run tests for a specific class only:
Bash/WSL:
# Test the main invocable class
sf apex run test --class-names DocusignCompositeEnvelopeBuilderTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the request handler
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the API service
sf apex run test --class-names DocusignAPIServiceTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the credentials helper
sf apex run test --class-names DocusignCredentialsTest --wait 10 --result-format human --code-coverage --target-org dev-org
PowerShell:
# Test the main invocable class
sf apex run test --class-names DocusignCompositeEnvelopeBuilderTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the request handler
sf apex run test --class-names DocusignEnvelopeRequestHandlerTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the API service
sf apex run test --class-names DocusignAPIServiceTest --wait 10 --result-format human --code-coverage --target-org dev-org
# Test the credentials helper
sf apex run test --class-names DocusignCredentialsTest --wait 10 --result-format human --code-coverage --target-org dev-org
Run ALL tests with JSON output (for parsing):
Bash/WSL:
sf apex run test --wait 10 --result-format json --code-coverage --target-org dev-org > test-results.json
PowerShell:
sf apex run test --wait 10 --result-format json --code-coverage --target-org dev-org | Out-File -FilePath test-results.json
Complete Deploy + Test in One Command
Bash/WSL:
cd /home/paulh/.openclaw/workspace/projects/salesforce-composite-envelope-builder/composite-envelope-builder && \
sf project deploy start --target-org dev-org && \
sf apex run test --wait 10 --result-format human --code-coverage --target-org dev-org
PowerShell (Windows Terminal):
cd "$env:USERPROFILE\.openclaw\workspace\projects\salesforce-composite-envelope-builder\composite-envelope-builder"; `
sf project deploy start --target-org dev-org; `
sf apex run test --wait 10 --result-format human --code-coverage --target-org dev-org
Alternative PowerShell (using semicolons):
cd "$env:USERPROFILE\.openclaw\workspace\projects\salesforce-composite-envelope-builder\composite-envelope-builder"; sf project deploy start --target-org dev-org; sf apex run test --wait 10 --result-format human --code-coverage --target-org dev-org
Understanding Test Results
Sample output:
Apex Tests
═════════════════════════════════════════════════════════════════
Test Results Summary [Included Code Coverage]
═════════════════════════════════════════════════════════════════
Outcome: Passed
Tests Ran: 39
Passes: 39
Failures: 0
Skipped: 0
Pass Rate: 100%
Apex Code Coverage: 92%
Key metrics:
- Pass Rate — Percentage of tests that passed (should be 100%)
- Apex Code Coverage — Percentage of code executed by tests (should be >80%)
- Failures — If > 0, review the failed test names and error messages below
Post-Deployment Setup
After successful deployment, configure your Salesforce org:
1. Create Docusign Configuration Custom Setting
- Log into your Salesforce org
- Go to Setup → Custom Settings
- Click Manage next to Docusign Configuration
- Click New
- Fill in:
- Account Id:
{your Docusign sandbox account ID} - Base URL:
callout:DocusignAPI
- Account Id:
- Click Save
2. Create Named Credential for Docusign API
- Go to Setup → Named Credentials
- Click New Named Credential
- Fill in:
- Name:
DocusignAPI - Label:
Docusign API - URL:
https://demo.docusign.net/restapi/v2.1 - Identity Type: Named Principal
- Authentication Protocol: OAuth 2.0
- Authentication Provider: DocusignOAuthProvider (if available)
- Name:
- Click Save
3. Update Your Screen Flow
- Go to Flow Builder
- Create or edit your Screen Flow
- Add an Action to the flow:
- Action: Send Composite Docusign Envelope
- Input Variables:
- Template IDs — Comma-separated Docusign template IDs
- Salesforce Record ID — {!Record.Id}
- Language — en or es
- Email Subject — Optional custom subject
- Output Variables:
- Envelope ID — Unique Docusign envelope ID
- Success — Boolean (true/false)
- Error Message — Error details if creation failed
- Save and test the flow
Troubleshooting
Authorization Issues
Bash/WSL:
# If auth fails, try manual URL method:
sf org login web --alias dev-org --instance-url https://login.salesforce.com --json
# Copy the 'url' value and paste into your browser
PowerShell:
# If auth fails, try manual URL method:
sf org login web --alias dev-org --instance-url https://login.salesforce.com --json
# Copy the 'url' value from the output and paste into your browser
Deployment Errors
Bash/WSL:
# Check what's in your org
sf project list metadata --target-org dev-org
# Validate without deploying
sf project validate deploy --target-org dev-org
PowerShell:
# Check what's in your org
sf project list metadata --target-org dev-org
# Validate without deploying
sf project validate deploy --target-org dev-org
Test Failures
Bash/WSL:
# Run tests with verbose output
sf apex run test --target-org dev-org --result-format human --code-coverage -v
PowerShell:
# Run tests with verbose output
sf apex run test --target-org dev-org --result-format human --code-coverage -v
Reference: Classes Deployed
Apex Classes:
DocusignCompositeEnvelopeBuilder— Main invocable class (Flows)DocusignEnvelopeRequestHandler— Request validation & envelope building (reusable)DocusignAPIService— Docusign REST API wrapperDocusignCredentials— Custom settings singleton
Test Classes:
DocusignCompositeEnvelopeBuilderTest— Tests for main invocableDocusignEnvelopeRequestHandlerTest— Tests for request handler (10 test methods)DocusignAPIServiceTest— Tests for API serviceDocusignCredentialsTest— Tests for credentials
Custom Settings:
Docusign_Configuration__c— Stores Account ID and Base URL
Next Steps After Successful Deploy
- ✅ Verify all tests pass
- ✅ Create Docusign Configuration in Salesforce
- ✅ Set up Named Credential
- ✅ Create a test Screen Flow
- ✅ Test with real Docusign templates
- ✅ Deploy to Production (when ready)
For more details, see:
docs/deployment-guide.md— Detailed deployment instructionsdocs/api-reference.md— API referencedocs/design.md— Architecture & design decisions