Skip to content

True E2E Test: Agent Creation → Issue Creation Pipeline #2

Description

@om952

Summary

Added a true end-to-end test that verifies the full agent creation → adapter spawn → model response → issue creation pipeline works through real HTTP requests against a running Levi server.

Test Coverage

File: server/src/__tests__/agent-issue-creation-true-e2e.test.ts

Test 1: Full Flow (60s timeout)

  • Creates company in real DB
  • Creates CTO agent via HTTP POST /api/companies/{id}/agents
  • Verifies CTO has canCreateAgents: true permission
  • Verifies API key auto-generated in DB
  • Creates subordinate engineer agent via HTTP
  • Verifies engineer has API key
  • Creates issue via HTTP POST /api/companies/{id}/issues
  • Verifies issue exists in real DB with correct status
  • Verifies process adapter has JWT support

Test 2: Adapter Config (30s timeout)

  • Creates agent with custom adapter config
  • Verifies adapter config persisted in DB
  • Verifies API key exists with proper hash

Test 3: Permission Enforcement (30s timeout)

  • Creates user without agent:create permission
  • Verifies engineer role gets canCreateAgents: false by default

Technical Details

  • Uses embedded PostgreSQL (real DB, not mocked)
  • Starts real Levi Express app with all services
  • Makes actual HTTP requests via supertest
  • Cleans up activity_log, agents, issues, companies between tests
  • 78 total tests passing across all Issue Fix Agent Issue Creation - Adapter Failure OpenScanAI/Levi#4 related test files

Test Results

✓ |@paperclipai/server| src/__tests__/agent-issue-creation-true-e2e.test.ts (3 tests) 1006ms
Test Files  7 passed (7)
Tests  78 passed (78)

Files Changed

  • server/src/__tests__/agent-issue-creation-true-e2e.test.ts (new, 338 lines)

How to Run

cd /Users/omkandpal/Levi
pnpm test -- server/src/__tests__/agent-issue-creation-true-e2e.test.ts

Manual Verification Steps

  1. Start Levi server:

    cd /Users/omkandpal/Levi/server
    pnpm dev
  2. Create company via API:

    curl -X POST http://localhost:3100/api/companies \
      -H "Content-Type: application/json" \
      -d '{"name":"Test Co","issuePrefix":"TC"}'
  3. Create CTO agent:

    curl -X POST http://localhost:3100/api/companies/{companyId}/agents \
      -H "Content-Type: application/json" \
      -d '{"name":"CTO","role":"cto","adapterType":"process"}'
  4. Verify in DB:

    psql $DATABASE_URL -c "SELECT * FROM agents WHERE role = 'cto';"
    psql $DATABASE_URL -c "SELECT * FROM agent_api_keys WHERE agent_id = '{agentId}';"
  5. Create issue:

    curl -X POST http://localhost:3100/api/companies/{companyId}/issues \
      -H "Content-Type: application/json" \
      -d '{"title":"Test issue","priority":"high","assigneeAgentId":"{agentId}"}'
  6. Verify issue in DB:

    psql $DATABASE_URL -c "SELECT * FROM issues WHERE title = 'Test issue';"

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions