Integration tests confirm that data passes correctly between agents at each handoff point. All tests use sandbox credentials. IDs continue from Phase 1.
ID
Scenario
Agents involved
Input
Expected output
Pass criteria
T16
Intake to Dispatch handoff — label URL passed correctly
Returns Intake Agent to Dispatch and Monitoring Agent
Qualifying return processed by Intake Agent; label URL written to Google Sheets
Dispatch Agent reads label URL from sheet and includes it in the Gmail send without manual intervention
Email contains the exact label URL written by the Intake Agent; no truncation or encoding error
T17
Dispatch to Reconciliation handoff — inspection form submission triggers correct agent
Dispatch and Monitoring Agent to Refund and Reconciliation Agent
Slack alert posted by Dispatch Agent; warehouse operative submits inspection form via the link in the message
Form submission fires the Reconciliation Agent with the correct order_id, inspection outcome, and refund type
Reconciliation Agent execution log shows order_id matching the Slack alert; no field mismatch; agent runs within 60 seconds of form submission
T18
Full end-to-end sandbox run — qualifying return, full refund
All three agents in sequence
Shopify sandbox webhook for a qualifying return; simulated delivery event; inspection form submitted with full refund outcome
All automated steps complete: sheet logged, label created, email sent, Slack alert posted, Shopify refund issued, Xero credit note created, confirmation email sent
All seven automated outputs present and correct; execution time under 3 minutes from trigger to confirmation email; no manual steps required
T19
Xero credit note amount matches Shopify refund exactly
Refund and Reconciliation Agent
Shopify partial refund of $47.50 issued by agent
Xero credit note created with net amount = $47.50 and correct customer reference from Shopify order
Xero API response: creditNote.total = 47.50; creditNote.contact matches Shopify customer name; no rounding error
T20
Inventory increment applied to correct Shopify location
Refund and Reconciliation Agent
Resalable return for SKU 'RET-1042'; default warehouse location configured in settings
Shopify inventory_level for SKU 'RET-1042' at the configured location incremented by 1
Shopify inventory_levels API response shows +1 for the correct location_id; no other location affected
T21
Google Sheets row status updated at each stage
All three agents
Full qualifying return run in sandbox
Sheet row status column updated at: intake logged, label created, email sent, delivered, inspection received, refund issued, credit note created, confirmation sent
Sheet column 'status' reflects each stage update; timestamps populated at each transition; no stage skipped
T22
Shopify refund API rate limit handling
Refund and Reconciliation Agent
Shopify sandbox configured to return 429 Too Many Requests on first refund attempt
Agent waits the Retry-After interval specified in the response header, then retries successfully
Execution log shows 429 received; retry fired after correct wait; refund issued on second attempt; no duplicate refund
T23
Xero API token expiry mid-run
Refund and Reconciliation Agent
Xero sandbox access token expired; refresh token valid
Agent detects 401, triggers OAuth refresh, obtains new access token, and completes credit note creation
Execution log shows 401 then successful token refresh; credit note created; no manual intervention required
T24
Multi-item order — only one item returned, inventory delta scoped correctly
Refund and Reconciliation Agent
Order with 3 line items; only line item 1 (SKU 'RET-0091') returned and approved
Refund applied only to line item 1; only SKU 'RET-0091' inventory incremented; other SKUs unchanged
Shopify refund line_items array contains only 'RET-0091'; inventory delta for 'RET-0091' = +1; other SKUs unchanged
T25
Confirmation email not sent if refund type is none
Refund and Reconciliation Agent
Inspection outcome = write_off; refund_type = none
No confirmation email sent; sheet status = 'Write-off — no refund'; Gmail API not called
Gmail API call count for this execution = 0; sheet status correct; no email in test inbox
T26
Exception path record visible in sheet for human review
Returns Intake Agent
Non-qualifying return (excluded product type)
Sheet row created with status = 'Exception'; no downstream agents triggered; row includes reason for exception
Sheet row present; status = 'Exception'; reason_code field populated; no ShipStation, Gmail, or Slack calls in execution log
Edge-case tests cover scenarios outside the standard happy path that could cause silent failures, duplicate records, or unhandled states. These use E-prefixed IDs and run in the same sandbox environment as the integration tests above.
ID
Scenario
Condition
Expected behaviour
Pass criteria
E01
Duplicate return submission — same order submitted twice within 60 seconds
Two identical Shopify webhooks arrive for the same order_id
Second webhook detected as duplicate; second execution halted before sheet write; only one row created
Google Sheets contains exactly one row for the order_id; execution log shows 'duplicate detected' on second run
E02
Shopify webhook arrives with no reason code
Return submitted via portal with reason field left blank
Agent assigns reason_code = 'Not provided'; logs the row; proceeds with all other eligible fields; label still created if otherwise qualifying
Sheet row reason_code = 'Not provided'; label created if order is within window; no unhandled error in execution log
E03
ShipStation delivery event fires before Intake Agent has written the row
Race condition: delivery webhook arrives within seconds of a new return being logged
Dispatch Agent polls Google Sheets with a short retry loop (up to 3 attempts, 10-second intervals); matches row on third attempt
Slack alert eventually posted; execution log shows retry attempts; no permanent failure logged; row matched correctly
E04
Inspection form submitted with no outcome selected
Warehouse operative submits the inspection form leaving the outcome field blank
Reconciliation Agent detects missing outcome field; posts follow-up Slack message to warehouse channel requesting resubmission; does not proceed to refund
No Shopify refund issued; follow-up Slack message posted within 60 seconds; sheet status = 'Awaiting Inspection Resubmission'
E05
Xero is unavailable (simulated 500 from Xero API)
Xero API returns 500 on credit note create endpoint
Agent retries 3 times with 30-second backoff; after final failure, sheet row flagged 'Xero Error — manual credit note required'; Shopify refund is NOT rolled back
Shopify refund status = refunded; Xero credit note not created; sheet status = 'Xero Error — manual credit note required'; execution log contains all 3 retry attempts
E06
Slack warehouse channel is archived or renamed
Dispatch Agent attempts to post Slack alert to a channel that no longer exists
Agent catches channel_not_found error; logs the failure; sheet row updated to 'Slack Alert Error'; FullSpec error log surfaced for manual follow-up
Slack post not delivered silently; sheet status = 'Slack Alert Error'; error visible in automation platform error log
E07
Human timeout — inspection form not submitted within 48 hours of Slack alert
Delivery confirmed; Slack alert sent; 48-hour window elapses with no form submission
Automation sends a second Slack reminder to the warehouse channel referencing the original order; sheet status updated to 'Awaiting Inspection — Reminder Sent'
Second Slack message appears at the 48-hour mark; sheet status updated; no refund issued prematurely; original alert message still present in channel
E08
Return label emailed to an invalid or bounced address
Gmail send succeeds (HTTP 200) but a bounce notification is received within the test window
Agent cannot detect bounce natively; bounce handling relies on Gmail bounce monitoring configured in the Gmail account settings. FullSpec confirms this limitation is documented in the SOP for manual follow-up by the customer service team
Execution log shows send success; SOP reference for bounce handling is confirmed present in the handover documentation