flyee 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/bin/install.js +357 -0
- package/bridge/bridge.py +1780 -0
- package/bridge/local_tracker.py +722 -0
- package/core/agents/backend-specialist.md +266 -0
- package/core/agents/code-archaeologist.md +106 -0
- package/core/agents/database-architect.md +226 -0
- package/core/agents/debugger.md +225 -0
- package/core/agents/devops-engineer.md +323 -0
- package/core/agents/documentation-writer.md +104 -0
- package/core/agents/explorer-agent.md +73 -0
- package/core/agents/frontend-specialist.md +743 -0
- package/core/agents/game-developer.md +162 -0
- package/core/agents/mobile-developer.md +377 -0
- package/core/agents/orchestrator.md +416 -0
- package/core/agents/penetration-tester.md +188 -0
- package/core/agents/performance-optimizer.md +187 -0
- package/core/agents/product-manager.md +112 -0
- package/core/agents/product-owner.md +95 -0
- package/core/agents/project-planner.md +470 -0
- package/core/agents/qa-automation-engineer.md +103 -0
- package/core/agents/security-auditor.md +170 -0
- package/core/agents/seo-specialist.md +111 -0
- package/core/agents/stitch-designer.md +190 -0
- package/core/agents/tdd-reviewer.md +282 -0
- package/core/agents/test-engineer.md +158 -0
- package/core/scripts/auto_preview.py +148 -0
- package/core/scripts/checklist.py +243 -0
- package/core/scripts/cost_report.py +149 -0
- package/core/scripts/doc-sync-check.py +461 -0
- package/core/scripts/parse_user_stories.py +79 -0
- package/core/scripts/prepare_notion_updates.py +172 -0
- package/core/scripts/print_create_payload.py +18 -0
- package/core/scripts/session_manager.py +120 -0
- package/core/scripts/task_complete.py +127 -0
- package/core/scripts/verify_all.py +327 -0
- package/core/skills/analytics-strategy/SKILL.md +128 -0
- package/core/skills/api-patterns/SKILL.md +81 -0
- package/core/skills/api-patterns/api-style.md +42 -0
- package/core/skills/api-patterns/auth.md +24 -0
- package/core/skills/api-patterns/documentation.md +26 -0
- package/core/skills/api-patterns/graphql.md +41 -0
- package/core/skills/api-patterns/rate-limiting.md +31 -0
- package/core/skills/api-patterns/response.md +37 -0
- package/core/skills/api-patterns/rest.md +40 -0
- package/core/skills/api-patterns/scripts/api_validator.py +211 -0
- package/core/skills/api-patterns/security-testing.md +122 -0
- package/core/skills/api-patterns/trpc.md +41 -0
- package/core/skills/api-patterns/versioning.md +22 -0
- package/core/skills/app-builder/SKILL.md +75 -0
- package/core/skills/app-builder/agent-coordination.md +71 -0
- package/core/skills/app-builder/feature-building.md +53 -0
- package/core/skills/app-builder/project-detection.md +34 -0
- package/core/skills/app-builder/scaffolding.md +118 -0
- package/core/skills/app-builder/tech-stack.md +40 -0
- package/core/skills/app-builder/templates/SKILL.md +39 -0
- package/core/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/core/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/core/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/core/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/core/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/core/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/core/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/core/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/core/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/core/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/core/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/core/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/core/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/core/skills/architecture/SKILL.md +55 -0
- package/core/skills/architecture/context-discovery.md +43 -0
- package/core/skills/architecture/examples.md +94 -0
- package/core/skills/architecture/pattern-selection.md +68 -0
- package/core/skills/architecture/patterns-reference.md +50 -0
- package/core/skills/architecture/trade-off-analysis.md +77 -0
- package/core/skills/atomic-design/SKILL.md +282 -0
- package/core/skills/atomic-design/references/classification-guide.md +132 -0
- package/core/skills/atomic-design/references/quality-checklist.md +60 -0
- package/core/skills/atomic-design/references/stacks/stack-blade.md +254 -0
- package/core/skills/atomic-design/references/stacks/stack-nextjs.md +272 -0
- package/core/skills/atomic-design/references/stacks/stack-react.md +239 -0
- package/core/skills/atomic-design/references/stacks/stack-vue.md +224 -0
- package/core/skills/bash-linux/SKILL.md +199 -0
- package/core/skills/behavioral-modes/SKILL.md +242 -0
- package/core/skills/brainstorming/SKILL.md +163 -0
- package/core/skills/brainstorming/dynamic-questioning.md +373 -0
- package/core/skills/checkpointing-patterns/SKILL.md +163 -0
- package/core/skills/clean-code/SKILL.md +201 -0
- package/core/skills/code-review-checklist/SKILL.md +109 -0
- package/core/skills/code-truth-validation/SKILL.md +149 -0
- package/core/skills/component-library-discovery/SKILL.md +154 -0
- package/core/skills/content-strategy/SKILL.md +222 -0
- package/core/skills/context-budget/SKILL.md +155 -0
- package/core/skills/context-gathering-patterns/SKILL.md +278 -0
- package/core/skills/cost-tracking/SKILL.md +206 -0
- package/core/skills/database-design/SKILL.md +52 -0
- package/core/skills/database-design/database-selection.md +43 -0
- package/core/skills/database-design/indexing.md +39 -0
- package/core/skills/database-design/migrations.md +48 -0
- package/core/skills/database-design/optimization.md +36 -0
- package/core/skills/database-design/orm-selection.md +30 -0
- package/core/skills/database-design/schema-design.md +56 -0
- package/core/skills/database-design/scripts/schema_validator.py +172 -0
- package/core/skills/deployment-procedures/SKILL.md +295 -0
- package/core/skills/design-md/README.md +34 -0
- package/core/skills/design-md/SKILL.md +172 -0
- package/core/skills/design-md/examples/DESIGN.md +154 -0
- package/core/skills/design-system-enforcement/SKILL.md +339 -0
- package/core/skills/doc.md +177 -0
- package/core/skills/document-registry/SKILL.md +130 -0
- package/core/skills/documentation-publishing/SKILL.md +174 -0
- package/core/skills/documentation-templates/SKILL.md +194 -0
- package/core/skills/enhance-prompt/README.md +34 -0
- package/core/skills/enhance-prompt/SKILL.md +204 -0
- package/core/skills/enhance-prompt/references/KEYWORDS.md +114 -0
- package/core/skills/frontend-design/SKILL.md +430 -0
- package/core/skills/frontend-design/animation-guide.md +331 -0
- package/core/skills/frontend-design/color-system.md +311 -0
- package/core/skills/frontend-design/decision-trees.md +418 -0
- package/core/skills/frontend-design/motion-graphics.md +306 -0
- package/core/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/core/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/core/skills/frontend-design/typography-system.md +345 -0
- package/core/skills/frontend-design/ux-psychology.md +541 -0
- package/core/skills/frontend-design/visual-effects.md +383 -0
- package/core/skills/game-development/2d-games/SKILL.md +119 -0
- package/core/skills/game-development/3d-games/SKILL.md +135 -0
- package/core/skills/game-development/SKILL.md +167 -0
- package/core/skills/game-development/game-art/SKILL.md +185 -0
- package/core/skills/game-development/game-audio/SKILL.md +190 -0
- package/core/skills/game-development/game-design/SKILL.md +129 -0
- package/core/skills/game-development/mobile-games/SKILL.md +108 -0
- package/core/skills/game-development/multiplayer/SKILL.md +132 -0
- package/core/skills/game-development/pc-games/SKILL.md +144 -0
- package/core/skills/game-development/vr-ar/SKILL.md +123 -0
- package/core/skills/game-development/web-games/SKILL.md +150 -0
- package/core/skills/geo-fundamentals/SKILL.md +156 -0
- package/core/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/core/skills/git-workflow/SKILL.md +263 -0
- package/core/skills/history-check-patterns/SKILL.md +125 -0
- package/core/skills/i18n-localization/SKILL.md +154 -0
- package/core/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/core/skills/integration-completeness/SKILL.md +219 -0
- package/core/skills/intelligent-routing/SKILL.md +370 -0
- package/core/skills/lint-and-validate/SKILL.md +45 -0
- package/core/skills/lint-and-validate/scripts/lint_runner.py +173 -0
- package/core/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/core/skills/local-verification/SKILL.md +195 -0
- package/core/skills/mcp-builder/SKILL.md +176 -0
- package/core/skills/mobile-design/SKILL.md +394 -0
- package/core/skills/mobile-design/decision-trees.md +516 -0
- package/core/skills/mobile-design/mobile-backend.md +491 -0
- package/core/skills/mobile-design/mobile-color-system.md +420 -0
- package/core/skills/mobile-design/mobile-debugging.md +122 -0
- package/core/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/core/skills/mobile-design/mobile-navigation.md +458 -0
- package/core/skills/mobile-design/mobile-performance.md +767 -0
- package/core/skills/mobile-design/mobile-testing.md +356 -0
- package/core/skills/mobile-design/mobile-typography.md +433 -0
- package/core/skills/mobile-design/platform-android.md +666 -0
- package/core/skills/mobile-design/platform-ios.md +561 -0
- package/core/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/core/skills/mobile-design/touch-psychology.md +537 -0
- package/core/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/core/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/core/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/core/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/core/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/core/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/core/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/core/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/core/skills/nextjs-react-expert/SKILL.md +267 -0
- package/core/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/core/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/core/skills/nodejs-best-practices/SKILL.md +333 -0
- package/core/skills/notion-task-patterns/SKILL.md +2529 -0
- package/core/skills/page-specifications/SKILL.md +367 -0
- package/core/skills/parallel-agents/SKILL.md +175 -0
- package/core/skills/performance-profiling/SKILL.md +143 -0
- package/core/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/core/skills/plan-writing/SKILL.md +190 -0
- package/core/skills/powershell-windows/SKILL.md +167 -0
- package/core/skills/project-foundation/SKILL.md +117 -0
- package/core/skills/project-setup/SKILL.md +141 -0
- package/core/skills/project-tracking-patterns/SKILL.md +357 -0
- package/core/skills/project-type-discovery/SKILL.md +239 -0
- package/core/skills/python-patterns/SKILL.md +441 -0
- package/core/skills/qa-test-generation/SKILL.md +156 -0
- package/core/skills/react-components/README.md +36 -0
- package/core/skills/react-components/SKILL.md +47 -0
- package/core/skills/react-components/examples/gold-standard-card.tsx +80 -0
- package/core/skills/react-components/package-lock.json +231 -0
- package/core/skills/react-components/package.json +16 -0
- package/core/skills/react-components/resources/architecture-checklist.md +15 -0
- package/core/skills/react-components/resources/component-template.tsx +37 -0
- package/core/skills/react-components/resources/stitch-api-reference.md +14 -0
- package/core/skills/react-components/resources/style-guide.json +27 -0
- package/core/skills/react-components/scripts/fetch-stitch.sh +30 -0
- package/core/skills/react-components/scripts/validate.js +68 -0
- package/core/skills/red-team-tactics/SKILL.md +199 -0
- package/core/skills/remotion/README.md +105 -0
- package/core/skills/remotion/SKILL.md +393 -0
- package/core/skills/remotion/examples/WalkthroughComposition.tsx +78 -0
- package/core/skills/remotion/examples/screens.json +56 -0
- package/core/skills/remotion/resources/composition-checklist.md +124 -0
- package/core/skills/remotion/resources/screen-slide-template.tsx +123 -0
- package/core/skills/remotion/scripts/download-stitch-asset.sh +38 -0
- package/core/skills/seo-fundamentals/SKILL.md +129 -0
- package/core/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/core/skills/server-management/SKILL.md +161 -0
- package/core/skills/session-resilience/SKILL.md +199 -0
- package/core/skills/shadcn-ui/README.md +248 -0
- package/core/skills/shadcn-ui/SKILL.md +326 -0
- package/core/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
- package/core/skills/shadcn-ui/examples/data-table.tsx +313 -0
- package/core/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
- package/core/skills/shadcn-ui/resources/component-catalog.md +481 -0
- package/core/skills/shadcn-ui/resources/customization-guide.md +516 -0
- package/core/skills/shadcn-ui/resources/migration-guide.md +463 -0
- package/core/skills/shadcn-ui/resources/setup-guide.md +412 -0
- package/core/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
- package/core/skills/state-machine/SKILL.md +264 -0
- package/core/skills/stitch-loop/README.md +54 -0
- package/core/skills/stitch-loop/SKILL.md +203 -0
- package/core/skills/stitch-loop/examples/SITE.md +73 -0
- package/core/skills/stitch-loop/examples/next-prompt.md +25 -0
- package/core/skills/stitch-loop/resources/baton-schema.md +61 -0
- package/core/skills/stitch-loop/resources/site-template.md +104 -0
- package/core/skills/systematic-debugging/SKILL.md +109 -0
- package/core/skills/tailwind-patterns/SKILL.md +284 -0
- package/core/skills/tdd-validation/SKILL.md +243 -0
- package/core/skills/tdd-workflow/SKILL.md +284 -0
- package/core/skills/testing-patterns/SKILL.md +196 -0
- package/core/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/core/skills/ui-ux-discovery/SKILL.md +329 -0
- package/core/skills/ui-validation/SKILL.md +190 -0
- package/core/skills/ui-validation/scripts/ui_antipattern_check.py +317 -0
- package/core/skills/verification-gate/SKILL.md +205 -0
- package/core/skills/vulnerability-scanner/SKILL.md +276 -0
- package/core/skills/vulnerability-scanner/checklists.md +121 -0
- package/core/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/core/skills/web-design-guidelines/SKILL.md +57 -0
- package/core/skills/webapp-testing/SKILL.md +187 -0
- package/core/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/core/templates/ARCHITECTURE.template.md +407 -0
- package/core/templates/project-resources.example.json +71 -0
- package/core/workflows/atomic.md +182 -0
- package/core/workflows/brainstorm.md +134 -0
- package/core/workflows/check-task.md +242 -0
- package/core/workflows/copy-collect.md +306 -0
- package/core/workflows/create-agent.md +33 -0
- package/core/workflows/create-skill.md +39 -0
- package/core/workflows/create-workflow.md +33 -0
- package/core/workflows/create.md +92 -0
- package/core/workflows/debug.md +186 -0
- package/core/workflows/demand.md +443 -0
- package/core/workflows/deploy.md +260 -0
- package/core/workflows/discovery.md +267 -0
- package/core/workflows/document.md +272 -0
- package/core/workflows/ds-components.md +296 -0
- package/core/workflows/ds-init.md +58 -0
- package/core/workflows/ds-refactor.md +245 -0
- package/core/workflows/ds-references.md +197 -0
- package/core/workflows/ds-styleguide.md +237 -0
- package/core/workflows/ds-token-diff.md +103 -0
- package/core/workflows/ds-tokens.md +317 -0
- package/core/workflows/ds-validate.md +309 -0
- package/core/workflows/execute.md +483 -0
- package/core/workflows/extract-template.md +278 -0
- package/core/workflows/fix-failed-tests.md +160 -0
- package/core/workflows/init-project.md +386 -0
- package/core/workflows/legacy-project.md +849 -0
- package/core/workflows/log.md +97 -0
- package/core/workflows/new-project.md +610 -0
- package/core/workflows/new-project.md.bak +3292 -0
- package/core/workflows/new-task.md +404 -0
- package/core/workflows/orchestrate.md +237 -0
- package/core/workflows/page-build.md +296 -0
- package/core/workflows/plan.md +89 -0
- package/core/workflows/prd.md +255 -0
- package/core/workflows/preview.md +81 -0
- package/core/workflows/review-page.md +304 -0
- package/core/workflows/status.md +86 -0
- package/core/workflows/stitch.md +226 -0
- package/core/workflows/task-complete.md +473 -0
- package/core/workflows/task-update.md +163 -0
- package/core/workflows/tdd.md +344 -0
- package/core/workflows/test.md +251 -0
- package/core/workflows/ui-ux-pro-max.md +437 -0
- package/core/workflows/ux-mobile-optimize.md +262 -0
- package/core/workflows/ux-mobile-validate.md +297 -0
- package/engine-files/GEMINI.md +69 -0
- package/package.json +47 -0
- package/runtime-adapters/antigravity.js +26 -0
- package/runtime-adapters/claude.js +57 -0
- package/runtime-adapters/codex.js +51 -0
- package/runtime-adapters/copilot.js +51 -0
- package/runtime-adapters/cursor.js +51 -0
- package/runtime-adapters/gemini-cli.js +30 -0
- package/runtime-adapters/opencode.js +51 -0
- package/runtime-adapters/windsurf.js +51 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd-validation
|
|
3
|
+
description: Validação de Technical Design Documents. Verifica completude, identifica gaps e cruza com arquitetura do projeto.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TDD Validation Skill
|
|
8
|
+
|
|
9
|
+
> Valida Technical Design Documents antes da implementação.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Overview
|
|
14
|
+
|
|
15
|
+
Este skill permite validar TDDs (Technical Design Documents) para garantir que estão completos e prontos para implementação.
|
|
16
|
+
|
|
17
|
+
### Quando Usar
|
|
18
|
+
- Antes de aprovar um TDD para implementação
|
|
19
|
+
- Quando o `/tdd validate` é executado
|
|
20
|
+
- Como parte do pipeline de revisão
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. Validation Categories
|
|
25
|
+
|
|
26
|
+
### 2.1 Estrutura (Seções Obrigatórias)
|
|
27
|
+
|
|
28
|
+
| Seção | Obrigatória? | Peso |
|
|
29
|
+
|-------|--------------|------|
|
|
30
|
+
| Informações Gerais | ✅ Sim | 5% |
|
|
31
|
+
| Contexto e Motivação | ✅ Sim | 10% |
|
|
32
|
+
| Glossário | ✅ Sim | 10% |
|
|
33
|
+
| Recursos e APIs Externas | 🟡 Se aplicável | 10% |
|
|
34
|
+
| Fluxo Técnico - MVP | ✅ Sim | 20% |
|
|
35
|
+
| Detalhamento da Solução | ✅ Sim | 20% |
|
|
36
|
+
| **Environment Strategy** | ✅ Sim ⭐ | 5% |
|
|
37
|
+
| Riscos e Mitigação | ✅ Sim | 10% |
|
|
38
|
+
| Roadmap | ✅ Sim | 5% |
|
|
39
|
+
| Checklist de Validação | ✅ Sim | 5% |
|
|
40
|
+
|
|
41
|
+
### 2.2 Conteúdo (Qualidade)
|
|
42
|
+
|
|
43
|
+
| Verificação | Critério |
|
|
44
|
+
|-------------|----------|
|
|
45
|
+
| **MVP Definido** | Pelo menos 1 item marcado como `✅ DEFINIDO` |
|
|
46
|
+
| **Sem Bloqueadores** | Nenhum `⚠️ INDEFINIDO` em tasks críticas |
|
|
47
|
+
| **Fluxo Documentado** | Diagrama mermaid presente |
|
|
48
|
+
| **APIs Mapeadas** | Endpoints listados se houver integração |
|
|
49
|
+
| **Riscos Mitigados** | Cada risco tem ação de mitigação |
|
|
50
|
+
| **Ambientes Separados** ⭐ | Seção `Environment Strategy` define dev vs prod |
|
|
51
|
+
|
|
52
|
+
### 2.3 Alinhamento Arquitetural
|
|
53
|
+
|
|
54
|
+
| Verificação | Fonte |
|
|
55
|
+
|-------------|-------|
|
|
56
|
+
| **Stack Compatível** | Cruza com `CODEBASE.md` ou `package.json` |
|
|
57
|
+
| **Padrões Seguidos** | Cruza com `ARCHITECTURE.md` |
|
|
58
|
+
| **Dependências Válidas** | Bibliotecas existem e são compatíveis |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3. Validation Algorithm
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
FUNCTION validate_tdd(file_path):
|
|
66
|
+
tdd = READ(file_path)
|
|
67
|
+
score = 0
|
|
68
|
+
issues = []
|
|
69
|
+
|
|
70
|
+
# 1. Check structure
|
|
71
|
+
FOR section IN required_sections:
|
|
72
|
+
IF section NOT IN tdd:
|
|
73
|
+
issues.append(MISSING: section)
|
|
74
|
+
ELSE:
|
|
75
|
+
score += section.weight
|
|
76
|
+
|
|
77
|
+
# 2. Check MVP items
|
|
78
|
+
defined_items = COUNT(tdd, status="DEFINIDO")
|
|
79
|
+
undefined_items = COUNT(tdd, status="INDEFINIDO")
|
|
80
|
+
|
|
81
|
+
IF defined_items == 0:
|
|
82
|
+
issues.append(BLOCKER: "No MVP items defined")
|
|
83
|
+
|
|
84
|
+
IF undefined_items > 0:
|
|
85
|
+
FOR item IN undefined_items:
|
|
86
|
+
IF item.is_critical:
|
|
87
|
+
issues.append(BLOCKER: item)
|
|
88
|
+
ELSE:
|
|
89
|
+
issues.append(WARNING: item)
|
|
90
|
+
|
|
91
|
+
# 3. Check architecture alignment
|
|
92
|
+
IF EXISTS("ARCHITECTURE.md"):
|
|
93
|
+
arch = READ("ARCHITECTURE.md")
|
|
94
|
+
mismatches = COMPARE(tdd.tech_stack, arch.tech_stack)
|
|
95
|
+
issues.extend(mismatches)
|
|
96
|
+
|
|
97
|
+
# 4. Calculate readiness
|
|
98
|
+
readiness = score / max_score * 100
|
|
99
|
+
IF any(issues.type == BLOCKER):
|
|
100
|
+
status = "NOT_READY"
|
|
101
|
+
ELIF readiness >= 80:
|
|
102
|
+
status = "READY"
|
|
103
|
+
ELSE:
|
|
104
|
+
status = "NEEDS_WORK"
|
|
105
|
+
|
|
106
|
+
RETURN ValidationReport(score, issues, status)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 4. Output Format
|
|
112
|
+
|
|
113
|
+
### Validation Report Structure
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
# TDD Validation Report
|
|
117
|
+
|
|
118
|
+
**File:** docs/design/TDD-{name}.md
|
|
119
|
+
**Date:** YYYY-MM-DD
|
|
120
|
+
**Status:** [READY | NEEDS_WORK | NOT_READY]
|
|
121
|
+
**Score:** XX%
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## ✅ Passed Checks
|
|
126
|
+
|
|
127
|
+
- [x] Contexto e Motivação presente
|
|
128
|
+
- [x] Glossário definido
|
|
129
|
+
- [x] MVP com 5 itens DEFINIDO
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## ⚠️ Warnings
|
|
134
|
+
|
|
135
|
+
- [ ] Tratamento de Erros marcado como INDEFINIDO
|
|
136
|
+
- [ ] Roadmap sem datas específicas
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## ❌ Blockers
|
|
141
|
+
|
|
142
|
+
- [ ] Seção "Riscos e Mitigação" ausente
|
|
143
|
+
- [ ] Nenhum diagrama de fluxo
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📊 Summary
|
|
148
|
+
|
|
149
|
+
| Categoria | Status |
|
|
150
|
+
|-----------|--------|
|
|
151
|
+
| Estrutura | 80% |
|
|
152
|
+
| Conteúdo | 70% |
|
|
153
|
+
| Arquitetura | 100% |
|
|
154
|
+
| **Total** | **83%** |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 🎯 Recommendations
|
|
159
|
+
|
|
160
|
+
1. **P0:** Adicionar seção de Riscos
|
|
161
|
+
2. **P1:** Criar diagrama mermaid do fluxo
|
|
162
|
+
3. **P2:** Definir datas no Roadmap
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 5. Status Definitions
|
|
168
|
+
|
|
169
|
+
| Status | Significado | Ação |
|
|
170
|
+
|--------|-------------|------|
|
|
171
|
+
| `READY` | TDD completo e pronto | Pode aprovar |
|
|
172
|
+
| `NEEDS_WORK` | Pequenos ajustes necessários | Corrigir warnings |
|
|
173
|
+
| `NOT_READY` | Bloqueadores críticos | Resolver antes de prosseguir |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 6. Integration Points
|
|
178
|
+
|
|
179
|
+
### Com Outros Skills
|
|
180
|
+
| Skill | Integração |
|
|
181
|
+
|-------|------------|
|
|
182
|
+
| `brainstorming` | Validação invoca se TDD incompleto |
|
|
183
|
+
| `plan-writing` | Recebe TDD validado para breakdown |
|
|
184
|
+
| `architecture` | Cruza TDD com padrões do projeto |
|
|
185
|
+
|
|
186
|
+
### Com Agentes
|
|
187
|
+
| Agente | Papel |
|
|
188
|
+
|--------|-------|
|
|
189
|
+
| `tdd-reviewer` | Executa validação |
|
|
190
|
+
| `project-planner` | Recebe resultado para planning |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 7. Best Practices
|
|
195
|
+
|
|
196
|
+
### Para Quem Escreve TDD
|
|
197
|
+
1. **Preencha todas as seções** - Não deixe placeholders
|
|
198
|
+
2. **Seja explícito sobre MVP** - Marque status de cada item
|
|
199
|
+
3. **Documente riscos** - Mesmo os óbvios
|
|
200
|
+
4. **Use diagramas** - Mermaid para fluxos
|
|
201
|
+
|
|
202
|
+
### Para Validação
|
|
203
|
+
1. **Não auto-aprovar** - Sempre revisão humana
|
|
204
|
+
2. **Bloqueador = Stop** - Não prosseguir com blockers
|
|
205
|
+
3. **Warnings são importantes** - Resolver antes de implementar
|
|
206
|
+
4. **Re-validar após mudanças** - TDD é vivo até aprovação
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 8. Checklist Rápido
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
## Quick Validation Checklist
|
|
214
|
+
|
|
215
|
+
### Estrutura
|
|
216
|
+
- [ ] Título e metadados preenchidos
|
|
217
|
+
- [ ] Contexto explica o "porquê"
|
|
218
|
+
- [ ] Glossário define termos de domínio
|
|
219
|
+
- [ ] Fluxo técnico com diagrama
|
|
220
|
+
- [ ] Tarefas com status (DEFINIDO/INDEFINIDO)
|
|
221
|
+
- [ ] Riscos com mitigações
|
|
222
|
+
- [ ] Roadmap com datas
|
|
223
|
+
|
|
224
|
+
### MVP
|
|
225
|
+
- [ ] Pelo menos 3 itens DEFINIDO
|
|
226
|
+
- [ ] Nenhum INDEFINIDO crítico
|
|
227
|
+
- [ ] Fora de escopo marcado
|
|
228
|
+
|
|
229
|
+
### Qualidade
|
|
230
|
+
- [ ] Revisado por Tech Lead
|
|
231
|
+
- [ ] Revisado por PM
|
|
232
|
+
- [ ] Alinhado com arquitetura
|
|
233
|
+
|
|
234
|
+
### Environment Strategy ⭐
|
|
235
|
+
- [ ] Ambientes listados (dev/staging/prod)
|
|
236
|
+
- [ ] Serviços externos mapeados por ambiente
|
|
237
|
+
- [ ] Arquivos `.env` documentados
|
|
238
|
+
- [ ] `.env.local` ≠ produção
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
> **Lembre-se:** Um TDD bem validado economiza horas de retrabalho na implementação.
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd-workflow
|
|
3
|
+
description: Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TDD Workflow
|
|
8
|
+
|
|
9
|
+
> Write tests first, code second.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. The TDD Cycle
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
🔴 RED → Write failing test
|
|
17
|
+
↓
|
|
18
|
+
🟢 GREEN → Write minimal code to pass
|
|
19
|
+
↓
|
|
20
|
+
🔵 REFACTOR → Improve code quality
|
|
21
|
+
↓
|
|
22
|
+
Repeat...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. The Three Laws of TDD
|
|
28
|
+
|
|
29
|
+
1. Write production code only to make a failing test pass
|
|
30
|
+
2. Write only enough test to demonstrate failure
|
|
31
|
+
3. Write only enough code to make the test pass
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. RED Phase Principles
|
|
36
|
+
|
|
37
|
+
### What to Write
|
|
38
|
+
|
|
39
|
+
| Focus | Example |
|
|
40
|
+
|-------|---------|
|
|
41
|
+
| Behavior | "should add two numbers" |
|
|
42
|
+
| Edge cases | "should handle empty input" |
|
|
43
|
+
| Error states | "should throw for invalid data" |
|
|
44
|
+
|
|
45
|
+
### RED Phase Rules
|
|
46
|
+
|
|
47
|
+
- Test must fail first
|
|
48
|
+
- Test name describes expected behavior
|
|
49
|
+
- One assertion per test (ideally)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 4. GREEN Phase Principles
|
|
54
|
+
|
|
55
|
+
### Minimum Code
|
|
56
|
+
|
|
57
|
+
| Principle | Meaning |
|
|
58
|
+
|-----------|---------|
|
|
59
|
+
| **YAGNI** | You Aren't Gonna Need It |
|
|
60
|
+
| **Simplest thing** | Write the minimum to pass |
|
|
61
|
+
| **No optimization** | Just make it work |
|
|
62
|
+
|
|
63
|
+
### GREEN Phase Rules
|
|
64
|
+
|
|
65
|
+
- Don't write unneeded code
|
|
66
|
+
- Don't optimize yet
|
|
67
|
+
- Pass the test, nothing more
|
|
68
|
+
|
|
69
|
+
### UI Components in GREEN Phase
|
|
70
|
+
|
|
71
|
+
> For components with UI, use Design System during GREEN phase:
|
|
72
|
+
|
|
73
|
+
| Step | Action |
|
|
74
|
+
|------|--------|
|
|
75
|
+
| 1 | Load `design-system/{project}/MASTER.md` |
|
|
76
|
+
| 2 | Use CSS variables (e.g., `var(--bg-card)`) |
|
|
77
|
+
| 3 | Follow skill `design-system-enforcement` |
|
|
78
|
+
| 4 | No hardcoded colors or values |
|
|
79
|
+
| 5 | Use Lucide/Heroicons, not emojis |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## 5. REFACTOR Phase Principles
|
|
85
|
+
|
|
86
|
+
### What to Improve
|
|
87
|
+
|
|
88
|
+
| Area | Action |
|
|
89
|
+
|------|--------|
|
|
90
|
+
| Duplication | Extract common code |
|
|
91
|
+
| Naming | Make intent clear |
|
|
92
|
+
| Structure | Improve organization |
|
|
93
|
+
| Complexity | Simplify logic |
|
|
94
|
+
|
|
95
|
+
### REFACTOR Rules
|
|
96
|
+
|
|
97
|
+
- All tests must stay green
|
|
98
|
+
- Small incremental changes
|
|
99
|
+
- Commit after each refactor
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 6. AAA Pattern
|
|
104
|
+
|
|
105
|
+
Every test follows:
|
|
106
|
+
|
|
107
|
+
| Step | Purpose |
|
|
108
|
+
|------|---------|
|
|
109
|
+
| **Arrange** | Set up test data |
|
|
110
|
+
| **Act** | Execute code under test |
|
|
111
|
+
| **Assert** | Verify expected outcome |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 7. When to Use TDD
|
|
116
|
+
|
|
117
|
+
| Scenario | TDD Value |
|
|
118
|
+
|----------|-----------|
|
|
119
|
+
| New feature | High |
|
|
120
|
+
| Bug fix | High (write test first) |
|
|
121
|
+
| Complex logic | High |
|
|
122
|
+
| Exploratory | Low (spike, then TDD) |
|
|
123
|
+
| UI layout | Low |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 8. Test Prioritization
|
|
128
|
+
|
|
129
|
+
| Priority | Test Type |
|
|
130
|
+
|----------|-----------|
|
|
131
|
+
| 1 | Happy path |
|
|
132
|
+
| 2 | Error cases |
|
|
133
|
+
| 3 | Edge cases |
|
|
134
|
+
| 4 | Performance |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 9. Anti-Patterns
|
|
139
|
+
|
|
140
|
+
| ❌ Don't | ✅ Do |
|
|
141
|
+
|----------|-------|
|
|
142
|
+
| Skip the RED phase | Watch test fail first |
|
|
143
|
+
| Write tests after | Write tests before |
|
|
144
|
+
| Over-engineer initial | Keep it simple |
|
|
145
|
+
| Multiple asserts | One behavior per test |
|
|
146
|
+
| Test implementation | Test behavior |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 10. AI-Augmented TDD
|
|
151
|
+
|
|
152
|
+
### Multi-Agent Pattern
|
|
153
|
+
|
|
154
|
+
| Agent | Role |
|
|
155
|
+
|-------|------|
|
|
156
|
+
| Agent A | Write failing tests (RED) |
|
|
157
|
+
| Agent B | Implement to pass (GREEN) |
|
|
158
|
+
| Agent C | Optimize (REFACTOR) |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
> **Remember:** The test is the specification. If you can't write a test, you don't understand the requirement.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 11. Anti-Mock Validation
|
|
167
|
+
|
|
168
|
+
> [!CAUTION]
|
|
169
|
+
> Tests that validate mock data in production pages/routes are INVALID.
|
|
170
|
+
> A test passing with `const mockProject = {...}` hardcoded in the page does NOT guarantee the page works with real database data.
|
|
171
|
+
|
|
172
|
+
**Rules for valid tests:**
|
|
173
|
+
|
|
174
|
+
| Test Type | MUST Validate | NOT Valid |
|
|
175
|
+
|-----------|--------------|-----------|
|
|
176
|
+
| **Page (server component)** | DB query returns data → renders | Manually passed mock props |
|
|
177
|
+
| **API route** | Request → INSERT/UPDATE in DB → real Response | `return NextResponse.json(mockData)` |
|
|
178
|
+
| **Client component** | onClick → calls function → side effect | `onSubmit={() => {}}` as handler |
|
|
179
|
+
| **Form** | Submit → API call → user feedback | Form renders but doesn't submit |
|
|
180
|
+
|
|
181
|
+
**Anti-Mock checklist (before GREEN):**
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
⚠️ ANTI-MOCK CHECK — Task: {title}
|
|
185
|
+
|
|
186
|
+
[ ] Page/route queries REAL database (not hardcoded)?
|
|
187
|
+
[ ] API route persists data (INSERT/UPDATE), not returning mock?
|
|
188
|
+
[ ] Click/submit handlers execute REAL action, not noop?
|
|
189
|
+
[ ] Test validates END-TO-END behavior, not just rendering?
|
|
190
|
+
|
|
191
|
+
❌ Mock detected in production → Rewrite with real data
|
|
192
|
+
✅ All OK → Valid GREEN
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Grep patterns to detect mock violations:**
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Run in src/ (pages, routes, components):
|
|
199
|
+
grep -rn "mockData\|mock_data\|const mock\|// TODO\|// MVP:" src/
|
|
200
|
+
grep -rn "() => {}\|onSubmit={() =>" src/
|
|
201
|
+
grep -rn "hardcoded\|placeholder" src/
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
> **Historical Lesson:** Project created 140+ tests in ~2h. ALL passed because they tested mock props rendering,
|
|
205
|
+
> not real integration. Result: 7 pages marked as "implemented" were completely non-functional with real data.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 12. E2E Core Loop Smoke Test
|
|
210
|
+
|
|
211
|
+
> [!CAUTION]
|
|
212
|
+
> Verification is NOT just test coverage. The agent MUST verify that the product's **CORE LOOP
|
|
213
|
+
> works end-to-end** with REAL data, not just that unit tests pass.
|
|
214
|
+
|
|
215
|
+
**What is the Core Loop?**
|
|
216
|
+
|
|
217
|
+
Consult PRD section "Core Flow" or "Main Journey" to identify the product's main flow:
|
|
218
|
+
```
|
|
219
|
+
[Action 1] → [Action 2] → [Action 3] → [Final Result]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Mandatory verification for each Core Loop step:**
|
|
223
|
+
|
|
224
|
+
```markdown
|
|
225
|
+
⚠️ E2E CORE LOOP SMOKE TEST — {project name}
|
|
226
|
+
|
|
227
|
+
Core Loop from PRD: {describe flow}
|
|
228
|
+
|
|
229
|
+
| # | Step | Page/Route | Mock? | DB Query? | Functional? |
|
|
230
|
+
|---|------|-----------|-------|-----------|-------------|
|
|
231
|
+
| 1 | {action 1} | {file} | [ ] | [ ] | [ ] |
|
|
232
|
+
| 2 | {action 2} | {file} | [ ] | [ ] | [ ] |
|
|
233
|
+
| 3 | {action 3} | {file} | [ ] | [ ] | [ ] |
|
|
234
|
+
|
|
235
|
+
For EACH step:
|
|
236
|
+
[ ] No mock data in production?
|
|
237
|
+
[ ] Real DB queries (supabase.from() / prisma)?
|
|
238
|
+
[ ] Handlers connected to real actions (not noop)?
|
|
239
|
+
[ ] Previous step → current step flow works?
|
|
240
|
+
|
|
241
|
+
❌ ANY step fails → FIX before deploy
|
|
242
|
+
✅ Core Loop 100% functional → Ready for deploy
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
> [!TIP]
|
|
246
|
+
> Run the smoke test in the browser (dev server) when possible, not only via unit tests.
|
|
247
|
+
> This catches issues that isolated component tests miss.
|
|
248
|
+
|
|
249
|
+
> **Historical Lesson:** Project had 140+ passing tests and >80% coverage, but core loop
|
|
250
|
+
> (create project → create decision → portal → approve) was 100% broken because no test
|
|
251
|
+
> verified real integration.
|
|
252
|
+
|
|
253
|
+
**Decision table:**
|
|
254
|
+
|
|
255
|
+
| Verification | Action |
|
|
256
|
+
|-------------|--------|
|
|
257
|
+
| Coverage >= 80% | ✅ Proceed |
|
|
258
|
+
| Coverage < 80% | ❌ Add missing tests |
|
|
259
|
+
| **E2E Smoke Test FAILED** | ❌ **FIX — main flow is broken** |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 13. Pós-TDD: Sync com Flyee (OBRIGATÓRIO)
|
|
264
|
+
|
|
265
|
+
> [!CAUTION]
|
|
266
|
+
> **REGRA BLOQUEANTE:** Após GREEN passar, ANTES de notificar usuário, DEVE:
|
|
267
|
+
> 1. Atualizar task no Flyee (Status → "Concluído", Tempo Gasto, % Progresso → 100)
|
|
268
|
+
> 2. Adicionar nota de conclusão no corpo da task
|
|
269
|
+
> 3. Seguir skill `Flyee API` seção "Gate de Sync Flyee" (linhas 167-263)
|
|
270
|
+
|
|
271
|
+
### Checklist Pós-GREEN
|
|
272
|
+
|
|
273
|
+
| Ação | API |
|
|
274
|
+
|------|-----|
|
|
275
|
+
| Status → Concluído | `Flyee API: update_task()` |
|
|
276
|
+
| Preencher Tempo Gasto | `Flyee API: update_task()` |
|
|
277
|
+
| Nota de Conclusão | `Flyee API: update_task() (output)` |
|
|
278
|
+
|
|
279
|
+
> [!WARNING]
|
|
280
|
+
> **📜 HISTÓRICO DE FALHA (2026-02-08):**
|
|
281
|
+
> - **Gap detectado:** Agente completou TDD para Task #1 mas não syncou com Flyee
|
|
282
|
+
> - **Causa raiz:** Esta skill não referenciava `Flyee API`
|
|
283
|
+
> - **Correção aplicada:** Adicionada seção 11 com regra bloqueante
|
|
284
|
+
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing-patterns
|
|
3
|
+
description: Testing patterns and principles. Unit, integration, mocking strategies.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Testing Patterns
|
|
8
|
+
|
|
9
|
+
> Principles for reliable test suites.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Testing Pyramid
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/\ E2E (Few)
|
|
17
|
+
/ \ Critical flows
|
|
18
|
+
/----\
|
|
19
|
+
/ \ Integration (Some)
|
|
20
|
+
/--------\ API, DB queries
|
|
21
|
+
/ \
|
|
22
|
+
/------------\ Unit (Many)
|
|
23
|
+
Functions, classes
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. AAA Pattern
|
|
29
|
+
|
|
30
|
+
| Step | Purpose |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| **Arrange** | Set up test data |
|
|
33
|
+
| **Act** | Execute code under test |
|
|
34
|
+
| **Assert** | Verify outcome |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Test Type Selection
|
|
39
|
+
|
|
40
|
+
### When to Use Each
|
|
41
|
+
|
|
42
|
+
| Type | Best For | Speed |
|
|
43
|
+
|------|----------|-------|
|
|
44
|
+
| **Unit** | Pure functions, logic | Fast (<50ms) |
|
|
45
|
+
| **Integration** | API, DB, services | Medium |
|
|
46
|
+
| **E2E** | Critical user flows | Slow |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 4. Unit Test Principles
|
|
51
|
+
|
|
52
|
+
### Good Unit Tests
|
|
53
|
+
|
|
54
|
+
| Principle | Meaning |
|
|
55
|
+
|-----------|---------|
|
|
56
|
+
| Fast | < 100ms each |
|
|
57
|
+
| Isolated | No external deps |
|
|
58
|
+
| Repeatable | Same result always |
|
|
59
|
+
| Self-checking | No manual verification |
|
|
60
|
+
| Timely | Written with code |
|
|
61
|
+
|
|
62
|
+
### What to Unit Test
|
|
63
|
+
|
|
64
|
+
| Test | Don't Test |
|
|
65
|
+
|------|------------|
|
|
66
|
+
| Business logic | Framework code |
|
|
67
|
+
| Edge cases | Third-party libs |
|
|
68
|
+
| Error handling | Simple getters |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 5. Integration Test Principles
|
|
73
|
+
|
|
74
|
+
### What to Test
|
|
75
|
+
|
|
76
|
+
| Area | Focus |
|
|
77
|
+
|------|-------|
|
|
78
|
+
| API endpoints | Request/response |
|
|
79
|
+
| Database | Queries, transactions |
|
|
80
|
+
| External services | Contracts |
|
|
81
|
+
|
|
82
|
+
### Setup/Teardown
|
|
83
|
+
|
|
84
|
+
| Phase | Action |
|
|
85
|
+
|-------|--------|
|
|
86
|
+
| Before All | Connect resources |
|
|
87
|
+
| Before Each | Reset state |
|
|
88
|
+
| After Each | Clean up |
|
|
89
|
+
| After All | Disconnect |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 6. Mocking Principles
|
|
94
|
+
|
|
95
|
+
### When to Mock
|
|
96
|
+
|
|
97
|
+
| Mock | Don't Mock |
|
|
98
|
+
|------|------------|
|
|
99
|
+
| External APIs | The code under test |
|
|
100
|
+
| Database (unit) | Simple dependencies |
|
|
101
|
+
| Time/random | Pure functions |
|
|
102
|
+
| Network | In-memory stores |
|
|
103
|
+
|
|
104
|
+
### Mock Types
|
|
105
|
+
|
|
106
|
+
| Type | Use |
|
|
107
|
+
|------|-----|
|
|
108
|
+
| Stub | Return fixed values |
|
|
109
|
+
| Spy | Track calls |
|
|
110
|
+
| Mock | Set expectations |
|
|
111
|
+
| Fake | Simplified implementation |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 7. Test Organization
|
|
116
|
+
|
|
117
|
+
### Naming
|
|
118
|
+
|
|
119
|
+
| Pattern | Example |
|
|
120
|
+
|---------|---------|
|
|
121
|
+
| Should behavior | "should return error when..." |
|
|
122
|
+
| When condition | "when user not found..." |
|
|
123
|
+
| Given-when-then | "given X, when Y, then Z" |
|
|
124
|
+
|
|
125
|
+
### Grouping
|
|
126
|
+
|
|
127
|
+
| Level | Use |
|
|
128
|
+
|-------|-----|
|
|
129
|
+
| describe | Group related tests |
|
|
130
|
+
| it/test | Individual case |
|
|
131
|
+
| beforeEach | Common setup |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 8. Test Data
|
|
136
|
+
|
|
137
|
+
### Strategies
|
|
138
|
+
|
|
139
|
+
| Approach | Use |
|
|
140
|
+
|----------|-----|
|
|
141
|
+
| Factories | Generate test data |
|
|
142
|
+
| Fixtures | Predefined datasets |
|
|
143
|
+
| Builders | Fluent object creation |
|
|
144
|
+
|
|
145
|
+
### Principles
|
|
146
|
+
|
|
147
|
+
- Use realistic data
|
|
148
|
+
- Randomize non-essential values (faker)
|
|
149
|
+
- Share common fixtures
|
|
150
|
+
- Keep data minimal
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 9. Best Practices
|
|
155
|
+
|
|
156
|
+
| Practice | Why |
|
|
157
|
+
|----------|-----|
|
|
158
|
+
| One assert per test | Clear failure reason |
|
|
159
|
+
| Independent tests | No order dependency |
|
|
160
|
+
| Fast tests | Run frequently |
|
|
161
|
+
| Descriptive names | Self-documenting |
|
|
162
|
+
| Clean up | Avoid side effects |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 10. Anti-Patterns
|
|
167
|
+
|
|
168
|
+
| ❌ Don't | ✅ Do |
|
|
169
|
+
|----------|-------|
|
|
170
|
+
| Test implementation | Test behavior |
|
|
171
|
+
| Duplicate test code | Use factories |
|
|
172
|
+
| Complex test setup | Simplify or split |
|
|
173
|
+
| Ignore flaky tests | Fix root cause |
|
|
174
|
+
| Skip cleanup | Reset state |
|
|
175
|
+
| Test only existence | Test interaction too |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 11. UI Interaction Testing
|
|
180
|
+
|
|
181
|
+
> [!IMPORTANT]
|
|
182
|
+
> Para testes de componentes interativos (botões, forms), consultar skill `integration-completeness`.
|
|
183
|
+
|
|
184
|
+
Testes de existência são insuficientes:
|
|
185
|
+
|
|
186
|
+
| ❌ Incompleto | ✅ Completo |
|
|
187
|
+
|---------------|-------------|
|
|
188
|
+
| "button exists" | "clicking button calls handler" |
|
|
189
|
+
| "form renders" | "submitting form sends data" |
|
|
190
|
+
|
|
191
|
+
**Skill relacionada:** `integration-completeness`
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
> **Remember:** Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.
|
|
196
|
+
|