create-huenei-template 0.3.3 → 0.3.5
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/dist/core/skills-refresh.js +8 -3
- package/dist/templates/automation/_ci/cypress-ts/azure/azure-pipelines.yml +7 -0
- package/dist/templates/automation/_ci/cypress-ts/bitbucket/bitbucket-pipelines.yml +1 -0
- package/dist/templates/automation/_ci/cypress-ts/github/.github/workflows/e2e.yml +9 -0
- package/dist/templates/automation/_ci/cypress-ts/gitlab/.gitlab-ci.yml +2 -1
- package/dist/templates/automation/_ci/cypress-ts/jenkins/Jenkinsfile +3 -0
- package/dist/templates/automation/_ci/playwright-ts/azure/azure-pipelines.yml +7 -0
- package/dist/templates/automation/_ci/playwright-ts/github/.github/workflows/e2e.yml +10 -3
- package/dist/templates/automation/_ci/playwright-ts/jenkins/Jenkinsfile +2 -1
- package/dist/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/SKILL.md +38 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/mocking.md +59 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/tests.md +77 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/AGENTS.md +14 -7
- package/dist/templates/automation/e2e-cypress-ts-app-actions/README.md +1 -1
- package/dist/templates/automation/e2e-cypress-ts-app-actions/_skills-lock.json +6 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/cypress.config.ts +44 -1
- package/dist/templates/automation/e2e-cypress-ts-app-actions/docs/CREDENTIALS.md +1 -0
- package/dist/templates/automation/e2e-cypress-ts-app-actions/docs/HUB-INTEGRATION.md +99 -74
- package/dist/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/new-e2e-scenario.md +102 -22
- package/dist/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/new-e2e-test.md +90 -22
- package/dist/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/setup-project-context.md +1 -1
- package/dist/templates/automation/e2e-cypress-ts-app-actions/scenarios/INDEX.md +20 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/SKILL.md +38 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/mocking.md +59 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/tests.md +77 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/AGENTS.md +14 -7
- package/dist/templates/automation/e2e-cypress-ts-pom/README.md +1 -1
- package/dist/templates/automation/e2e-cypress-ts-pom/_skills-lock.json +6 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/cypress.config.ts +44 -1
- package/dist/templates/automation/e2e-cypress-ts-pom/docs/CREDENTIALS.md +1 -0
- package/dist/templates/automation/e2e-cypress-ts-pom/docs/HUB-INTEGRATION.md +99 -74
- package/dist/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/new-e2e-scenario.md +102 -22
- package/dist/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/new-e2e-test.md +90 -22
- package/dist/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/setup-project-context.md +1 -1
- package/dist/templates/automation/e2e-cypress-ts-pom/scenarios/INDEX.md +20 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/SKILL.md +38 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/mocking.md +59 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/tests.md +77 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/AGENTS.md +14 -6
- package/dist/templates/automation/e2e-playwright-ts-app-actions/README.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-app-actions/_skills-lock.json +6 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/CREDENTIALS.md +1 -0
- package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/HUB-INTEGRATION.md +99 -74
- package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/new-e2e-test.md +99 -28
- package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/setup-project-context.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-app-actions/playwright.config.ts +6 -1
- package/dist/templates/automation/e2e-playwright-ts-app-actions/scenarios/INDEX.md +20 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/SKILL.md +38 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/mocking.md +59 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/tests.md +77 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/AGENTS.md +14 -6
- package/dist/templates/automation/e2e-playwright-ts-pom/README.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-pom/_skills-lock.json +6 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/docs/CREDENTIALS.md +1 -0
- package/dist/templates/automation/e2e-playwright-ts-pom/docs/HUB-INTEGRATION.md +99 -74
- package/dist/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/dist/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/new-e2e-test.md +99 -28
- package/dist/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/setup-project-context.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-pom/playwright.config.ts +6 -1
- package/dist/templates/automation/e2e-playwright-ts-pom/scenarios/INDEX.md +20 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/SKILL.md +38 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/mocking.md +59 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/tests.md +77 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/AGENTS.md +14 -6
- package/dist/templates/automation/e2e-playwright-ts-screenplay/README.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-screenplay/_skills-lock.json +6 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/docs/CREDENTIALS.md +1 -0
- package/dist/templates/automation/e2e-playwright-ts-screenplay/docs/HUB-INTEGRATION.md +99 -74
- package/dist/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/dist/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/new-e2e-test.md +99 -28
- package/dist/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/setup-project-context.md +1 -1
- package/dist/templates/automation/e2e-playwright-ts-screenplay/playwright.config.ts +6 -1
- package/dist/templates/automation/e2e-playwright-ts-screenplay/scenarios/INDEX.md +20 -0
- package/dist/test-cli.js +59 -4
- package/package.json +1 -1
- package/templates/automation/_ci/cypress-ts/azure/azure-pipelines.yml +7 -0
- package/templates/automation/_ci/cypress-ts/bitbucket/bitbucket-pipelines.yml +1 -0
- package/templates/automation/_ci/cypress-ts/github/.github/workflows/e2e.yml +9 -0
- package/templates/automation/_ci/cypress-ts/gitlab/.gitlab-ci.yml +2 -1
- package/templates/automation/_ci/cypress-ts/jenkins/Jenkinsfile +3 -0
- package/templates/automation/_ci/playwright-ts/azure/azure-pipelines.yml +7 -0
- package/templates/automation/_ci/playwright-ts/github/.github/workflows/e2e.yml +10 -3
- package/templates/automation/_ci/playwright-ts/jenkins/Jenkinsfile +2 -1
- package/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/SKILL.md +38 -0
- package/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/mocking.md +59 -0
- package/templates/automation/e2e-cypress-ts-app-actions/.cursor/skills/tdd/tests.md +77 -0
- package/templates/automation/e2e-cypress-ts-app-actions/AGENTS.md +14 -7
- package/templates/automation/e2e-cypress-ts-app-actions/README.md +1 -1
- package/templates/automation/e2e-cypress-ts-app-actions/_skills-lock.json +6 -0
- package/templates/automation/e2e-cypress-ts-app-actions/cypress.config.ts +44 -1
- package/templates/automation/e2e-cypress-ts-app-actions/docs/CREDENTIALS.md +1 -0
- package/templates/automation/e2e-cypress-ts-app-actions/docs/HUB-INTEGRATION.md +99 -74
- package/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/new-e2e-scenario.md +102 -22
- package/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/new-e2e-test.md +90 -22
- package/templates/automation/e2e-cypress-ts-app-actions/docs/agent-commands/setup-project-context.md +1 -1
- package/templates/automation/e2e-cypress-ts-app-actions/scenarios/INDEX.md +20 -0
- package/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/SKILL.md +38 -0
- package/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/mocking.md +59 -0
- package/templates/automation/e2e-cypress-ts-pom/.cursor/skills/tdd/tests.md +77 -0
- package/templates/automation/e2e-cypress-ts-pom/AGENTS.md +14 -7
- package/templates/automation/e2e-cypress-ts-pom/README.md +1 -1
- package/templates/automation/e2e-cypress-ts-pom/_skills-lock.json +6 -0
- package/templates/automation/e2e-cypress-ts-pom/cypress.config.ts +44 -1
- package/templates/automation/e2e-cypress-ts-pom/docs/CREDENTIALS.md +1 -0
- package/templates/automation/e2e-cypress-ts-pom/docs/HUB-INTEGRATION.md +99 -74
- package/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/new-e2e-scenario.md +102 -22
- package/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/new-e2e-test.md +90 -22
- package/templates/automation/e2e-cypress-ts-pom/docs/agent-commands/setup-project-context.md +1 -1
- package/templates/automation/e2e-cypress-ts-pom/scenarios/INDEX.md +20 -0
- package/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/SKILL.md +38 -0
- package/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/mocking.md +59 -0
- package/templates/automation/e2e-playwright-ts-app-actions/.cursor/skills/tdd/tests.md +77 -0
- package/templates/automation/e2e-playwright-ts-app-actions/AGENTS.md +14 -6
- package/templates/automation/e2e-playwright-ts-app-actions/README.md +1 -1
- package/templates/automation/e2e-playwright-ts-app-actions/_skills-lock.json +6 -0
- package/templates/automation/e2e-playwright-ts-app-actions/docs/CREDENTIALS.md +1 -0
- package/templates/automation/e2e-playwright-ts-app-actions/docs/HUB-INTEGRATION.md +99 -74
- package/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/new-e2e-test.md +99 -28
- package/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/setup-project-context.md +1 -1
- package/templates/automation/e2e-playwright-ts-app-actions/playwright.config.ts +6 -1
- package/templates/automation/e2e-playwright-ts-app-actions/scenarios/INDEX.md +20 -0
- package/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/SKILL.md +38 -0
- package/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/mocking.md +59 -0
- package/templates/automation/e2e-playwright-ts-pom/.cursor/skills/tdd/tests.md +77 -0
- package/templates/automation/e2e-playwright-ts-pom/AGENTS.md +14 -6
- package/templates/automation/e2e-playwright-ts-pom/README.md +1 -1
- package/templates/automation/e2e-playwright-ts-pom/_skills-lock.json +6 -0
- package/templates/automation/e2e-playwright-ts-pom/docs/CREDENTIALS.md +1 -0
- package/templates/automation/e2e-playwright-ts-pom/docs/HUB-INTEGRATION.md +99 -74
- package/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/new-e2e-test.md +99 -28
- package/templates/automation/e2e-playwright-ts-pom/docs/agent-commands/setup-project-context.md +1 -1
- package/templates/automation/e2e-playwright-ts-pom/playwright.config.ts +6 -1
- package/templates/automation/e2e-playwright-ts-pom/scenarios/INDEX.md +20 -0
- package/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/SKILL.md +38 -0
- package/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/agents/openai.yaml +3 -0
- package/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/mocking.md +59 -0
- package/templates/automation/e2e-playwright-ts-screenplay/.cursor/skills/tdd/tests.md +77 -0
- package/templates/automation/e2e-playwright-ts-screenplay/AGENTS.md +14 -6
- package/templates/automation/e2e-playwright-ts-screenplay/README.md +1 -1
- package/templates/automation/e2e-playwright-ts-screenplay/_skills-lock.json +6 -0
- package/templates/automation/e2e-playwright-ts-screenplay/docs/CREDENTIALS.md +1 -0
- package/templates/automation/e2e-playwright-ts-screenplay/docs/HUB-INTEGRATION.md +99 -74
- package/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/new-e2e-scenario.md +101 -21
- package/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/new-e2e-test.md +99 -28
- package/templates/automation/e2e-playwright-ts-screenplay/docs/agent-commands/setup-project-context.md +1 -1
- package/templates/automation/e2e-playwright-ts-screenplay/playwright.config.ts +6 -1
- package/templates/automation/e2e-playwright-ts-screenplay/scenarios/INDEX.md +20 -0
package/dist/templates/automation/e2e-playwright-ts-app-actions/docs/agent-commands/new-e2e-test.md
CHANGED
|
@@ -1,14 +1,68 @@
|
|
|
1
1
|
# /new-e2e-test
|
|
2
2
|
|
|
3
|
-
Implementa el
|
|
3
|
+
Implementa el spec E2E de un escenario de `scenarios/`, aplicando las skills de Playwright del proyecto y el ciclo TDD de la skill `tdd` (adaptado a E2E).
|
|
4
4
|
|
|
5
5
|
Este archivo es la fuente única del comando: lo usan los comandos de Cursor, Claude Code (`.claude/commands/`), Copilot (`.github/prompts/`) y cualquier agente que lea `AGENTS.md` (Codex, ChatGPT).
|
|
6
6
|
|
|
7
7
|
**Entrada opcional**: la ruta o el id de un escenario (por ejemplo `scenarios/SC-001-login.md` o `SC-001`). Si se indica y existe, el paso 2 la usa sin preguntar.
|
|
8
8
|
|
|
9
|
+
## Modos
|
|
10
|
+
|
|
11
|
+
| Modo | Cuándo aplica | Preguntas | Escribe archivos |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| **Modo persona (IDE)** | Una persona corre el comando en su editor; la invocación no trae marcador del Hub | Entrevista con grilling (pasos 1–6) | Sí, desde el principio |
|
|
14
|
+
| **Modo Hub (interactivo)** | La invocación trae `Modo Hub (interactivo)` | Solo en bloques `hub-questions`; responde una persona desde el Hub | No: produce un plan |
|
|
15
|
+
| **Modo Hub (borrador)** | La invocación trae `Modo Hub (borrador)`, con o sin plan aprobado | Ninguna | Sí, sin ramas, commits ni PRs |
|
|
16
|
+
|
|
17
|
+
Sin marcador, el modo es **Modo persona (IDE)**. En los modos Hub, su sección prevalece sobre el resto del comando.
|
|
18
|
+
|
|
19
|
+
## Modo Hub (interactivo)
|
|
20
|
+
|
|
21
|
+
Lo invoca una sesión del Hub para planificar el test: un modelo del Hub sigue este comando y una persona responde desde un formulario. El plan aprobado lo ejecuta después un agente de código con **Modo Hub (borrador)** → **Ejecutar plan aprobado**. Contrato y ejemplos en [HUB-INTEGRATION.md](../HUB-INTEGRATION.md).
|
|
22
|
+
|
|
23
|
+
**Entorno.** No hay repo, terminal ni navegador: no correr `pnpm`, no explorar `BASE_URL`, no leer ni escribir archivos. Usar solo lo que trae la invocación (escenario, detalles de automatización, personas, app map). Los pasos 1–6 sirven como guía de qué planificar, no se ejecutan.
|
|
24
|
+
|
|
25
|
+
**Preguntas.** Solo por datos, personas, rutas o dependencias que falten y que la persona pueda resolver, todas las del turno en un único bloque `hub-questions` (formato en [HUB-INTEGRATION.md](../HUB-INTEGRATION.md)). Cada `id` estable en kebab-case, con el tema como prefijo (`datos-`, `personas-`, `rutas-`, `dependencias-`, `paso-<n>-`); `options` solo con `select`. No pedir selectores CSS ni XPath: el agente de código los confirma en la app. Credenciales: solo `type: persona` o el nombre de la variable (`TEST_<CLAVE>_EMAIL`); nunca passwords, API keys, PATs ni otros valores secretos. Nunca preguntar si se aprueba el plan: el Hub tiene el botón «Aprobar plan».
|
|
26
|
+
|
|
27
|
+
**Respuestas.** Con el bloque `hub-answers`, usar solo lo respondido. El Hub exige las requeridas; las opcionales sin respuesta no aparecen en `answers`. Con `hub-answers` en la invocación no se vuelven a emitir preguntas opcionales (`required: false`): lo que falte va a el plan como **Pregunta abierta**, sin inventar valores. Otro `hub-questions` solo con preguntas `required: true` nuevas que abra una respuesta.
|
|
28
|
+
|
|
29
|
+
**Plan.** Cuando ya no falta nada que la persona pueda responder, no emitir `hub-questions`: responder con un resumen de dos o tres líneas y el plan numerado, con:
|
|
30
|
+
|
|
31
|
+
1. Archivos a crear o modificar, agrupados en el orden de commits de [HUB-INTEGRATION.md](../HUB-INTEGRATION.md).
|
|
32
|
+
2. Abstracciones a reutilizar o crear, según [ARCHITECTURE.md](../ARCHITECTURE.md).
|
|
33
|
+
3. Locators por paso: los conocidos del app map, o «a confirmar al ejecutar» con el rol o texto visible esperado.
|
|
34
|
+
4. Casos del **Set de datos**, personas por clave y origen de cada dato.
|
|
35
|
+
5. Dependencias (datos creados por API, mocks) y su preparación.
|
|
36
|
+
6. Aserción de cada paso y del **Resultado esperado**.
|
|
37
|
+
7. Preguntas abiertas, si quedan.
|
|
38
|
+
|
|
39
|
+
En este modo no se escribe ningún archivo.
|
|
40
|
+
|
|
9
41
|
## Modo de trabajo
|
|
10
42
|
|
|
11
|
-
Modo agente, sin modo plan: este comando escribe código desde el principio. Las preguntas y los mensajes siguen las mismas reglas que `/new-e2e-scenario` (ver **Modo de trabajo** en [new-e2e-scenario.md](new-e2e-scenario.md)):
|
|
43
|
+
Esta sección y los pasos 1–6 describen el **Modo persona (IDE)**. Modo agente, sin modo plan: este comando escribe código desde el principio. Las preguntas y los mensajes siguen las mismas reglas que `/new-e2e-scenario` (ver **Modo de trabajo** en [new-e2e-scenario.md](new-e2e-scenario.md)): la mecánica de la entrevista es la skill `grilling`; usar la herramienta estructurada del entorno (`AskQuestion` / `AskUserQuestion`) con opciones, la recomendada primera y texto libre. Mensajes que empiezan con `Paso X de 6: <nombre>` y no pasan de unas 5 líneas antes de las preguntas, y bloques **Acción tuya** cuando la persona tiene que hacer algo fuera del chat.
|
|
44
|
+
|
|
45
|
+
**Escenario como fuente de verdad.** Solo `/new-e2e-scenario` reescribe pasos, textos o el resultado esperado del `.md`. Si la app difiere del escenario, anotar la diferencia en **Preguntas abiertas** del escenario y en el resumen; no editar el resto del `.md`.
|
|
46
|
+
|
|
47
|
+
## Modo Hub (borrador)
|
|
48
|
+
|
|
49
|
+
Cuando la invocación viene del Hub (pipeline o worker sin persona revisando en vivo):
|
|
50
|
+
|
|
51
|
+
- No hacer preguntas.
|
|
52
|
+
- Los huecos y las diferencias con la app van a **Preguntas abiertas** del escenario.
|
|
53
|
+
- No crear ramas, commits ni PRs: el Hub genera el borrador; tras la revisión humana, un disparador del Hub abre la rama, hace los commits y el PR (orden en [HUB-INTEGRATION.md](../HUB-INTEGRATION.md)).
|
|
54
|
+
- Terminar con un resumen de archivos agrupados según ese orden de commits, más el resultado de typecheck, lint, test y la prueba de que cada caso puede fallar.
|
|
55
|
+
|
|
56
|
+
Sin plan aprobado, este modo se mantiene por compatibilidad con la generación en borrador y queda deprecado a favor de **Modo Hub (interactivo)** + **Ejecutar plan aprobado**.
|
|
57
|
+
|
|
58
|
+
### Ejecutar plan aprobado
|
|
59
|
+
|
|
60
|
+
Aplica cuando la invocación de **Modo Hub (borrador)** trae el bloque **Plan aprobado por QA**:
|
|
61
|
+
|
|
62
|
+
- El plan es la fuente de lo que se implementa: archivos, abstracciones, casos, personas y dependencias. No volver a preguntar nada de lo que ya decidió.
|
|
63
|
+
- Seguir los pasos 1–6 con las reglas de este modo. Los locators marcados «a confirmar al ejecutar» se confirman en el paso 4, en la app.
|
|
64
|
+
- Si la app o el repo contradicen el plan, implementar lo que alcance, anotar la diferencia en **Preguntas abiertas** del escenario e informarla en el resumen.
|
|
65
|
+
- El resumen lista los archivos en el orden de commits de [HUB-INTEGRATION.md](../HUB-INTEGRATION.md) y marca cada desvío respecto del plan.
|
|
12
66
|
|
|
13
67
|
## Skills
|
|
14
68
|
|
|
@@ -17,28 +71,30 @@ Rutas relativas a `.cursor/skills/`, en orden de prioridad:
|
|
|
17
71
|
| Skill | Cómo usarla |
|
|
18
72
|
| --- | --- |
|
|
19
73
|
| `e2e-playwright/SKILL.md` | Convenciones del proyecto; prevalece sobre las demás |
|
|
20
|
-
| `playwright-best-practices/SKILL.md` |
|
|
21
|
-
| `playwright-cli/SKILL.md` | Explorar la app desde la terminal (`npx playwright cli open`, `snapshot`, `generate-locator`) si no hay Playwright MCP |
|
|
74
|
+
| `playwright-best-practices/SKILL.md` | Aplicar solo las actividades que el escenario necesita (core, assertions; waits, network, authentication, test-suite si aplica). No leer las 13 de una |
|
|
22
75
|
| `e2e-testing-patterns/SKILL.md` | Independencia de tests, selectores estables, qué no cubrir en E2E |
|
|
76
|
+
| `tdd/SKILL.md` | Paso 5: ciclo falla → pasa → puede fallar, por caso. El seam ya es la pantalla del escenario (confirmada en el paso 4); no pedir confirmación de seams. Valores esperados solo del **Set de datos** |
|
|
23
77
|
| `verification-before-completion/SKILL.md` | Paso 6: no declarar terminado sin evidencia |
|
|
24
78
|
|
|
79
|
+
Si `playwright-best-practices` y este proyecto difieren (dónde van las abstracciones, nombres, atributo de test), prevalece este proyecto. `tdd` remite a `codebase-design`; no hace falta: el seam ya está definido.
|
|
80
|
+
|
|
25
81
|
## Paso 1 de 6: Preparación
|
|
26
82
|
|
|
27
83
|
Correr `pnpm env:check`. Si falla, mostrar lo que falta en un bloque **Acción tuya**, esperar y volver a correrlo.
|
|
28
84
|
|
|
29
85
|
## Paso 2 de 6: Elegir el escenario
|
|
30
86
|
|
|
31
|
-
1.
|
|
32
|
-
2. Si se pasó un escenario como entrada y existe, informar su id y título y seguir sin preguntar. Si no se pasó o no existe, preguntar en caja cuál implementar (hasta 4 opciones por pregunta; si hay más, priorizar
|
|
87
|
+
1. Leer `scenarios/INDEX.md` (excluir `INDEX.md` y `_template.md` al mirar la carpeta). Contrastar con `tests/`: un archivo de escenario sin fila se agrega al índice; si el índice y los tags `@<id>` no coinciden, corregir el índice. Listar Id, Título, Tag y Estado del índice. Priorizar `listo`; `borrador` y `bloqueado` se muestran con el motivo de **Preguntas abiertas**.
|
|
88
|
+
2. Si se pasó un escenario como entrada y existe, informar su id y título y seguir sin preguntar. Si no se pasó o no existe, preguntar en caja cuál implementar (hasta 4 opciones por pregunta; si hay más, priorizar `listo` y dejar texto libre para el resto). En modo Hub, usar el escenario de la entrada sin preguntar.
|
|
33
89
|
3. Si no hay escenarios, proponer `/new-e2e-scenario` y terminar.
|
|
34
|
-
4. Si
|
|
35
|
-
5. Si le falta información (pasos sin elemento, entradas sin **Set de datos**, **Preguntas abiertas** que bloquean), listarla en una línea y proponer completarla con `/new-e2e-scenario` antes de seguir.
|
|
36
|
-
6. Si el escenario tiene `session`, correr `pnpm env:check <rol>`. Si falta el rol en `.env`, bloque **Acción tuya** con las dos variables a completar.
|
|
37
|
-
7. Si tiene **Set de datos** pero no existe el archivo de `data_file`, proponer generarlo con `/new-e2e-scenario`. Solo si la persona prefiere seguir, crearlo con las reglas de **Dónde se guarda** de ese comando.
|
|
90
|
+
4. Si el estado es `implementado`, preguntar si se extiende el test existente o se reemplaza (en modo Hub: extender si hay huecos; si no, no tocar el spec y anotar en **Preguntas abiertas**).
|
|
91
|
+
5. Si le falta información (pasos sin elemento, entradas sin **Set de datos**, **Preguntas abiertas** que bloquean, o estado `borrador`/`bloqueado`), listarla en una línea y proponer completarla con `/new-e2e-scenario` antes de seguir. En modo Hub: anotar en **Preguntas abiertas** y seguir solo con lo que alcance.
|
|
92
|
+
6. Si el escenario tiene `session`, correr `pnpm env:check <rol>`. Si falta el rol en `.env`, bloque **Acción tuya** con las dos variables a completar (en modo Hub: anotar en **Preguntas abiertas**).
|
|
93
|
+
7. Si tiene **Set de datos** pero no existe el archivo de `data_file`, proponer generarlo con `/new-e2e-scenario`. Solo si la persona prefiere seguir, crearlo con las reglas de **Dónde se guarda** de ese comando. En modo Hub: crearlo sin preguntar.
|
|
38
94
|
|
|
39
95
|
## Paso 3 de 6: Leer el contexto
|
|
40
96
|
|
|
41
|
-
El escenario, [AGENTS.md](../../AGENTS.md), [docs/ARCHITECTURE.md](../ARCHITECTURE.md) y estas referencias de `playwright-best-practices/`:
|
|
97
|
+
El escenario, [AGENTS.md](../../AGENTS.md), [docs/ARCHITECTURE.md](../ARCHITECTURE.md), `scenarios/INDEX.md` → **Decisiones compartidas** (aplicarlas como **Supuestos** antes de preguntar) y estas referencias de `playwright-best-practices/`:
|
|
42
98
|
|
|
43
99
|
| Situación | Leer |
|
|
44
100
|
| --- | --- |
|
|
@@ -54,25 +110,35 @@ No mostrar este paso a la persona más que con su encabezado y una línea.
|
|
|
54
110
|
|
|
55
111
|
## Paso 4 de 6: Explorar la aplicación
|
|
56
112
|
|
|
57
|
-
Abrir `BASE_URL` + `target_path`. Si `session` no es `none`, explorar con la sesión del rol según **Explorar una pantalla que requiere sesión** de `e2e-playwright/SKILL.md` (correr `pnpm auth` si falta `.auth/<rol>.json` o venció). Recorrer los pasos para confirmar textos, roles y test ids reales. Nunca escribir un locator sin haberlo visto en la app.
|
|
113
|
+
Abrir `BASE_URL` + `target_path`. Si `session` no es `none`, explorar con la sesión del rol según **Explorar una pantalla que requiere sesión** de `e2e-playwright/SKILL.md` (correr `pnpm auth` si falta `.auth/<rol>.json` o venció). Recorrer los pasos para confirmar textos, roles y test ids reales. Nunca escribir un locator sin haberlo visto en la app.
|
|
114
|
+
|
|
115
|
+
Si algo difiere del escenario, preguntarlo en caja (en modo Hub: no preguntar). Con la respuesta —o sin ella en modo Hub— **no** editar pasos ni resultado esperado del `.md`: agregar la diferencia a **Preguntas abiertas** del escenario e informar en el resumen. Seguir implementando contra el escenario escrito; si la diferencia bloquea el caso, dejar ese `test()` pendiente de resolución y documentarlo.
|
|
58
116
|
|
|
59
|
-
## Paso 5 de 6: Implementar
|
|
117
|
+
## Paso 5 de 6: Implementar (TDD por caso)
|
|
60
118
|
|
|
61
119
|
**Set de datos.**
|
|
62
120
|
|
|
63
|
-
- Importar los casos del
|
|
64
|
-
- Los usuarios
|
|
65
|
-
- Varios casos del mismo flujo: un `test()` por caso
|
|
66
|
-
- Datos **generados**: la factory de `factories/`. Datos **creados por API**:
|
|
67
|
-
- Si falta un dato, agregarlo al
|
|
121
|
+
- Importar los casos del módulo de `data_file`. No repetir sus valores dentro del spec.
|
|
122
|
+
- Los usuarios se resuelven con la clave del caso: rol y permisos de `tests/helpers/users.ts`, email y contraseña con `emailOf(<clave>)` y `passwordOf(<clave>)` de `tests/helpers/credentials.ts`, salvo que el caso traiga una contraseña inválida a propósito. No copiar emails ni contraseñas en el spec.
|
|
123
|
+
- Varios casos del mismo flujo: un `test()` por caso, recorriendo el array exportado, con el nombre del caso en el título y los mismos tags. Si es un solo caso, también sirve.
|
|
124
|
+
- Otros **secretos** (tokens, claves de API): el caso trae el nombre de la variable; leerla con `process.env[...]`. Datos **generados**: la factory de `tests/helpers/factories/`. Datos **creados por API**: con `APIRequestContext` en `beforeEach` / fixture (resetear antes, no limpiar después).
|
|
125
|
+
- Si falta un dato, agregarlo al módulo y a la tabla del escenario a la vez. No usar valores "(propuesto)" sin confirmarlos. En modo Hub: agregar el dato y dejar la confirmación en **Preguntas abiertas**.
|
|
68
126
|
|
|
69
|
-
**
|
|
127
|
+
**Ciclo TDD (skill `tdd`), un caso a la vez.**
|
|
70
128
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
129
|
+
El seam es la pantalla del escenario ya confirmada en el paso 4: no pedir confirmación de seams. Por cada caso del set (y cada caso negativo que el escenario marque como separado):
|
|
130
|
+
|
|
131
|
+
1. **Falla**: escribir el `test()` del caso (tag `@<id>` + `@smoke` \| `@regression`) y las aserciones sobre el **Resultado esperado** / **Set de datos**, *antes* de crear o completar la abstracción que falta (page object, tarea o app action). Correr `pnpm test --grep @<id>` (o el título del caso) y ver que falla por esa abstracción ausente o incompleta — no por un assert tautológico ni por un locator inventado.
|
|
132
|
+
2. **Pasa**: implementar lo mínimo que pide [docs/ARCHITECTURE.md](../ARCHITECTURE.md) (reutilizar lo existente) hasta que ese caso pase en verde.
|
|
133
|
+
3. **Puede fallar**: cambiar a propósito un valor esperado (solo del **Set de datos** o del **Resultado esperado**), volver a correr, confirmar que falla con un mensaje que nombra lo esperado vs lo recibido, y restaurar el valor. Sin esta prueba, el caso no cuenta como listo.
|
|
134
|
+
|
|
135
|
+
No avanzar al siguiente caso hasta completar los tres pasos del actual. Un locator o una espera mal resueltos se corrigen una vez, no en todos los casos.
|
|
136
|
+
|
|
137
|
+
**Reglas de implementación.**
|
|
138
|
+
|
|
139
|
+
- Si el escenario tiene `session`, el spec usa el `storageState` del proyecto; no abrir el formulario de login en el test.
|
|
140
|
+
- Preferir locators por rol, label o test id; no CSS/XPath frágiles.
|
|
141
|
+
- Esperar condiciones (`expect` auto-retry, `waitForURL`, respuestas de red); nunca `waitForTimeout`.
|
|
76
142
|
|
|
77
143
|
## Paso 6 de 6: Verificar y resumir
|
|
78
144
|
|
|
@@ -81,15 +147,20 @@ Aplicar `verification-before-completion`: correr cada comando y leer la salida c
|
|
|
81
147
|
1. `pnpm typecheck`
|
|
82
148
|
2. `pnpm lint`
|
|
83
149
|
3. `pnpm test --grep @<id>`
|
|
84
|
-
4. `pnpm test --grep @<id> --repeat-each=3
|
|
150
|
+
4. `pnpm test --grep @<id> --repeat-each=3` (detectar flakiness)
|
|
85
151
|
|
|
86
|
-
|
|
152
|
+
Ante un fallo, revisar el trace en `test-results/` antes de cambiar el test.
|
|
87
153
|
|
|
88
154
|
Con todo en verde, revisar los cambios en dos ejes, por separado:
|
|
89
155
|
|
|
90
|
-
- **Contra el escenario**: cada paso, cada **Resultado esperado** y cada fila del **Set de datos** tienen su aserción o su test; no hay nada que el escenario no pida.
|
|
156
|
+
- **Contra el escenario**: cada paso, cada **Resultado esperado** y cada fila del **Set de datos** tienen su aserción o su `test()`; cada caso pasó la prueba de que puede fallar; no hay nada que el escenario no pida; el `.md` del escenario no fue reescrito (solo **Preguntas abiertas** si hubo diferencias).
|
|
91
157
|
- **Contra las convenciones**: la tabla de la regla `e2e-architecture` (en `.cursor/rules/`) y los **Límites** de `AGENTS.md`.
|
|
92
158
|
|
|
93
159
|
Corregir lo que aparezca y volver a correr los comandos de arriba.
|
|
94
160
|
|
|
95
|
-
|
|
161
|
+
Actualizar `scenarios/INDEX.md`: con todo en verde, marcar la fila como `implementado` y completar la columna Test; si quedó bloqueado (captcha, 2FA, dato o cambio pendiente de desarrollo), marcar `bloqueado` con el motivo en Preguntas abiertas. Sumar a **Decisiones compartidas** las respuestas nuevas reutilizables.
|
|
162
|
+
|
|
163
|
+
**Resumen final**
|
|
164
|
+
|
|
165
|
+
- Modo persona (IDE): resumen corto (casos, archivos, resultado de cada comando, hallazgos de cada eje, supuestos) y, si aplica, dejar el PR listo.
|
|
166
|
+
- Modo Hub (borrador): **no** abrir PR. Listar los archivos agrupados en el orden de commits de [HUB-INTEGRATION.md](../HUB-INTEGRATION.md) (`scenario` + `data/`, roles nuevos si hubo, abstracciones, spec), el resultado de typecheck / lint / test / prueba de que puede fallar, y el contenido nuevo de **Preguntas abiertas**.
|
|
@@ -21,7 +21,7 @@ En el pipeline del Hub este comando es el **último paso**: el Hub ya generó el
|
|
|
21
21
|
|
|
22
22
|
## Modo de trabajo
|
|
23
23
|
|
|
24
|
-
Modo
|
|
24
|
+
Modo persona (IDE), con una persona en el chat (ejecución manual).
|
|
25
25
|
|
|
26
26
|
**Modo plan.** Al empezar, pasar a modo plan: en Cursor, `SwitchMode` a Plan; en Claude Code, `EnterPlanMode` (o pedirle a la persona que lo active con Shift+Tab). En modo plan solo se explora y se pregunta. Para escribir `AGENTS.md` en el paso 4, volver a modo agente. Si el entorno no tiene modo plan, seguir igual sin escribir nada hasta el paso 4.
|
|
27
27
|
|
|
@@ -13,7 +13,12 @@ export default defineConfig({
|
|
|
13
13
|
retries: process.env.CI ? 2 : 0,
|
|
14
14
|
workers: process.env.CI ? 2 : undefined,
|
|
15
15
|
reporter: process.env.CI
|
|
16
|
-
? [
|
|
16
|
+
? [
|
|
17
|
+
['list'],
|
|
18
|
+
['html', { open: 'never' }],
|
|
19
|
+
['junit', { outputFile: 'test-results/junit.xml' }],
|
|
20
|
+
['json', { outputFile: 'test-results/results.json' }],
|
|
21
|
+
]
|
|
17
22
|
: [['list'], ['html', { open: 'never' }]],
|
|
18
23
|
use: {
|
|
19
24
|
baseURL,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Índice de escenarios
|
|
2
|
+
|
|
3
|
+
Lo leen y actualizan `/new-e2e-scenario` y `/new-e2e-test` (y el agente del Hub). Antes de preguntar algo, buscarlo acá.
|
|
4
|
+
|
|
5
|
+
## Escenarios
|
|
6
|
+
|
|
7
|
+
| Id | Título | Estado | Tag | Pantalla | Rol | Test | Preguntas abiertas |
|
|
8
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
9
|
+
|
|
10
|
+
Estados: **borrador** (tiene preguntas abiertas que bloquean), **listo** (completo, sin test), **implementado** (test en verde), **bloqueado** (captcha, 2FA, dato o cambio que depende de desarrollo; el motivo va en Preguntas abiertas).
|
|
11
|
+
|
|
12
|
+
## Decisiones compartidas
|
|
13
|
+
|
|
14
|
+
Respuestas que valen para más de un escenario. Se reutilizan como Supuestos, no se repreguntan.
|
|
15
|
+
|
|
16
|
+
- Roles y cómo obtienen sesión:
|
|
17
|
+
- Creación y limpieza de datos (API, seed, existentes):
|
|
18
|
+
- Servicios externos (sandbox o simulados):
|
|
19
|
+
- Atributo de test id y convenciones de selectores:
|
|
20
|
+
- Bloqueos conocidos y cómo se evitan:
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development
|
|
7
|
+
|
|
8
|
+
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
|
|
9
|
+
|
|
10
|
+
When exploring the codebase, read `GLOSSARY.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
|
|
11
|
+
|
|
12
|
+
## What a good test is
|
|
13
|
+
|
|
14
|
+
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
|
|
15
|
+
|
|
16
|
+
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
|
17
|
+
|
|
18
|
+
## Seams: where tests go
|
|
19
|
+
|
|
20
|
+
A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
|
|
21
|
+
|
|
22
|
+
**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
|
|
23
|
+
|
|
24
|
+
Ask: "What's the public interface, and which seams should we test?" Give each proposed seam a one-line note on what it catches and what it misses.
|
|
25
|
+
|
|
26
|
+
When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
|
|
27
|
+
|
|
28
|
+
## Anti-patterns
|
|
29
|
+
|
|
30
|
+
- **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
|
|
31
|
+
- **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
|
|
32
|
+
- **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
|
|
33
|
+
|
|
34
|
+
## Rules of the loop
|
|
35
|
+
|
|
36
|
+
- **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
|
|
37
|
+
- **One slice at a time.** One seam, one test, one minimal implementation per cycle.
|
|
38
|
+
- **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# When to Mock
|
|
2
|
+
|
|
3
|
+
Mock at **system boundaries** only:
|
|
4
|
+
|
|
5
|
+
- External APIs (payment, email, etc.)
|
|
6
|
+
- Databases (sometimes - prefer test DB)
|
|
7
|
+
- Time/randomness
|
|
8
|
+
- File system (sometimes)
|
|
9
|
+
|
|
10
|
+
Don't mock:
|
|
11
|
+
|
|
12
|
+
- Your own classes/modules
|
|
13
|
+
- Internal collaborators
|
|
14
|
+
- Anything you control
|
|
15
|
+
|
|
16
|
+
## Designing for Mockability
|
|
17
|
+
|
|
18
|
+
At system boundaries, design interfaces that are easy to mock:
|
|
19
|
+
|
|
20
|
+
**1. Use dependency injection**
|
|
21
|
+
|
|
22
|
+
Pass external dependencies in rather than creating them internally:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Easy to mock
|
|
26
|
+
function processPayment(order, paymentClient) {
|
|
27
|
+
return paymentClient.charge(order.total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Hard to mock
|
|
31
|
+
function processPayment(order) {
|
|
32
|
+
const client = new StripeClient(process.env.STRIPE_KEY);
|
|
33
|
+
return client.charge(order.total);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**2. Prefer SDK-style interfaces over generic fetchers**
|
|
38
|
+
|
|
39
|
+
Create specific functions for each external operation instead of one generic function with conditional logic:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// GOOD: Each function is independently mockable
|
|
43
|
+
const api = {
|
|
44
|
+
getUser: (id) => fetch(`/users/${id}`),
|
|
45
|
+
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
|
46
|
+
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// BAD: Mocking requires conditional logic inside the mock
|
|
50
|
+
const api = {
|
|
51
|
+
fetch: (endpoint, options) => fetch(endpoint, options),
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The SDK approach means:
|
|
56
|
+
- Each mock returns one specific shape
|
|
57
|
+
- No conditional logic in test setup
|
|
58
|
+
- Easier to see which endpoints a test exercises
|
|
59
|
+
- Type safety per endpoint
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Good and Bad Tests
|
|
2
|
+
|
|
3
|
+
## Good Tests
|
|
4
|
+
|
|
5
|
+
**Integration-style**: Test through real interfaces, not mocks of internal parts.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// GOOD: Tests observable behavior
|
|
9
|
+
test("user can checkout with valid cart", async () => {
|
|
10
|
+
const cart = createCart();
|
|
11
|
+
cart.add(product);
|
|
12
|
+
const result = await checkout(cart, paymentMethod);
|
|
13
|
+
expect(result.status).toBe("confirmed");
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Characteristics:
|
|
18
|
+
|
|
19
|
+
- Tests behavior users/callers care about
|
|
20
|
+
- Uses public API only
|
|
21
|
+
- Survives internal refactors
|
|
22
|
+
- Describes WHAT, not HOW
|
|
23
|
+
- One logical assertion per test
|
|
24
|
+
|
|
25
|
+
## Bad Tests
|
|
26
|
+
|
|
27
|
+
**Implementation-detail tests**: Coupled to internal structure.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// BAD: Tests implementation details
|
|
31
|
+
test("checkout calls paymentService.process", async () => {
|
|
32
|
+
const mockPayment = jest.mock(paymentService);
|
|
33
|
+
await checkout(cart, payment);
|
|
34
|
+
expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Red flags:
|
|
39
|
+
|
|
40
|
+
- Mocking internal collaborators
|
|
41
|
+
- Testing private methods
|
|
42
|
+
- Asserting on call counts/order
|
|
43
|
+
- Test breaks when refactoring without behavior change
|
|
44
|
+
- Test name describes HOW not WHAT
|
|
45
|
+
- Verifying through external means instead of interface
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// BAD: Bypasses interface to verify
|
|
49
|
+
test("createUser saves to database", async () => {
|
|
50
|
+
await createUser({ name: "Alice" });
|
|
51
|
+
const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
|
|
52
|
+
expect(row).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// GOOD: Verifies through interface
|
|
56
|
+
test("createUser makes user retrievable", async () => {
|
|
57
|
+
const user = await createUser({ name: "Alice" });
|
|
58
|
+
const retrieved = await getUser(user.id);
|
|
59
|
+
expect(retrieved.name).toBe("Alice");
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Tautological tests**: Expected value restates the implementation, so the test passes by construction.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// BAD: Expected value is recomputed the way the code computes it
|
|
67
|
+
test("calculateTotal sums line items", () => {
|
|
68
|
+
const items = [{ price: 10 }, { price: 5 }];
|
|
69
|
+
const expected = items.reduce((sum, i) => sum + i.price, 0);
|
|
70
|
+
expect(calculateTotal(items)).toBe(expected);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// GOOD: Expected value is an independent, known literal
|
|
74
|
+
test("calculateTotal sums line items", () => {
|
|
75
|
+
expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
<!-- huenei-template:start -->
|
|
1
2
|
# AGENTS.md
|
|
2
3
|
|
|
3
4
|
Proyecto de pruebas E2E con **Playwright + TypeScript**, arquitectura **Page Object Model (POM)**.
|
|
4
5
|
|
|
5
6
|
Este archivo es el punto de entrada para cualquier agente (Cursor, Claude Code, Codex/ChatGPT, Copilot, Cursor SDK, Cloud Agents). Las reglas en `.cursor/rules/` lo complementan.
|
|
6
7
|
|
|
8
|
+
<!-- huenei-template:end -->
|
|
9
|
+
|
|
7
10
|
## Aplicación bajo prueba
|
|
8
11
|
|
|
9
12
|
Briefing canónico de la app bajo prueba. Completar con `/setup-project-context`. Los agentes lo leen antes de cualquier tarea E2E.
|
|
@@ -50,6 +53,8 @@ Briefing canónico de la app bajo prueba. Completar con `/setup-project-context`
|
|
|
50
53
|
|
|
51
54
|
Última actualización: <!-- YYYY-MM-DD -->
|
|
52
55
|
|
|
56
|
+
<!-- huenei-template:start -->
|
|
57
|
+
|
|
53
58
|
## Comandos
|
|
54
59
|
|
|
55
60
|
| Acción | Comando |
|
|
@@ -75,21 +80,21 @@ Funcionan en cualquier IDE o extensión. Si la persona escribe el comando, o pid
|
|
|
75
80
|
| Comando | Qué hace | Seguir |
|
|
76
81
|
| --- | --- | --- |
|
|
77
82
|
| `/setup-project-context` | Briefing del SUT → sección `## Aplicación bajo prueba` en `AGENTS.md` | [docs/agent-commands/setup-project-context.md](docs/agent-commands/setup-project-context.md) |
|
|
78
|
-
| `/new-e2e-scenario` |
|
|
79
|
-
| `/new-e2e-test` |
|
|
83
|
+
| `/new-e2e-scenario` | Completa un escenario a partir del borrador/contexto del Hub (o entrevista si no hay borrador) y escribe `scenarios/` + `data/<id>` | [docs/agent-commands/new-e2e-scenario.md](docs/agent-commands/new-e2e-scenario.md) |
|
|
84
|
+
| `/new-e2e-test` | Implementa el test con ciclo TDD (falla → pasa → puede fallar); no reescribe el escenario | [docs/agent-commands/new-e2e-test.md](docs/agent-commands/new-e2e-test.md) |
|
|
80
85
|
|
|
81
86
|
Antes de cualquier tarea E2E, leer la sección `## Aplicación bajo prueba` de este archivo. Si aún tiene placeholders, sugerí `/setup-project-context`.
|
|
82
87
|
|
|
83
|
-
Cursor, Claude Code (`.claude/commands/`) y Copilot (`.github/prompts/`) los ofrecen como comandos de barra; todos apuntan a esos archivos. En ejecuciones sin persona (Cloud Agents), no usarlos: anotar lo faltante en **Preguntas abiertas** del escenario y en el PR. Excepción: `/setup-project-context` invocado por el Hub con el contexto del proyecto corre en su modo pipeline, sin preguntas.
|
|
88
|
+
Cursor, Claude Code (`.claude/commands/`) y Copilot (`.github/prompts/`) los ofrecen como comandos de barra; todos apuntan a esos archivos. En ejecuciones sin persona (Cloud Agents), no usarlos: anotar lo faltante en **Preguntas abiertas** del escenario y en el PR. Excepción: `/setup-project-context` invocado por el Hub con el contexto del proyecto corre en su modo pipeline, sin preguntas. Excepciones Hub: en **Modo Hub (borrador)**, `/new-e2e-scenario` y `/new-e2e-test` corren sin persona (sin grilling ni preguntas) y los huecos van a **Preguntas abiertas**. En **Modo Hub (interactivo)**, una sesión del Hub los sigue sin repo ni terminal y solo pregunta con bloques `hub-questions`, que responde una persona desde el Hub. Cada comando documenta sus modos en `## Modos`.
|
|
84
89
|
|
|
85
90
|
## Flujo para implementar un escenario
|
|
86
91
|
|
|
87
|
-
1. **Leer el escenario
|
|
92
|
+
1. **Leer** [scenarios/INDEX.md](scenarios/INDEX.md) (estado y Decisiones compartidas) y el escenario en `scenarios/<ID>-<slug>.md` (formato en [scenarios/_template.md](scenarios/_template.md)) y su set de datos en `data_file`. Si el archivo de datos no existe, generarlo con las reglas de **Dónde se guarda** de `/new-e2e-scenario`. Si falta información imprescindible, dejarlo anotado en el PR en lugar de inventarla.
|
|
88
93
|
2. **Explorar la aplicación**: correr `pnpm env:check` para ver `BASE_URL` (la URL de la app vive en `.env`) y abrir `BASE_URL` + `target_path`. Si el escenario tiene `session`, explorar con la sesión del rol según **Explorar una pantalla que requiere sesión** de la skill `e2e-playwright`: el login lo hace `tests/auth/<rol>.setup.ts` con `pnpm auth`, y el agente nunca escribe contraseñas en el navegador. Usar el navegador disponible (Playwright MCP en el IDE, el navegador de la VM en Cloud Agents) para confirmar textos, roles y test ids reales antes de escribir locators.
|
|
89
94
|
3. **Implementar según la arquitectura** descrita en [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): reutilizar lo existente antes de crear algo nuevo.
|
|
90
95
|
4. **Escribir el test** en `tests/`, importando los casos de `data_file`, etiquetado con el id del escenario (`@SC-001`) y con `@smoke` o `@regression`.
|
|
91
|
-
5. **Correr y corregir**: `pnpm typecheck`, `pnpm lint` y el test
|
|
92
|
-
6. **Dejar
|
|
96
|
+
5. **Correr y corregir (TDD)**: por caso, aplicar la skill `tdd` (falla → pasa → puede fallar). Luego `pnpm typecheck`, `pnpm lint` y el test deben pasar. Si la app difiere del escenario, anotar en **Preguntas abiertas** — no reescribir pasos ni resultados. Ante un fallo, revisar el trace (`test-results/`).
|
|
97
|
+
6. **Dejar listo para revisión**: actualizar la fila del escenario en [scenarios/INDEX.md](scenarios/INDEX.md) (`implementado` o `bloqueado` con el motivo). En **Modo persona (IDE)**, abrir el PR con el escenario cubierto, archivos y supuestos. En **Modo Hub (borrador)** de `/new-e2e-test`, el resumen agrupa archivos en el orden de commits de [docs/HUB-INTEGRATION.md](docs/HUB-INTEGRATION.md); el disparador del Hub abre el PR.
|
|
93
98
|
|
|
94
99
|
## Skills
|
|
95
100
|
|
|
@@ -102,6 +107,7 @@ En `.cursor/skills/`. Ante cualquier diferencia, este archivo, `.cursor/rules/`
|
|
|
102
107
|
| `playwright-cli` | Explorar la app desde la terminal con `npx playwright cli`, sin MCP |
|
|
103
108
|
| `e2e-testing-patterns` | Criterios generales de E2E (qué automatizar, selectores estables, aislamiento) |
|
|
104
109
|
| `grilling` | Entrevistar a la persona sobre el dominio antes de documentar contexto |
|
|
110
|
+
| `tdd` | Ciclo falla → pasa → puede fallar al implementar cada caso E2E |
|
|
105
111
|
| `verification-before-completion` | No dar nada por terminado sin correr y leer typecheck, lint y tests |
|
|
106
112
|
|
|
107
113
|
Antes de declarar un escenario terminado, aplicar `verification-before-completion`: correr `pnpm typecheck`, `pnpm lint` y el test nuevo, y citar el resultado.
|
|
@@ -112,3 +118,5 @@ Antes de declarar un escenario terminado, aplicar `verification-before-completio
|
|
|
112
118
|
- No usar esperas fijas (`waitForTimeout`) ni `test.only`.
|
|
113
119
|
- En `playwright.config.ts`, solo cambiar `testIdAttribute` si la app usa otro atributo, salvo que el escenario requiera más. Si cambia la versión de `@playwright/test`, actualizar también la imagen Docker del CI.
|
|
114
120
|
- Los tests deben ser independientes entre sí y poder correr en paralelo.
|
|
121
|
+
|
|
122
|
+
<!-- huenei-template:end -->
|
|
@@ -58,7 +58,7 @@ Safari real no se puede automatizar: el proyecto `webkit` usa el motor WebKit. E
|
|
|
58
58
|
pages/ Page objects: locators y acciones por página
|
|
59
59
|
tests/ Specs y aserciones
|
|
60
60
|
data/ Set de datos de cada escenario (data/<id>.ts), catálogo de usuarios (users.ts) y credentials.ts
|
|
61
|
-
scenarios/ Escenarios
|
|
61
|
+
scenarios/ Escenarios + INDEX.md (estados y Decisiones compartidas; contrato con el Hub)
|
|
62
62
|
scripts/env-check.mjs Validación de .env (pnpm env:check)
|
|
63
63
|
docs/agent-commands/ /new-e2e-scenario y /new-e2e-test, para cualquier agente
|
|
64
64
|
docs/ARCHITECTURE.md El patrón POM y cuándo agregar capas
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
"sourceType": "github",
|
|
31
31
|
"skillPath": "skills/productivity/grilling/SKILL.md",
|
|
32
32
|
"computedHash": "e40cc1d348f6d935e28f1e24474302d7368f0a400429271a43b35fe154891dc5"
|
|
33
|
+
},
|
|
34
|
+
"tdd": {
|
|
35
|
+
"source": "mattpocock/skills",
|
|
36
|
+
"sourceType": "github",
|
|
37
|
+
"skillPath": "skills/engineering/tdd/SKILL.md",
|
|
38
|
+
"computedHash": "daf55026f456af104a72fa43247f7bcec89e5127316dc5b1b8d675d6a9d8ce94"
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -26,4 +26,5 @@ Definir `BASE_URL` como variable y cada `TEST_<CLAVE>_EMAIL` / `TEST_<CLAVE>_PAS
|
|
|
26
26
|
|
|
27
27
|
- Las contraseñas nunca van en el catálogo, en un set de datos ni en un test: siempre `passwordOf()`. La excepción son los casos negativos con una contraseña inválida a propósito.
|
|
28
28
|
- El agente nunca escribe valores en `.env`: los completa la persona.
|
|
29
|
+
- El agente nunca pide passwords, API keys, PATs ni otros valores secretos, tampoco en las preguntas del Hub (`hub-questions`): para una credencial pregunta la persona (`type: persona`, por clave de rol) o el nombre de la variable (`TEST_<CLAVE>_EMAIL`).
|
|
29
30
|
- En `.env` solo van `BASE_URL`, los usuarios y otros secretos (tokens, claves de API). El resto de los datos de prueba va en el set de datos de cada escenario.
|