ADR-009-d — BDD + E2E Testing (Gherkin + Playwright)
ADR-009-d — BDD + E2E Testing (Gherkin + Playwright)
Sección titulada «ADR-009-d — BDD + E2E Testing (Gherkin + Playwright)»Draft
Context
Sección titulada «Context»No end-to-end tests exist. No user flow is validated through the full stack (browser → Angular → Django → PostgreSQL). BDD scenarios will serve as both acceptance specification and executable tests.
Decision
Sección titulada «Decision»BDD scenarios and E2E tests are unified into a single framework using playwright-bdd — a binding that connects Gherkin .feature files to Playwright step definitions.
Architecture.
e2e/├── playwright.config.ts├── features/ ← Gherkin .feature files (the spec)│ ├── auth/│ │ ├── login.feature│ │ └── logout.feature│ ├── roster/│ │ ├── employee-list.feature│ │ └── employee-detail.feature│ ├── org-chart/│ │ ├── tree-navigation.feature│ │ └── assign-worker.feature│ ├── structure/│ │ └── create-unit.feature│ └── coverage/│ └── dashboard.feature├── steps/ ← TypeScript step definitions│ ├── auth.steps.ts│ ├── roster.steps.ts│ ├── org-chart.steps.ts│ └── common.steps.ts├── fixtures/│ └── auth.fixture.ts ← Reusable login state└── support/ └── world.ts ← Shared contextPrinciples.
- Feature files are the spec. Written in Spanish (UI language), readable by non-developers. They describe what the user does, not how the DOM is structured.
- Step definitions are TypeScript. They use Playwright’s API to interact with the browser. Named in English per [[adr-001-b-language-conventions|ADR-001-b]].
- One feature per user flow. Each
.featuremaps to a complete operational workflow, not a single page. - playwright-bdd binds them. Gherkin scenarios execute as Playwright tests. No separate runner needed.
Example.
Funcionalidad: Asignar empleado a puesto vacante
Escenario: Admin asigna empleado activo a puesto sin asignación Dado que estoy autenticado como admin Y existe un puesto vacante en "Unidad Guardia" Y existe un empleado activo "García, María" Cuando navego al organigrama y selecciono "Unidad Guardia" Y hago click en "Asignar" en el puesto vacante Y selecciono "García, María" Entonces el puesto muestra "García, María" como asignada Y la cobertura de la unidad aumentaScope. Deferred until core modules (org-chart, roster, assignments) are feature-complete. Initial implementation will target 5-8 critical flows:
- Login → Dashboard visible
- Roster: search → detail view
- Org-chart: navigate tree → view unit positions
- Assign employee to vacant position
- Structure: create unit + create position
Accessibility. An axe-scan.feature will run @axe-core/playwright against the 5 main pages after each E2E suite run, per [[adr-013-accessibility|ADR-013]].
Consequences
Sección titulada «Consequences»- (+) BDD scenarios serve as both specification and executable tests — single source of truth for acceptance criteria.
- (+) Feature files in Spanish match the UI language, making them readable by clinical stakeholders.
- (+) Playwright provides reliable cross-browser testing with auto-waiting and trace capture.
- (+)
playwright-bddavoids maintaining two separate frameworks. - (-) Gherkin step definitions add an abstraction layer over Playwright’s already expressive API.
- (-) Feature files can become brittle if UI copy changes frequently.
- (-) Deferred implementation means no E2E safety net until core modules stabilize.