5.3 KiB
5.3 KiB
Integration Test Plan
Integration tests verify real agent-platform interactions using actual agent binaries
with a mock platform. Tests are gated by //go:build integration and excluded from
normal CI. Run with:
go test -tags=integration ./tests/integration/...
Philosophy
- Real agents, mocked platform: Agents run as real subprocesses; platform is mocked to record and verify all messages without network dependencies.
- Agent pooling: Agent instances are reused across tests to avoid per-test startup overhead (Claude Code cold start ~3-6s).
- Resilient assertions: Use case-insensitive substring matching, generous timeouts, and skip agents that fail due to auth/infra issues (e.g., OpenCode needs GitLab token).
Implemented Cases
Session Management
TestNewSession_ClaudeCode— New session spawns, agent respondsTestNewSession_Codex— Same for CodexTestListSessions_ShowsActiveSessions—/listshows active sessionsTestSwitchSession—/switchchanges active sessionTestStopCommand—/stopinterrupts active sessionTestNewSessionClearsContext— After/new, prior context is clearedTestHistoryCommand—/historyreturns conversation historyTestConcurrentSessionIsolation— Two sessions don't cross-talk
Agent Interaction
TestEventParsing_ThinkToolUse— Tool calls (echo) are parsed and produce outputTestMarkdownLongTextChunking— Long responses chunked correctlyTestPermissionModeSwitch—/mode yoloand/mode defaultworkTestAgentCodex— Codex agent respondsTestAgentCursor— Cursor agent responds (⚠️ may respond in locale)TestAgentGemini— ⚠️ Fails due to quota exhaustion in CI envTestAgentOpencode— ⚠️ Requires GitLab auth, skippedTestSharedCasesAcrossAgents— Same prompts validated across agentsTestLongTextChunking— Very long user input (5k+ chars) processed
Commands & Built-ins
TestShellCommand—/shellexecutes (skips ifadmin_fromnot set)TestProviderSwitch—/provider listworks
i18n
TestLanguageSwitch—/lang zhchanges language (⚠️ may skip due to locale)TestEmptyMessage— Whitespace-only messages handled gracefully
Message Handling
TestImageAttachmentRouting— Image-bearing messages routed (⚠️ needs real image)
Planned Cases (not yet implemented)
Multi-Agent / Provider
TestSessionResume— Send/new, reconnect to same session key, verify context preservedTestProviderSwitchActual—/provider switch <name>actually changes provider mid-sessionTestModelSwitch—/model <name>changes model; responses reflect new modelTestConcurrentMultiAgent— Two different agent types active simultaneously
Commands & Built-ins
TestCustomCommand— Register and invoke a custom commandTestAliasCommand— Create/use alias; verify substitutionTestDirCommand—/dirnavigates workspace; agent respects new directoryTestSearchCommand—/search <query>invokes search
Permission & Safety
TestPermissionPromptBypass—yolomode bypasses permission prompts;defaultshows themTestSensitiveMessageRedaction— Tokens/secrets in user input are redactedTestBannedWordBlocking— Banned-word messages rejected with feedback
Message Handling
TestFileAttachmentRouting— File attachments reach agentTestVoiceMessageHandling— Voice messages transcribed/processed or gracefully rejectedTestMarkdownParsing— Markdown in agent responses rendered correctly
Rate Limiting & Performance
TestIncomingRateLimit— Rapid messages rate-limited; excess queued/rejectedTestOutgoingRateLimit— Rapid agent output respects platform limitsTestSlowAgentTimeout— Slow agent (>idle timeout) flagged or session reaped
i18n
TestMultiLanguageResponses— Same prompt in different language configs produces localized responses
Error & Edge Cases
TestBadAgentOutput— Malformed agent output handled gracefully (no panic)TestAgentCrashRecovery— Agent dies mid-session; engine detects, notifies, allows respawnTestVeryLongAgentResponse— Extremely long response (>50k chars); chunking works, no OOMTestConcurrentSessionCreation— Rapid session creation; keys unique, no state leakage
ACP / Relay
TestACPMessageRelay— ACP message relayed to agent; response returns via correct channelTestRelaySessionKeyPreservation—CC_SESSION_KEYpropagated through relay; session continuity maintained
Notes
- Timeout guidelines: Simple prompts ("say hi") — 30s; tool use — 60s; slow agents (gemini, opencode) — 90s; long output — 120s.
- Skip vs Fail: Auth/infra failures (
Skip) are expected in some environments; code bugs shouldFatal. Uset.Skipf("reason")for expected env issues. - Agent pool reuse: The pool key includes
workDir, so tests using the same workDir share the same agent instance. Uset.TempDir()for isolation. - Parallel tests: Use
t.Parallel()for independent tests. Avoid parallel subtests that share session keys to prevent race conditions.