Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

step-04b-subagent-e2e-failing.md 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. ---
  2. name: 'step-04b-subagent-e2e-failing'
  3. description: 'Subagent: Generate red-phase E2E test scaffolds (TDD red phase)'
  4. subagent: true
  5. outputFile: '/tmp/tea-atdd-e2e-tests-{{timestamp}}.json'
  6. ---
  7. # Subagent 4B: Generate Red-Phase E2E Test Scaffolds (TDD Red Phase)
  8. ## SUBAGENT CONTEXT
  9. This is an **isolated subagent** running in parallel with API red-phase test generation.
  10. **What you have from parent workflow:**
  11. - Story acceptance criteria from Step 1
  12. - Test strategy and user journey scenarios from Step 3
  13. - Knowledge fragments loaded: fixture-architecture, network-first, selector-resilience
  14. - Config: test framework, Playwright Utils enabled/disabled
  15. **Your task:** Generate E2E test scaffolds for the feature's expected UI behavior. They stay in `test.skip()` until the developer activates them for the current task (TDD RED PHASE).
  16. ---
  17. ## MANDATORY EXECUTION RULES
  18. - 📖 Read this entire subagent file before acting
  19. - ✅ Generate red-phase E2E test scaffolds ONLY
  20. - ✅ Tests MUST be emitted with `test.skip()` until the developer activates them
  21. - ✅ Output structured JSON to temp file
  22. - ✅ Follow knowledge fragment patterns
  23. - ❌ Do NOT generate API tests (that's subagent 4A)
  24. - ❌ Do NOT generate active passing tests (this is TDD red phase)
  25. - ❌ Do NOT run tests (that's step 5)
  26. ---
  27. ## SUBAGENT TASK
  28. ### 1. Identify User Journeys from Acceptance Criteria
  29. From the story acceptance criteria (Step 1 output), identify:
  30. - Which UI flows will be created for this story
  31. - User interactions required
  32. - Expected visual states
  33. - Success/error messages expected
  34. **Example Acceptance Criteria:**
  35. ```
  36. Story: User Registration
  37. - As a user, I can navigate to /register page
  38. - I can fill in email and password fields
  39. - I can click "Register" button
  40. - System shows success message and redirects to dashboard
  41. - System shows error if email already exists
  42. ```
  43. ### 2. Browser Interaction (Selector Verification)
  44. **Automation mode:** `config.tea_browser_automation`
  45. If `auto` (fall back to MCP if CLI unavailable; if neither available, generate from best practices):
  46. - Open the target page first, then verify selectors with a snapshot:
  47. `playwright-cli -s=tea-atdd-{{timestamp}} open <target_url>`
  48. `playwright-cli -s=tea-atdd-{{timestamp}} snapshot` → map refs to Playwright locators
  49. - ref `{role: "button", name: "Submit"}` → `page.getByRole('button', { name: 'Submit' })`
  50. - ref `{role: "textbox", name: "Email"}` → `page.getByRole('textbox', { name: 'Email' })`
  51. - `playwright-cli -s=tea-atdd-{{timestamp}} close` when done
  52. If `cli` (CLI only — do NOT fall back to MCP; generate from best practices if CLI unavailable):
  53. - Open the target page first, then verify selectors with a snapshot:
  54. `playwright-cli -s=tea-atdd-{{timestamp}} open <target_url>`
  55. `playwright-cli -s=tea-atdd-{{timestamp}} snapshot` → map refs to Playwright locators
  56. - ref `{role: "button", name: "Submit"}` → `page.getByRole('button', { name: 'Submit' })`
  57. - ref `{role: "textbox", name: "Email"}` → `page.getByRole('textbox', { name: 'Email' })`
  58. - `playwright-cli -s=tea-atdd-{{timestamp}} close` when done
  59. > **Session Hygiene:** Always close sessions using `playwright-cli -s=tea-atdd-{{timestamp}} close`. Do NOT use `close-all` — it kills every session on the machine and breaks parallel execution.
  60. If `mcp`:
  61. - Use MCP tools for selector verification (current behavior)
  62. If `none`:
  63. - Generate selectors from best practices without browser verification
  64. ### 3. Generate Red-Phase E2E Test Files
  65. For each user journey, create test file in `tests/e2e/[feature].spec.ts`:
  66. **Test Structure (ATDD - Red Phase):**
  67. ```typescript
  68. import { test, expect } from '@playwright/test';
  69. test.describe('[Story Name] E2E User Journey (ATDD)', () => {
  70. test.skip('[P0] should complete user registration successfully', async ({ page }) => {
  71. // THIS TEST WILL FAIL - UI not implemented yet
  72. await page.goto('/register');
  73. // Expect registration form but will get 404 or missing elements
  74. await page.fill('[name="email"]', 'newuser@example.com');
  75. await page.fill('[name="password"]', 'SecurePass123!');
  76. await page.click('button:has-text("Register")');
  77. // Expect success message and redirect
  78. await expect(page.getByText('Registration successful!')).toBeVisible();
  79. await page.waitForURL('/dashboard');
  80. });
  81. test.skip('[P1] should show error if email exists', async ({ page }) => {
  82. // THIS TEST WILL FAIL - UI not implemented yet
  83. await page.goto('/register');
  84. await page.fill('[name="email"]', 'existing@example.com');
  85. await page.fill('[name="password"]', 'SecurePass123!');
  86. await page.click('button:has-text("Register")');
  87. // Expect error message
  88. await expect(page.getByText('Email already exists')).toBeVisible();
  89. });
  90. });
  91. ```
  92. **CRITICAL ATDD Requirements:**
  93. - ✅ Use `test.skip()` to mark tests as red-phase scaffolds
  94. - ✅ Write assertions for EXPECTED UI behavior (even though not implemented)
  95. - ✅ Use resilient selectors: getByRole, getByText, getByLabel (from selector-resilience)
  96. - ✅ Follow network-first patterns if API calls involved (from network-first)
  97. - ✅ Test complete user journeys from acceptance criteria
  98. - ✅ Include priority tags [P0], [P1], [P2], [P3]
  99. - ✅ Use proper TypeScript types
  100. - ✅ Deterministic waits (no hard sleeps)
  101. **Why test.skip():**
  102. - Tests are written correctly for EXPECTED UI behavior
  103. - But we know they'll fail because UI isn't implemented
  104. - `test.skip()` documents this is intentional (TDD red phase)
  105. - Once UI is implemented, remove `test.skip()` to verify green phase
  106. ### 4. Track Fixture Needs
  107. Identify fixtures needed for E2E tests:
  108. - Authentication fixtures (if journey requires logged-in state)
  109. - Network mocks (if API calls involved)
  110. - Test data fixtures
  111. **Do NOT create fixtures yet** - just track what's needed for aggregation step.
  112. ---
  113. ## OUTPUT FORMAT
  114. Write JSON to temp file: `/tmp/tea-atdd-e2e-tests-{{timestamp}}.json`
  115. ```json
  116. {
  117. "success": true,
  118. "subagent": "atdd-e2e-tests",
  119. "tests": [
  120. {
  121. "file": "tests/e2e/user-registration.spec.ts",
  122. "content": "[full TypeScript test file content with test.skip()]",
  123. "description": "ATDD E2E test scaffolds for user registration journey (RED PHASE)",
  124. "expected_to_fail": true,
  125. "acceptance_criteria_covered": [
  126. "User can navigate to /register",
  127. "User can fill registration form",
  128. "System shows success message on registration",
  129. "System shows error if email exists"
  130. ],
  131. "priority_coverage": {
  132. "P0": 1,
  133. "P1": 1,
  134. "P2": 0,
  135. "P3": 0
  136. }
  137. }
  138. ],
  139. "fixture_needs": ["registrationPageMock"],
  140. "knowledge_fragments_used": ["fixture-architecture", "network-first", "selector-resilience"],
  141. "test_count": 2,
  142. "tdd_phase": "RED",
  143. "summary": "Generated 2 red-phase E2E test scaffolds for user registration story"
  144. }
  145. ```
  146. **On Error:**
  147. ```json
  148. {
  149. "success": false,
  150. "subagent": "atdd-e2e-tests",
  151. "error": "Error message describing what went wrong",
  152. "partial_output": {
  153. /* any tests generated before error */
  154. }
  155. }
  156. ```
  157. ---
  158. ## EXIT CONDITION
  159. Subagent completes when:
  160. - ✅ All user journeys from acceptance criteria have test files
  161. - ✅ All tests use `test.skip()` (documented red-phase scaffolds)
  162. - ✅ All tests assert EXPECTED UI behavior (not placeholder assertions)
  163. - ✅ Resilient selectors used (getByRole, getByText)
  164. - ✅ JSON output written to temp file
  165. - ✅ Fixture needs tracked
  166. **Subagent terminates here.** Parent workflow will read output and proceed to aggregation.
  167. ---
  168. ## 🚨 SUBAGENT SUCCESS METRICS
  169. ### ✅ SUCCESS:
  170. - All E2E tests generated with test.skip()
  171. - Tests assert expected UI behavior (not placeholders)
  172. - Resilient selectors used (getByRole, getByText)
  173. - JSON output valid and complete
  174. - No API/component/unit tests included (out of scope)
  175. - Tests follow knowledge fragment patterns
  176. ### ❌ FAILURE:
  177. - Generated active passing tests (wrong - this is RED phase)
  178. - Tests without test.skip() (will break CI)
  179. - Placeholder assertions (expect(true).toBe(true))
  180. - Brittle selectors used (CSS classes, XPath)
  181. - Did not follow knowledge fragment patterns
  182. - Invalid or missing JSON output