Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

step-03b-subagent-e2e.md 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. ---
  2. name: 'step-03b-subagent-e2e'
  3. description: 'Subagent: Generate E2E tests only'
  4. subagent: true
  5. outputFile: '/tmp/tea-automate-e2e-tests-{{timestamp}}.json'
  6. ---
  7. # Subagent 3B: Generate E2E Tests
  8. ## SUBAGENT CONTEXT
  9. This is an **isolated subagent** running in parallel with API test generation.
  10. **What you have from parent workflow:**
  11. - Target features/user journeys identified in Step 2
  12. - Knowledge fragments loaded: fixture-architecture, network-first, selector-resilience, playwright-cli
  13. - Config: test framework, Playwright Utils enabled/disabled
  14. - Coverage plan: which user journeys need E2E testing
  15. **Your task:** Generate E2E tests ONLY (not API, not fixtures, not other test types).
  16. ---
  17. ## MANDATORY EXECUTION RULES
  18. - 📖 Read this entire subagent file before acting
  19. - ✅ Generate E2E tests ONLY
  20. - ✅ Output structured JSON to temp file
  21. - ✅ Follow knowledge fragment patterns
  22. - ❌ Do NOT generate API tests (that's subagent 3A)
  23. - ❌ Do NOT run tests (that's step 4)
  24. - ❌ Do NOT generate fixtures yet (that's step 3C aggregation)
  25. ---
  26. ## SUBAGENT TASK
  27. ### 1. Identify User Journeys
  28. From the coverage plan (Step 2 output), identify:
  29. - Which user journeys need E2E coverage
  30. - Critical user paths (authentication, checkout, profile, etc.)
  31. - UI interactions required
  32. - Expected visual states
  33. ### 2. Browser Interaction (Selector Verification)
  34. **Automation mode:** `config.tea_browser_automation`
  35. If `auto` (fall back to MCP if CLI unavailable; if neither available, generate from best practices):
  36. - Open the target page first, then verify selectors with a snapshot:
  37. `playwright-cli -s=tea-automate-{{timestamp}} open <target_url>`
  38. `playwright-cli -s=tea-automate-{{timestamp}} snapshot` → map refs to Playwright locators
  39. - ref `{role: "button", name: "Submit"}` → `page.getByRole('button', { name: 'Submit' })`
  40. - ref `{role: "textbox", name: "Email"}` → `page.getByRole('textbox', { name: 'Email' })`
  41. - `playwright-cli -s=tea-automate-{{timestamp}} close` when done
  42. If `cli` (CLI only — do NOT fall back to MCP; generate from best practices if CLI unavailable):
  43. - Open the target page first, then verify selectors with a snapshot:
  44. `playwright-cli -s=tea-automate-{{timestamp}} open <target_url>`
  45. `playwright-cli -s=tea-automate-{{timestamp}} snapshot` → map refs to Playwright locators
  46. - ref `{role: "button", name: "Submit"}` → `page.getByRole('button', { name: 'Submit' })`
  47. - ref `{role: "textbox", name: "Email"}` → `page.getByRole('textbox', { name: 'Email' })`
  48. - `playwright-cli -s=tea-automate-{{timestamp}} close` when done
  49. > **Session Hygiene:** Always close sessions using `playwright-cli -s=tea-automate-{{timestamp}} close`. Do NOT use `close-all` — it kills every session on the machine and breaks parallel execution.
  50. If `mcp`:
  51. - Use MCP tools for selector verification (current behavior)
  52. If `none`:
  53. - Generate selectors from best practices without browser verification
  54. ### 3. Generate E2E Test Files
  55. For each user journey, create test file in `tests/e2e/[feature].spec.ts`:
  56. **Test Structure:**
  57. ```typescript
  58. import { test, expect } from '@playwright/test';
  59. test.describe('[Feature] E2E User Journey', () => {
  60. test('[P0] should complete [user journey]', async ({ page }) => {
  61. // Navigate to starting point
  62. await page.goto('/feature');
  63. // Interact with UI
  64. await page.getByRole('button', { name: 'Submit' }).click();
  65. // Assert expected state
  66. await expect(page.getByText('Success')).toBeVisible();
  67. });
  68. test('[P1] should handle [edge case]', async ({ page }) => {
  69. // Test edge case scenario
  70. });
  71. });
  72. ```
  73. **Requirements:**
  74. - ✅ Follow fixture architecture patterns (from fixture-architecture fragment)
  75. - ✅ Use network-first patterns: intercept before navigate (from network-first fragment)
  76. - ✅ Use resilient selectors: getByRole, getByText, getByLabel (from selector-resilience fragment)
  77. - ✅ Include priority tags [P0], [P1], [P2], [P3]
  78. - ✅ Test complete user journeys (not isolated clicks)
  79. - ✅ Use proper TypeScript types
  80. - ✅ Deterministic waits (no hard sleeps, use expect().toBeVisible())
  81. ### 4. Track Fixture Needs
  82. Identify fixtures needed for E2E tests:
  83. - Page object models (if complex)
  84. - Authentication fixtures (logged-in user state)
  85. - Network mocks/intercepts
  86. - Test data fixtures
  87. **Do NOT create fixtures yet** - just track what's needed for aggregation step.
  88. ---
  89. ## OUTPUT FORMAT
  90. Write JSON to temp file: `/tmp/tea-automate-e2e-tests-{{timestamp}}.json`
  91. ```json
  92. {
  93. "success": true,
  94. "subagent": "e2e-tests",
  95. "tests": [
  96. {
  97. "file": "tests/e2e/authentication.spec.ts",
  98. "content": "[full TypeScript test file content]",
  99. "description": "E2E tests for user authentication journey",
  100. "priority_coverage": {
  101. "P0": 2,
  102. "P1": 3,
  103. "P2": 2,
  104. "P3": 0
  105. }
  106. },
  107. {
  108. "file": "tests/e2e/checkout.spec.ts",
  109. "content": "[full TypeScript test file content]",
  110. "description": "E2E tests for checkout journey",
  111. "priority_coverage": {
  112. "P0": 3,
  113. "P1": 2,
  114. "P2": 1,
  115. "P3": 0
  116. }
  117. }
  118. ],
  119. "fixture_needs": ["authenticatedUserFixture", "paymentMockFixture", "checkoutDataFixture"],
  120. "knowledge_fragments_used": ["fixture-architecture", "network-first", "selector-resilience", "playwright-cli"],
  121. "test_count": 15,
  122. "summary": "Generated 15 E2E test cases covering 5 user journeys"
  123. }
  124. ```
  125. **On Error:**
  126. ```json
  127. {
  128. "success": false,
  129. "subagent": "e2e-tests",
  130. "error": "Error message describing what went wrong",
  131. "partial_output": {
  132. /* any tests generated before error */
  133. }
  134. }
  135. ```
  136. ---
  137. ## EXIT CONDITION
  138. Subagent completes when:
  139. - ✅ All user journeys have E2E test files generated
  140. - ✅ All tests follow knowledge fragment patterns
  141. - ✅ JSON output written to temp file
  142. - ✅ Fixture needs tracked
  143. **Subagent terminates here.** Parent workflow will read output and proceed to aggregation.
  144. ---
  145. ## 🚨 SUBAGENT SUCCESS METRICS
  146. ### ✅ SUCCESS:
  147. - All E2E tests generated following patterns
  148. - JSON output valid and complete
  149. - No API/component/unit tests included (out of scope)
  150. - Resilient selectors used (getByRole, getByText)
  151. - Network-first patterns applied (intercept before navigate)
  152. ### ❌ FAILURE:
  153. - Generated tests other than E2E tests
  154. - Did not follow knowledge fragment patterns
  155. - Invalid or missing JSON output
  156. - Ran tests (not subagent responsibility)
  157. - Used brittle selectors (CSS classes, XPath)