---
description: Create and implement integration tests for module
agent: orchestrator
---

# Integration Test: $ARGUMENTS

**Module:** $ARGUMENTS
**Project:** $(basename $(pwd))
**Timestamp:** $(date '+%Y-%m-%d %H:%M:%S')

## Phase 1: Module Analysis

**GKG Module Discovery:**
!`gkg search_codebase_definitions --project_absolute_path $(pwd) --search_terms ["$ARGUMENTS"] --page 1`

**Dependency Analysis:**
!`gkg get_references --definition_name "$ARGUMENTS" --file_path "$(find . -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.go" | head -1)" --page 1`

**Module Structure:**
!`gkg repo_map --project_absolute_path $(pwd) --relative_paths "$(find . -name "*$ARGUMENTS*" -type d | head -1)" --depth 2`

## Phase 2: Test Strategy

**Integration Points Identified:**

- [ ] External API dependencies
- [ ] Database connections
- [ ] Service interactions
- [ ] Message queues/events
- [ ] File system operations

**Test Scope:**

- Unit tests: Already covered by existing tests
- Integration tests: Cross-component interactions
- End-to-end tests: Full user workflows

## Phase 3: Task Creation

**Create Integration Test Tasks:**
!`backlog task create "Integration test setup for $ARGUMENTS module" --priority high --ac "Test framework configured,Test environment setup,Mock services created"`

!`backlog task create "Implement $ARGUMENTS integration tests" --priority high --dep "$(backlog task list --plain | grep "Integration test setup" | tail -1 | cut -d' ' -f1)" --ac "API integration tests,Database integration tests,Error handling validation"`

!`backlog task create "Cross-module integration validation" --priority medium --dep "$(backlog task list --plain | grep "Implement $ARGUMENTS integration tests" | tail -1 | cut -d' ' -f1)" --ac "Service interaction tests,Data flow validation,Performance benchmarks"`

## Phase 4: Agent Assignment

**Task Assignment:**

- **Setup Task:** @build (uses devops/ skill for test environment, mocking)
- **Implementation Task:** @build (implements test code, assertions)
- **Validation Task:** @code-auditor (validates complex integrations, performance)

**Execute Implementation:**

```
@build Implement integration tests for $ARGUMENTS module

Requirements:
1. Use existing test framework (jest, pytest, etc.)
2. Mock external dependencies
3. Test all integration points identified above
4. Include error scenarios and edge cases
5. Ensure tests are deterministic and fast

Reference module analysis from Phase 1.
```

## Phase 5: Validation

**Test Execution:**
!`npm test -- --testPathPattern="$ARGUMENTS.*integration" 2>/dev/null || echo "Run integration tests manually"`

**Coverage Check:**
!`npm run test:coverage 2>/dev/null | grep "$ARGUMENTS" || echo "Check coverage manually"`

## Completion Criteria

- [ ] All integration points tested
- [ ] Tests pass consistently
- [ ] Coverage > 80% for module
- [ ] CI/CD pipeline updated
- [ ] Documentation updated

---

_Integration tests ensure $ARGUMENTS module works correctly with all dependencies_
