diff --git a/legacy-command-shims/commands/e2e.md b/legacy-command-shims/commands/e2e.md index 4fd5ad16..dc95ff43 100644 --- a/legacy-command-shims/commands/e2e.md +++ b/legacy-command-shims/commands/e2e.md @@ -21,248 +21,3 @@ Apply the `e2e-testing` skill. - Generate or update Playwright coverage for the requested user flow. - Run only the relevant tests unless the user explicitly asked for the entire suite. - Capture the usual artifacts and report failures, flake risk, and next fixes without duplicating the full skill body here. - await marketsPage.searchMarkets('xyznonexistentmarket123456') - - // Verify empty state - await expect(page.locator('[data-testid="no-results"]')).toBeVisible() - await expect(page.locator('[data-testid="no-results"]')).toContainText( - /no.*results|no.*markets/i - ) - - const marketCount = await marketsPage.marketCards.count() - expect(marketCount).toBe(0) - }) - - test('can clear search and see all markets again', async ({ page }) => { - const marketsPage = new MarketsPage(page) - await marketsPage.goto() - - // Initial market count - const initialCount = await marketsPage.marketCards.count() - - // Perform search - await marketsPage.searchMarkets('trump') - await page.waitForLoadState('networkidle') - - // Verify filtered results - const filteredCount = await marketsPage.marketCards.count() - expect(filteredCount).toBeLessThan(initialCount) - - // Clear search - await marketsPage.searchInput.clear() - await page.waitForLoadState('networkidle') - - // Verify all markets shown again - const finalCount = await marketsPage.marketCards.count() - expect(finalCount).toBe(initialCount) - }) -}) -``` - -## Running Tests - -```bash -# Run the generated test -npx playwright test tests/e2e/markets/search-and-view.spec.ts - -Running 3 tests using 3 workers - - ✓ [chromium] › search-and-view.spec.ts:5:3 › user can search markets and view details (4.2s) - ✓ [chromium] › search-and-view.spec.ts:52:3 › search with no results shows empty state (1.8s) - ✓ [chromium] › search-and-view.spec.ts:67:3 › can clear search and see all markets again (2.9s) - - 3 passed (9.1s) - -Artifacts generated: -- artifacts/search-results.png -- artifacts/market-details.png -- playwright-report/index.html -``` - -## Test Report - -``` -╔══════════════════════════════════════════════════════════════╗ -║ E2E Test Results ║ -╠══════════════════════════════════════════════════════════════╣ -║ Status: PASS: ALL TESTS PASSED ║ -║ Total: 3 tests ║ -║ Passed: 3 (100%) ║ -║ Failed: 0 ║ -║ Flaky: 0 ║ -║ Duration: 9.1s ║ -╚══════════════════════════════════════════════════════════════╝ - -Artifacts: - Screenshots: 2 files - Videos: 0 files (only on failure) - Traces: 0 files (only on failure) - HTML Report: playwright-report/index.html - -View report: npx playwright show-report -``` - -PASS: E2E test suite ready for CI/CD integration! -``` - -## Test Artifacts - -When tests run, the following artifacts are captured: - -**On All Tests:** -- HTML Report with timeline and results -- JUnit XML for CI integration - -**On Failure Only:** -- Screenshot of the failing state -- Video recording of the test -- Trace file for debugging (step-by-step replay) -- Network logs -- Console logs - -## Viewing Artifacts - -```bash -# View HTML report in browser -npx playwright show-report - -# View specific trace file -npx playwright show-trace artifacts/trace-abc123.zip - -# Screenshots are saved in artifacts/ directory -open artifacts/search-results.png -``` - -## Flaky Test Detection - -If a test fails intermittently: - -``` -WARNING: FLAKY TEST DETECTED: tests/e2e/markets/trade.spec.ts - -Test passed 7/10 runs (70% pass rate) - -Common failure: -"Timeout waiting for element '[data-testid="confirm-btn"]'" - -Recommended fixes: -1. Add explicit wait: await page.waitForSelector('[data-testid="confirm-btn"]') -2. Increase timeout: { timeout: 10000 } -3. Check for race conditions in component -4. Verify element is not hidden by animation - -Quarantine recommendation: Mark as test.fixme() until fixed -``` - -## Browser Configuration - -Tests run on multiple browsers by default: -- PASS: Chromium (Desktop Chrome) -- PASS: Firefox (Desktop) -- PASS: WebKit (Desktop Safari) -- PASS: Mobile Chrome (optional) - -Configure in `playwright.config.ts` to adjust browsers. - -## CI/CD Integration - -Add to your CI pipeline: - -```yaml -# .github/workflows/e2e.yml -- name: Install Playwright - run: npx playwright install --with-deps - -- name: Run E2E tests - run: npx playwright test - -- name: Upload artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: playwright-report - path: playwright-report/ -``` - -## PMX-Specific Critical Flows - -For PMX, prioritize these E2E tests: - -**CRITICAL (Must Always Pass):** -1. User can connect wallet -2. User can browse markets -3. User can search markets (semantic search) -4. User can view market details -5. User can place trade (with test funds) -6. Market resolves correctly -7. User can withdraw funds - -**IMPORTANT:** -1. Market creation flow -2. User profile updates -3. Real-time price updates -4. Chart rendering -5. Filter and sort markets -6. Mobile responsive layout - -## Best Practices - -**DO:** -- PASS: Use Page Object Model for maintainability -- PASS: Use data-testid attributes for selectors -- PASS: Wait for API responses, not arbitrary timeouts -- PASS: Test critical user journeys end-to-end -- PASS: Run tests before merging to main -- PASS: Review artifacts when tests fail - -**DON'T:** -- FAIL: Use brittle selectors (CSS classes can change) -- FAIL: Test implementation details -- FAIL: Run tests against production -- FAIL: Ignore flaky tests -- FAIL: Skip artifact review on failures -- FAIL: Test every edge case with E2E (use unit tests) - -## Important Notes - -**CRITICAL for PMX:** -- E2E tests involving real money MUST run on testnet/staging only -- Never run trading tests against production -- Set `test.skip(process.env.NODE_ENV === 'production')` for financial tests -- Use test wallets with small test funds only - -## Integration with Other Commands - -- Use `/plan` to identify critical journeys to test -- Use `/tdd` for unit tests (faster, more granular) -- Use `/e2e` for integration and user journey tests -- Use `/code-review` to verify test quality - -## Related Agents - -This command invokes the `e2e-runner` agent provided by ECC. - -For manual installs, the source file lives at: -`agents/e2e-runner.md` - -## Quick Commands - -```bash -# Run all E2E tests -npx playwright test - -# Run specific test file -npx playwright test tests/e2e/markets/search.spec.ts - -# Run in headed mode (see browser) -npx playwright test --headed - -# Debug test -npx playwright test --debug - -# Generate test code -npx playwright codegen http://localhost:3000 - -# View report -npx playwright show-report -``` diff --git a/legacy-command-shims/commands/orchestrate.md b/legacy-command-shims/commands/orchestrate.md index ba735c69..023d9b58 100644 --- a/legacy-command-shims/commands/orchestrate.md +++ b/legacy-command-shims/commands/orchestrate.md @@ -22,114 +22,3 @@ Apply the orchestration skills instead of maintaining a second workflow spec her - Start with `dmux-workflows` for split/parallel execution. - Pull in `autonomous-agent-harness` when the user is really asking for persistent loops, governance, or operator-layer behavior. - Keep handoffs structured, but let the skills define the maintained sequencing rules. -Security Reviewer: [summary] - -### FILES CHANGED - -[List all files modified] - -### TEST RESULTS - -[Test pass/fail summary] - -### SECURITY STATUS - -[Security findings] - -### RECOMMENDATION - -[SHIP / NEEDS WORK / BLOCKED] -``` - -## Parallel Execution - -For independent checks, run agents in parallel: - -```markdown -### Parallel Phase -Run simultaneously: -- code-reviewer (quality) -- security-reviewer (security) -- architect (design) - -### Merge Results -Combine outputs into single report -``` - -For external tmux-pane workers with separate git worktrees, use `node scripts/orchestrate-worktrees.js plan.json --execute`. The built-in orchestration pattern stays in-process; the helper is for long-running or cross-harness sessions. - -When workers need to see dirty or untracked local files from the main checkout, add `seedPaths` to the plan file. ECC overlays only those selected paths into each worker worktree after `git worktree add`, which keeps the branch isolated while still exposing in-flight local scripts, plans, or docs. - -```json -{ - "sessionName": "workflow-e2e", - "seedPaths": [ - "scripts/orchestrate-worktrees.js", - "scripts/lib/tmux-worktree-orchestrator.js", - ".claude/plan/workflow-e2e-test.json" - ], - "workers": [ - { "name": "docs", "task": "Update orchestration docs." } - ] -} -``` - -To export a control-plane snapshot for a live tmux/worktree session, run: - -```bash -node scripts/orchestration-status.js .claude/plan/workflow-visual-proof.json -``` - -The snapshot includes session activity, tmux pane metadata, worker states, objectives, seeded overlays, and recent handoff summaries in JSON form. - -## Operator Command-Center Handoff - -When the workflow spans multiple sessions, worktrees, or tmux panes, append a control-plane block to the final handoff: - -```markdown -CONTROL PLANE -------------- -Sessions: -- active session ID or alias -- branch + worktree path for each active worker -- tmux pane or detached session name when applicable - -Diffs: -- git status summary -- git diff --stat for touched files -- merge/conflict risk notes - -Approvals: -- pending user approvals -- blocked steps awaiting confirmation - -Telemetry: -- last activity timestamp or idle signal -- estimated token or cost drift -- policy events raised by hooks or reviewers -``` - -This keeps planner, implementer, reviewer, and loop workers legible from the operator surface. - -## Workflow Arguments - -$ARGUMENTS: -- `feature ` - Full feature workflow -- `bugfix ` - Bug fix workflow -- `refactor ` - Refactoring workflow -- `security ` - Security review workflow -- `custom ` - Custom agent sequence - -## Custom Workflow Example - -``` -/orchestrate custom "architect,tdd-guide,code-reviewer" "Redesign caching layer" -``` - -## Tips - -1. **Start with planner** for complex features -2. **Always include code-reviewer** before merge -3. **Use security-reviewer** for auth/payment/PII -4. **Keep handoffs concise** - focus on what next agent needs -5. **Run verification** between agents if needed diff --git a/legacy-command-shims/commands/tdd.md b/legacy-command-shims/commands/tdd.md index ca7d57d3..d8f96053 100644 --- a/legacy-command-shims/commands/tdd.md +++ b/legacy-command-shims/commands/tdd.md @@ -21,211 +21,3 @@ Apply the `tdd-workflow` skill. - Stay strict on RED -> GREEN -> REFACTOR. - Keep tests first, coverage explicit, and checkpoint evidence clear. - Use the skill as the maintained TDD body instead of duplicating the playbook here. -}) -``` - -## Step 3: Run Tests - Verify FAIL - -```bash -npm test lib/liquidity.test.ts - -FAIL lib/liquidity.test.ts - ✕ should return high score for liquid market (2 ms) - Error: Not implemented - -1 test failed, 0 passed -``` - -PASS: Tests fail as expected. Ready to implement. - -## Step 4: Implement Minimal Code (GREEN) - -```typescript -// lib/liquidity.ts -export function calculateLiquidityScore(market: MarketData): number { - // Handle zero volume edge case - if (market.totalVolume === 0) { - return 0 - } - - // Calculate component scores (0-100 scale) - const volumeScore = Math.min(market.totalVolume / 1000, 100) - const spreadScore = Math.max(100 - (market.bidAskSpread * 1000), 0) - const traderScore = Math.min(market.activeTraders / 10, 100) - - // Recent activity bonus - const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60) - const recencyScore = Math.max(100 - (hoursSinceLastTrade * 10), 0) - - // Weighted average - const score = ( - volumeScore * 0.4 + - spreadScore * 0.3 + - traderScore * 0.2 + - recencyScore * 0.1 - ) - - return Math.min(Math.max(score, 0), 100) // Clamp to 0-100 -} -``` - -## Step 5: Run Tests - Verify PASS - -```bash -npm test lib/liquidity.test.ts - -PASS lib/liquidity.test.ts - ✓ should return high score for liquid market (3 ms) - ✓ should return low score for illiquid market (2 ms) - ✓ should handle edge case: zero volume (1 ms) - -3 tests passed -``` - -PASS: All tests passing! - -## Step 6: Refactor (IMPROVE) - -```typescript -// lib/liquidity.ts - Refactored with constants and better readability -const WEIGHTS = { - VOLUME: 0.4, - SPREAD: 0.3, - TRADERS: 0.2, - RECENCY: 0.1, -} as const - -const SCALE_FACTORS = { - VOLUME: 1000, - SPREAD: 1000, - TRADERS: 10, - RECENCY_PENALTY: 10, -} as const - -function clamp(value: number, min: number, max: number): number { - return Math.min(Math.max(value, min), max) -} - -export function calculateLiquidityScore(market: MarketData): number { - if (market.totalVolume === 0) return 0 - - const volumeScore = Math.min(market.totalVolume / SCALE_FACTORS.VOLUME, 100) - const spreadScore = clamp(100 - (market.bidAskSpread * SCALE_FACTORS.SPREAD), 0, 100) - const traderScore = Math.min(market.activeTraders / SCALE_FACTORS.TRADERS, 100) - - const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60) - const recencyScore = clamp(100 - (hoursSinceLastTrade * SCALE_FACTORS.RECENCY_PENALTY), 0, 100) - - const weightedScore = - volumeScore * WEIGHTS.VOLUME + - spreadScore * WEIGHTS.SPREAD + - traderScore * WEIGHTS.TRADERS + - recencyScore * WEIGHTS.RECENCY - - return clamp(weightedScore, 0, 100) -} -``` - -## Step 7: Verify Tests Still Pass - -```bash -npm test lib/liquidity.test.ts - -PASS lib/liquidity.test.ts - ✓ should return high score for liquid market (3 ms) - ✓ should return low score for illiquid market (2 ms) - ✓ should handle edge case: zero volume (1 ms) - -3 tests passed -``` - -PASS: Refactoring complete, tests still passing! - -## Step 8: Check Coverage - -```bash -npm test -- --coverage lib/liquidity.test.ts - -File | % Stmts | % Branch | % Funcs | % Lines ----------------|---------|----------|---------|-------- -liquidity.ts | 100 | 100 | 100 | 100 - -Coverage: 100% PASS: (Target: 80%) -``` - -PASS: TDD session complete! -``` - -## TDD Best Practices - -**DO:** -- PASS: Write the test FIRST, before any implementation -- PASS: Run tests and verify they FAIL before implementing -- PASS: Write minimal code to make tests pass -- PASS: Refactor only after tests are green -- PASS: Add edge cases and error scenarios -- PASS: Aim for 80%+ coverage (100% for critical code) - -**DON'T:** -- FAIL: Write implementation before tests -- FAIL: Skip running tests after each change -- FAIL: Write too much code at once -- FAIL: Ignore failing tests -- FAIL: Test implementation details (test behavior) -- FAIL: Mock everything (prefer integration tests) - -## Test Types to Include - -**Unit Tests** (Function-level): -- Happy path scenarios -- Edge cases (empty, null, max values) -- Error conditions -- Boundary values - -**Integration Tests** (Component-level): -- API endpoints -- Database operations -- External service calls -- React components with hooks - -**E2E Tests** (use `/e2e` command): -- Critical user flows -- Multi-step processes -- Full stack integration - -## Coverage Requirements - -- **80% minimum** for all code -- **100% required** for: - - Financial calculations - - Authentication logic - - Security-critical code - - Core business logic - -## Important Notes - -**MANDATORY**: Tests must be written BEFORE implementation. The TDD cycle is: - -1. **RED** - Write failing test -2. **GREEN** - Implement to pass -3. **REFACTOR** - Improve code - -Never skip the RED phase. Never write code before tests. - -## Integration with Other Commands - -- Use `/plan` first to understand what to build -- Use `/tdd` to implement with tests -- Use `/build-fix` if build errors occur -- Use `/code-review` to review implementation -- Use `/test-coverage` to verify coverage - -## Related Agents - -This command invokes the `tdd-guide` agent provided by ECC. - -The related `tdd-workflow` skill is also bundled with ECC. - -For manual installs, the source files live at: -- `agents/tdd-guide.md` -- `skills/tdd-workflow/SKILL.md`