Autotests for agents
Verify hosted MailAgent on prod without human OTP checks and without
DATABASE_URL. Contract tests inject mail via
POST /v1/inboxes/:id/simulate.
Prod gate
npm ci
MAILAGENT_API_URL=https://api.webmailagent.com \
MAILAGENT_API_KEY=ma_… \
npm run test:prod:gate # CI after deploy
npm run test:prod # full — before merge / tag v*
CI runs test:prod:gate (smoke:agent → smoke:qa). Full suite adds all contract-qa* + Playwright.
Environment
| Variable | Required | Notes |
|---|---|---|
MAILAGENT_API_KEY | yes | Team or legacy API key |
MAILAGENT_API_URL | no | Default https://api.webmailagent.com |
SMOKE_EXPECT_ATTACHMENTS | CI only | Set to 1 in GitHub Actions |
Test layers
| Command | Scope |
|---|---|
npm run test:prod:gate | CI smoke gate |
npm run test:prod | Full prod gate |
npm run smoke:agent | MCP, OAuth, DCR, Streamable HTTP |
npm run smoke:qa | Inbox lifecycle on prod |
npm run test:contract:all | 12 API contract scripts |
npm run test:contract:qa:agent | GET /v1/agent, /v1/me, /mcp/auth |
npm run check | TypeScript (no prod key) |
Agent workflow after a code change
GET /v1/agent— tools and auth discoverynpm run checkif you changedsrc/- Run one targeted
npm run test:contract:qa:*for your area npm run test:prodbefore merge- On failure:
npm run doctor:qaormailagent_diagnose_inbox
CI
GitHub Actions secret MAILAGENT_API_KEY is required.
Without it, deploy and PR checks fail on purpose.
Operator setup: docs/OPERATOR.md.
Add a new contract test
- Copy
scripts/contract-qa.mjs - Use
scripts/lib/contract-api.mjs(contractSimulate) - Register in
scripts/test-contract-all.mjs+package.json - Update docs/AUTOTESTS.md