Integration tests verify that data and control signals pass correctly between agents across the full automated flow. All tests run in the sandbox environment using the staging budget template. IDs continue from the Phase 1 sequence.
ID
Scenario
Agents Under Test
Input
Expected Output
Pass Criteria
T15
Actuals Sync Agent completion signal correctly triggers Variance Analysis Agent
Actuals Sync Agent → Variance Analysis Agent
Actuals Sync Agent completes a full successful write to the sandbox sheet
Variance Analysis Agent starts automatically within 30 seconds of sync completion signal
Variance agent run log shows trigger timestamp within 30 seconds of sync completion; no manual intervention required
T16
Variance Analysis Agent passes flagged line data to Slack prompt dispatch correctly
Variance Analysis Agent → Slack
4 lines flagged in variance calculation; 3 distinct cost-centre owners mapped in configuration
Each cost-centre owner receives only the Slack prompt for lines attributed to their centre; no cross-contamination
3 Slack messages sent to 3 distinct test users; each message contains only the lines for that user's cost centre
T17
Slack replies from department heads are correctly ingested into commentary draft
Slack → Variance Analysis Agent → Google Sheets
Two of three department heads reply within the 24-hour window; one does not reply
Replied content pre-populated into commentary cells for those two lines; unanswered line marked as pending; all three lines visible in the sheet
Two commentary cells contain reply text; one cell marked pending; no blank or null cells; report not blocked by the missing reply
T18
Finance manager approval in Google Sheets correctly triggers Report Distribution Agent
Google Sheets → Report Distribution Agent
Finance manager sets the approval cell to Approved in the sandbox sheet
Report Distribution Agent fires within 60 seconds; Drive publish and Slack notification complete
Agent trigger log timestamp within 60 seconds of approval cell change; Drive file created; Slack notification sent
T19
Variance Analysis Agent does not fire if Actuals Sync Agent exits with a partial-success status
Actuals Sync Agent → Variance Analysis Agent
Actuals Sync Agent exits with partial-success due to unmapped account (T04 scenario)
Variance Analysis Agent is blocked; operator alert fired; workflow paused pending manual resolution of unmapped lines
Variance agent run log shows no start event; alert message delivered to configured admin contact
T20
Report Distribution Agent does not fire if commentary contains any blank non-pending cells
Google Sheets → Report Distribution Agent
Finance manager sets approval to Approved but one commentary cell is completely blank (not marked pending)
Distribution agent blocked; validation error raised; finance manager notified to resolve the blank cell before re-approving
No Drive file created; no Slack notification sent; validation error log entry present; finance manager alert fired
T21
End-to-end agent chain completes within acceptable runtime for a 50-line report
All three agents in sequence
Sandbox P&L with 50 account lines; 6 flagged variances; all department heads reply within window
Full chain from trigger to Slack notification completes within 15 minutes (excluding the human review window)
Total automated runtime log shows completion under 15 minutes; all intermediate agent logs show no errors
T22
Token refresh mid-chain does not break agent handoff
Actuals Sync Agent → Variance Analysis Agent
QuickBooks OAuth token expires between the sync call and the variance trigger
Token refresh completes silently; variance agent receives the correct trigger and runs normally
Token refresh event logged; variance agent start confirmed; no data loss or duplicate write
Edge-case tests below cover scenarios outside the normal flow that the automation must handle gracefully without halting the pipeline or silently corrupting data.
ID
Scenario
Input
Expected Output
Pass Criteria
E01
Duplicate period-close trigger fires (e.g. scheduler misconfiguration sends two signals on the same date)
Two trigger events fire within 5 minutes for the same accounting period
Second trigger detected as a duplicate; workflow deduplication logic suppresses the second run; single sync completes
Exactly one sync run in the log for the period; second trigger flagged as duplicate; no double-write to Google Sheets
E02
QuickBooks P&L contains a duplicate account code (same code appears on two lines)
QuickBooks sandbox returns a P&L with account code 5100 appearing on two separate lines
Agent detects the duplicate, sums the values, writes the combined total to the mapped budget line, and logs a data-quality warning
Single row written for account 5100 with summed value; data-quality warning in log; no two rows written for the same code
E03
Google Sheets budget template has been manually restructured since the last run (column order changed)
Actuals column index has shifted by two columns due to a manual edit
Agent detects column header mismatch, halts the write, logs the structural change, and fires an alert rather than writing to wrong columns
No data written; structural mismatch logged; alert sent to configured admin; sheet left unchanged
E04
Slack is unavailable for the entire 24-hour department head response window
Slack API returns errors for the full 24-hour window; no department head prompts delivered
After the window expires, all flagged lines are marked as pending-no-response; commentary draft uses variance-only language; report is not blocked
All flagged lines show pending-no-response status; commentary cells populated with fallback text; approval gate opens on schedule
E05
Department head reply arrives after the configured 24-hour response window has closed
Slack reply received 26 hours after the prompt was sent
Late reply logged but not automatically merged into the commentary; finance manager notified of the late reply for manual consideration
Commentary cell retains the pre-close draft; late reply logged with timestamp; finance manager alert sent
E06
Finance manager does not approve or reject commentary within 48 hours of the variance agent completing
No action taken on the approval cell in Google Sheets for 48 hours
Escalation alert sent to the configured secondary contact (e.g. Operations Lead); workflow remains paused; no report published until approval received
Escalation alert fired at the 48-hour mark; secondary contact notified; workflow log shows paused state; no Drive file created