Integration tests validate that data flows correctly across tool boundaries and that the handoff between the Contractor Onboarding Agent and the Invoice Processing Agent produces a consistent record state in HubSpot throughout. All IDs continue the T sequence from Phase 1.
ID
Scenario
Tools involved
Expected output
Pass criteria
T15
Full onboarding handoff: HubSpot record created, DocuSign sent, Drive folder created, Gusto payee added in one uninterrupted sequence
HubSpot, DocuSign, Google Drive, Gusto
All four systems reflect consistent contractor data with matching name, role, rate, and start date; no field drift between systems
Field values in all four sandbox systems are identical to the trigger payload values; no data transformation errors in logs
T16
DocuSign completion webhook triggers Gusto payee creation without manual intervention
DocuSign, HubSpot, Gusto
On envelope status change to Completed, Gusto payee record is created automatically within 2 minutes; HubSpot contact status updated to 'Agreement Signed'
Gusto sandbox payee created within 2-minute window; HubSpot status field updated; no manual step required
T17
Invoice Processing Agent reads rate from HubSpot record created by Onboarding Agent
HubSpot, Invoice Processing Agent
Agent correctly retrieves agreed rate from HubSpot contact record and uses it for invoice matching without requiring manual rate entry
Rate used in matching logic matches the value stored in HubSpot; no hardcoded fallback value used
T18
Slack approval triggers Xero and Gusto simultaneously without race condition
Slack, Xero, Gusto
On approval, Xero bill created and Gusto payment trigger fired in the correct order; Gusto does not fire before Xero bill reference is available
Xero bill ID is present in the Gusto payment payload; no Gusto call made before Xero confirms bill creation
T19
HR Slack alert for missing documents includes correct contractor name and outstanding document list
HubSpot, Google Drive, Slack
Slack message body pulls contractor name from HubSpot and outstanding document list by comparing Drive folder contents against required checklist
Slack message contains correct name and lists only the documents genuinely absent from the Drive folder; no false positives
T20
Contractor completes DocuSign before document collection email is sent: ordering conflict
DocuSign, HubSpot, Google Drive
System detects that DocuSign is already complete at the point of document email dispatch; sends document email regardless (DocuSign is separate from compliance documents); no duplicate emails sent
Document collection email sent exactly once; no duplicate; DocuSign status in HubSpot not reset
T21
Slack approval message sent but manager does not respond within 48 hours
Slack, HubSpot
Escalation reminder sent to manager after 48-hour timeout; HubSpot invoice record updated with 'Pending Approval' status; Finance team alerted via Slack
Escalation message sent at 48-hour mark; HubSpot status field updated; Finance Slack alert received with invoice details and manager name
T22
Second invoice submitted by same contractor while first invoice approval is still pending
HubSpot, Slack, Xero
Second invoice queued in HubSpot; Slack notification to Finance noting a second invoice is pending while first is unresolved; no Xero bill created for second invoice until first is resolved
HubSpot shows two invoice records with distinct statuses; second Xero bill not created; Finance Slack alert received with both invoice references
Edge case tests cover scenarios where data is malformed, tools are temporarily unavailable, a contractor submits a duplicate record, or a human step times out. These tests use IDs in the E series.
ID
Scenario
Input condition
Expected behaviour
Pass criteria
E01
Duplicate contractor: same email submitted via form twice within 10 minutes
Two form submissions with identical email address
Second trigger detected as duplicate; second HubSpot record creation blocked; HR Slack alert identifies duplicate with timestamp of both submissions
Only one HubSpot contact created; Slack alert received; second submission logged with duplicate flag in automation error log
E02
Missing required field: contractor rate not included in trigger payload
Form submission or HubSpot record with rate field blank or null
Automation halts at rate validation step; HR Slack alert requests rate be entered manually before workflow resumes; no DocuSign sent
DocuSign not dispatched; HubSpot contact status set to 'Pending Rate Entry'; Slack alert received with contractor name and missing field identified
E03
Google Drive API unavailable at time of document folder creation
Drive API returns 503 at folder creation step
Automation retries three times with 2-minute intervals; on third failure posts alert to HR Slack channel with error details; document upload step queued for manual retry
Three retry attempts logged with timestamps; HR Slack alert received after final failure; no partial folder created in Drive
E04
DocuSign template not found: template ID in HubSpot record does not match any active DocuSign template
HubSpot record with role value that maps to a deleted or draft DocuSign template
Automation catches template not found error; logs error with template ID; alerts HR Slack channel to assign the correct template before retrying
No envelope created; HR Slack alert received with the unresolvable template ID; HubSpot contact status set to 'DocuSign Template Error'
E05
Invoice PDF unreadable: file corrupted or zero-byte attachment
Invoice email with zero-byte PDF attachment
Automation detects unreadable file; saves original email to holding folder; alerts Finance via Slack to request a replacement invoice from the contractor
No invoice data extracted; Finance Slack alert received with sender details; original email reference logged; no Xero bill attempted
E06
Gusto API returns authentication error during payee creation
Gusto access token expired at time of payee creation step
Automation attempts token refresh; if refresh fails, logs error and alerts Finance Slack channel; Gusto payee creation queued for retry after manual token renewal
Token refresh attempt logged; Finance Slack alert received with error type; no partial Gusto record created; retry queue updated
E07
Human timeout: HR reviewer does not act on a flagged missing document within 5 business days
HR Slack alert for missing document with no action taken for 5 business days
Escalation alert sent to Operations Lead (Priya Menon) via Slack; HubSpot contractor record updated with escalation timestamp; contractor start date flag added
Escalation Slack message sent to correct channel at 5-business-day mark; HubSpot record shows escalation flag; original HR alert remains open
E08
Slack workspace temporarily unavailable during approval routing
Slack API returns 503 at approval message dispatch step
Automation retries Slack delivery twice at 5-minute intervals; on second failure sends approval request via email to the manager's address stored in HubSpot; logs Slack failure with timestamp
Email approval request sent to correct manager address after Slack retry failures; Slack failure logged; invoice record in HubSpot updated with 'Approval Via Email' status