Contract Drafting Agent (trigger: HubSpot deal stage moves to Closed Won; outputs: populated contract draft saved to Google Drive)
ID
Scenario
Input
Expected Output
Pass Criteria
T01
Happy path: complete deal record, standard service type
HubSpot sandbox deal with all mandatory fields populated (client name, entity type, service type, start date, fee amount, payment terms)
Correct template selected; all variable fields populated accurately; draft saved to Google Drive test folder with correct naming convention
Google Drive file exists; filename matches pattern CLIENT_ContractType_YYYY-MM-DD; all placeholder fields replaced with deal data; no unfilled tokens remain in document
T02
Template selection: multiple service types mapped
Three separate sandbox deals each with a different service type value in HubSpot
Each deal triggers selection of the corresponding contract template from the library; no template mismatch
Template filename in Google Drive matches the service-type-to-template mapping table defined in the field-mapping specification for all three deals
T03
Field population accuracy: special characters and long strings
HubSpot deal with client entity name containing an ampersand and a registered trademark symbol; fee amount with decimal cents
Contract draft renders special characters correctly; fee amount formatted to two decimal places
Rendered document reviewed in Google Drive; no encoding errors; fee field matches HubSpot value exactly
T04
Failure mode: missing mandatory HubSpot field (start date absent)
HubSpot sandbox deal with start date field left blank
Agent halts population; flags the incomplete record; does not save a partial draft; sends an internal alert notification
No draft file created in Google Drive; alert notification delivered to the configured internal Gmail address; error logged in automation platform run history
T05
Failure mode: missing mandatory HubSpot field (fee amount absent)
HubSpot sandbox deal with fee amount field left blank
Agent halts; flags the record; no draft saved; internal alert sent
Same pass criteria as T04; error message text references the specific missing field name
T06
Failure mode: no matching template for service type value
HubSpot sandbox deal with service type set to a value not present in the template library
Agent halts; flags unrecognised service type; does not attempt to use a fallback template; internal alert sent
No draft file created; error log entry includes the unrecognised service type value; alert received in Gmail test inbox
T07
Failure mode: Google Drive write permission denied
Sandbox deal with all fields complete; Google Drive test folder permissions set to read-only for the automation service account
Agent logs a Google Drive write error; does not silently fail; internal alert sent; run marked as failed in automation platform
Run history shows error state; no partial file in Drive; alert received; run does not retry indefinitely (maximum three retries confirmed in logs)
T08
Naming convention enforcement
Sandbox deal with client name containing spaces and mixed case
Google Drive filename normalised to uppercase client name with underscores replacing spaces, matching the agreed naming convention
Filename in Google Drive matches the exact pattern defined in the field-mapping specification; no raw spaces in filename
Signature and Filing Agent (trigger: manager approves contract draft via Gmail approval link; outputs: DocuSign envelope dispatched, executed contract filed, HubSpot updated, Xero invoice drafted)
ID
Scenario
Input
Expected Output
Pass Criteria
T09
Happy path: manager approves via Gmail link
Simulated approval payload from Gmail sandbox; Google Drive draft file present at expected path
DocuSign sandbox envelope created with correct recipient email and signing fields placed per template; envelope dispatched
DocuSign sandbox shows envelope in Sent status; recipient matches HubSpot contact email; signing fields present at predefined positions
T10
Reminder sequence: day-3 reminder fires
DocuSign sandbox envelope in Sent status; simulated time advance to day 3 with no signer action
DocuSign automated reminder email sent to recipient at 72-hour mark
DocuSign sandbox activity log shows reminder event at day 3; no manual intervention required
T11
Reminder sequence: day-5 reminder fires
DocuSign sandbox envelope in Sent status; simulated time advance to day 5 with no signer action
Second DocuSign reminder email sent at 120-hour mark
DocuSign sandbox activity log shows second reminder event at day 5
T12
Post-signature filing: executed contract saved to Google Drive
DocuSign sandbox envelope marked Completed (all parties signed)
Executed PDF retrieved from DocuSign and saved to the executed-contracts folder in Google Drive with standardised naming
File exists in correct subfolder; filename matches EXECUTED_CLIENT_ContractType_YYYY-MM-DD pattern; file is the signed PDF not the draft
T13
HubSpot CRM update on execution
DocuSign sandbox envelope marked Completed
HubSpot deal record updated: contract status field set to Executed; link to Google Drive executed file written to deal notes
HubSpot sandbox deal record shows correct contract status value and a valid Google Drive URL in the notes field
T14
Xero draft invoice creation on execution
DocuSign sandbox envelope marked Completed; HubSpot deal record contains fee amount and payment terms
Draft invoice created in Xero demo company with correct contact, line item description, amount, and due date derived from payment terms
Xero demo company shows a Draft invoice; contact name matches HubSpot client; amount matches fee field; due date calculated correctly from payment terms
T15
Failure mode: DocuSign envelope creation fails (API error)
Valid approval payload; DocuSign sandbox configured to return a 500 error on envelope creation
Agent logs DocuSign API error; does not proceed to send; internal alert sent; run marked failed
Run history shows error state with DocuSign error code; alert received in Gmail test inbox; no orphaned envelope in DocuSign
T16
Failure mode: Xero invoice creation fails (authentication error)
DocuSign envelope Completed; Xero OAuth token expired in sandbox
Agent logs Xero authentication error; files the contract to Google Drive and updates HubSpot regardless; sends alert that Xero step requires manual completion
Google Drive and HubSpot steps confirmed complete; Xero shows no invoice; alert received specifying Xero authentication failure and the deal reference