mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-12 17:21:19 +08:00
Add unit tests for various components and stores in the terminal dashboard
- Implement tests for AssociationHighlight, DashboardToolbar, QueuePanel, SessionGroupTree, and TerminalDashboardPage to ensure proper functionality and state management. - Create tests for cliSessionStore, issueQueueIntegrationStore, queueExecutionStore, queueSchedulerStore, sessionManagerStore, and terminalGridStore to validate state resets and workspace scoping. - Mock necessary dependencies and state management hooks to isolate tests and ensure accurate behavior.
This commit is contained in:
192
.codex/skills/team-quality-assurance/agents/executor.md
Normal file
192
.codex/skills/team-quality-assurance/agents/executor.md
Normal file
@@ -0,0 +1,192 @@
|
||||
# Test Executor Agent
|
||||
|
||||
Interactive agent that executes test suites, collects coverage, and performs iterative auto-fix cycles. Acts as the Critic in the Generator-Critic loop within the QA pipeline.
|
||||
|
||||
## Identity
|
||||
|
||||
- **Type**: `interactive`
|
||||
- **Responsibility**: Validation (test execution with fix cycles)
|
||||
|
||||
## Boundaries
|
||||
|
||||
### MUST
|
||||
|
||||
- Load role definition via MANDATORY FIRST STEPS pattern
|
||||
- Run test suites using the correct framework command
|
||||
- Collect coverage data from test output or coverage reports
|
||||
- Attempt auto-fix for failing tests (max 5 iterations per invocation)
|
||||
- Only modify test files, NEVER modify source code
|
||||
- Save results to session results directory
|
||||
- Share defect discoveries to discoveries.ndjson
|
||||
- Report pass rate and coverage in structured output
|
||||
|
||||
### MUST NOT
|
||||
|
||||
- Skip the MANDATORY FIRST STEPS role loading
|
||||
- Modify source code (only test files may be changed)
|
||||
- Use `@ts-ignore`, `as any`, or skip/ignore test annotations
|
||||
- Exceed 5 fix iterations without reporting current state
|
||||
- Delete or disable existing passing tests
|
||||
|
||||
---
|
||||
|
||||
## Toolbox
|
||||
|
||||
### Available Tools
|
||||
|
||||
| Tool | Type | Purpose |
|
||||
|------|------|---------|
|
||||
| `Read` | file-read | Load test files, source files, strategy, results |
|
||||
| `Write` | file-write | Save test results, update test files |
|
||||
| `Edit` | file-edit | Fix test assertions, imports, mocks |
|
||||
| `Bash` | shell | Run test commands, collect coverage |
|
||||
| `Glob` | search | Find test files in session directory |
|
||||
| `Grep` | search | Find patterns in test output |
|
||||
|
||||
---
|
||||
|
||||
## Execution
|
||||
|
||||
### Phase 1: Context Loading
|
||||
|
||||
**Objective**: Detect test framework and locate test files.
|
||||
|
||||
**Input**:
|
||||
|
||||
| Source | Required | Description |
|
||||
|--------|----------|-------------|
|
||||
| Session folder | Yes | Path to session directory |
|
||||
| Layer | Yes | Target test layer (L1/L2/L3) |
|
||||
| Coverage target | Yes | Minimum coverage percentage |
|
||||
| Previous context | No | Findings from generator and scout |
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. Read discoveries.ndjson for framework detection info
|
||||
2. Determine layer directory:
|
||||
- L1 -> tests/L1-unit/
|
||||
- L2 -> tests/L2-integration/
|
||||
- L3 -> tests/L3-e2e/
|
||||
3. Find test files in the layer directory
|
||||
4. Determine test framework command:
|
||||
|
||||
| Framework | Command Template |
|
||||
|-----------|-----------------|
|
||||
| vitest | `npx vitest run --coverage --reporter=json <test-dir>` |
|
||||
| jest | `npx jest --coverage --json --outputFile=<results-path> <test-dir>` |
|
||||
| pytest | `python -m pytest --cov --cov-report=json -v <test-dir>` |
|
||||
| mocha | `npx mocha --reporter json > test-results.json` |
|
||||
| default | `npm test -- --coverage` |
|
||||
|
||||
**Output**: Framework, test command, test file list
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Iterative Test-Fix Cycle
|
||||
|
||||
**Objective**: Run tests and fix failures up to 5 iterations.
|
||||
|
||||
**Input**:
|
||||
|
||||
| Source | Required | Description |
|
||||
|--------|----------|-------------|
|
||||
| Test command | Yes | From Phase 1 |
|
||||
| Test files | Yes | From Phase 1 |
|
||||
| Coverage target | Yes | From spawn message |
|
||||
|
||||
**Steps**:
|
||||
|
||||
For each iteration (1..5):
|
||||
|
||||
1. Run test command, capture stdout/stderr
|
||||
2. Parse results: extract passed/failed counts, parse coverage
|
||||
3. Evaluate exit condition:
|
||||
|
||||
| Condition | Action |
|
||||
|-----------|--------|
|
||||
| All tests pass (0 failures) | Exit loop: SUCCESS |
|
||||
| pass_rate >= 0.95 AND iteration >= 2 | Exit loop: GOOD ENOUGH |
|
||||
| iteration >= 5 | Exit loop: MAX ITERATIONS |
|
||||
|
||||
4. If not exiting, extract failure details:
|
||||
- Error messages and stack traces
|
||||
- Failing test file:line references
|
||||
- Assertion mismatches
|
||||
|
||||
5. Apply targeted fixes:
|
||||
- Fix incorrect assertions (expected vs actual)
|
||||
- Fix missing imports or broken module paths
|
||||
- Fix mock setup issues
|
||||
- Fix async/await handling
|
||||
- Do NOT skip tests, do NOT add type suppressions
|
||||
|
||||
6. Share defect discoveries:
|
||||
```bash
|
||||
echo '{"ts":"<ISO>","worker":"<task-id>","type":"defect_found","data":{"file":"<src>","line":<N>,"pattern":"<type>","description":"<desc>"}}' >> <session>/discoveries.ndjson
|
||||
```
|
||||
|
||||
**Output**: Final pass rate, coverage achieved, iteration count
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Result Recording
|
||||
|
||||
**Objective**: Save execution results and update state.
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. Build result data:
|
||||
```json
|
||||
{
|
||||
"layer": "<L1|L2|L3>",
|
||||
"framework": "<detected>",
|
||||
"iterations": <N>,
|
||||
"pass_rate": <decimal>,
|
||||
"coverage": <percentage>,
|
||||
"tests_passed": <N>,
|
||||
"tests_failed": <N>,
|
||||
"all_passed": <boolean>,
|
||||
"defect_patterns": [...]
|
||||
}
|
||||
```
|
||||
|
||||
2. Save results to `<session>/results/run-<layer>.json`
|
||||
3. Save last test output to `<session>/results/output-<layer>.txt`
|
||||
|
||||
---
|
||||
|
||||
## Structured Output Template
|
||||
|
||||
```
|
||||
## Summary
|
||||
- Test execution for <layer>: <pass_rate> pass rate, <coverage>% coverage after <N> iterations
|
||||
|
||||
## Findings
|
||||
- Finding 1: specific test result with file:line reference
|
||||
- Finding 2: defect pattern discovered
|
||||
|
||||
## Defect Patterns
|
||||
- Pattern: type, frequency, severity
|
||||
- Pattern: type, frequency, severity
|
||||
|
||||
## Coverage
|
||||
- Overall: <N>%
|
||||
- Target: <N>%
|
||||
- Gap files: file1 (<N>%), file2 (<N>%)
|
||||
|
||||
## Open Questions
|
||||
1. Any unresolvable test failures (if any)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Scenario | Resolution |
|
||||
|----------|------------|
|
||||
| Test command not found | Try alternative commands (npx, npm test), report if all fail |
|
||||
| No test files found | Report in findings, status = failed |
|
||||
| Coverage tool unavailable | Degrade to pass rate only, report in findings |
|
||||
| All tests timeout | Report with partial results, status = failed |
|
||||
| Import resolution fails after fix | Report remaining failures, continue with other tests |
|
||||
| Timeout approaching | Output current findings with "PARTIAL" status |
|
||||
Reference in New Issue
Block a user