Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

5 дні тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. ---
  2. name: 'step-03c-aggregate'
  3. description: 'Aggregate subagent outputs and complete test infrastructure'
  4. outputFile: '{test_artifacts}/automation-summary.md'
  5. nextStepFile: '{skill-root}/steps-c/step-04-validate-and-summarize.md'
  6. ---
  7. # Step 3C: Aggregate Test Generation Results
  8. ## STEP GOAL
  9. Read outputs from parallel subagents (API + E2E and/or Backend test generation based on `{detected_stack}`), aggregate results, and create supporting infrastructure (fixtures, helpers).
  10. ---
  11. ## MANDATORY EXECUTION RULES
  12. - 📖 Read the entire step file before acting
  13. - ✅ Speak in `{communication_language}`
  14. - ✅ Read subagent outputs from temp files
  15. - ✅ Generate shared fixtures based on fixture needs from both subagents
  16. - ✅ Write all generated test files to disk
  17. - ❌ Do NOT regenerate tests (use subagent outputs)
  18. - ❌ Do NOT run tests yet (that's step 4)
  19. ---
  20. ## EXECUTION PROTOCOLS:
  21. - 🎯 Follow the MANDATORY SEQUENCE exactly
  22. - 💾 Record outputs before proceeding
  23. - 📖 Load the next step only when instructed
  24. ## CONTEXT BOUNDARIES:
  25. - Available context: config, subagent outputs from temp files
  26. - Focus: aggregation and fixture generation only
  27. - Limits: do not execute future steps
  28. - Dependencies: Step 3A and 3B subagent outputs
  29. ---
  30. ## MANDATORY SEQUENCE
  31. **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
  32. ### 1. Read Subagent Outputs
  33. **Read API test subagent output (always):**
  34. ```javascript
  35. const apiTestsPath = '/tmp/tea-automate-api-tests-{{timestamp}}.json';
  36. const apiTestsOutput = JSON.parse(fs.readFileSync(apiTestsPath, 'utf8'));
  37. ```
  38. **Read E2E test subagent output (if {detected_stack} is `frontend` or `fullstack`):**
  39. ```javascript
  40. let e2eTestsOutput = null;
  41. if (detected_stack === 'frontend' || detected_stack === 'fullstack') {
  42. const e2eTestsPath = '/tmp/tea-automate-e2e-tests-{{timestamp}}.json';
  43. e2eTestsOutput = JSON.parse(fs.readFileSync(e2eTestsPath, 'utf8'));
  44. }
  45. ```
  46. **Read Backend test subagent output (if {detected_stack} is `backend` or `fullstack`):**
  47. ```javascript
  48. let backendTestsOutput = null;
  49. if (detected_stack === 'backend' || detected_stack === 'fullstack') {
  50. const backendTestsPath = '/tmp/tea-automate-backend-tests-{{timestamp}}.json';
  51. backendTestsOutput = JSON.parse(fs.readFileSync(backendTestsPath, 'utf8'));
  52. }
  53. ```
  54. **Verify all launched subagents succeeded:**
  55. - Check `apiTestsOutput.success === true`
  56. - If E2E was launched: check `e2eTestsOutput.success === true`
  57. - If Backend was launched: check `backendTestsOutput.success === true`
  58. - If any failed, report error and stop (don't proceed)
  59. ---
  60. ### 2. Write All Test Files to Disk
  61. **Write API test files:**
  62. ```javascript
  63. apiTestsOutput.tests.forEach((test) => {
  64. fs.writeFileSync(test.file, test.content, 'utf8');
  65. console.log(`✅ Created: ${test.file}`);
  66. });
  67. ```
  68. **Write E2E test files (if {detected_stack} is `frontend` or `fullstack`):**
  69. ```javascript
  70. if (e2eTestsOutput) {
  71. e2eTestsOutput.tests.forEach((test) => {
  72. fs.writeFileSync(test.file, test.content, 'utf8');
  73. console.log(`✅ Created: ${test.file}`);
  74. });
  75. }
  76. ```
  77. **Write Backend test files (if {detected_stack} is `backend` or `fullstack`):**
  78. ```javascript
  79. if (backendTestsOutput) {
  80. backendTestsOutput.testsGenerated.forEach((test) => {
  81. fs.writeFileSync(test.file, test.content, 'utf8');
  82. console.log(`✅ Created: ${test.file}`);
  83. });
  84. }
  85. ```
  86. ---
  87. ### 3. Aggregate Fixture Needs
  88. **Collect all fixture needs from all launched subagents:**
  89. ```javascript
  90. const allFixtureNeeds = [
  91. ...apiTestsOutput.fixture_needs,
  92. ...(e2eTestsOutput ? e2eTestsOutput.fixture_needs : []),
  93. ...(backendTestsOutput ? backendTestsOutput.coverageSummary?.fixtureNeeds || [] : []),
  94. ];
  95. // Remove duplicates
  96. const uniqueFixtures = [...new Set(allFixtureNeeds)];
  97. ```
  98. **Categorize fixtures:**
  99. - **Authentication fixtures:** authToken, authenticatedUserFixture, etc.
  100. - **Data factories:** userDataFactory, productDataFactory, etc.
  101. - **Network mocks:** paymentMockFixture, apiResponseMocks, etc.
  102. - **Test helpers:** wait/retry/assertion helpers
  103. ---
  104. ### 4. Generate Fixture Infrastructure
  105. **Create or update fixture files based on needs:**
  106. **A) Authentication Fixtures** (`tests/fixtures/auth.ts`):
  107. ```typescript
  108. import { test as base } from '@playwright/test';
  109. export const test = base.extend({
  110. authenticatedUser: async ({ page }, use) => {
  111. // Login logic
  112. await page.goto('/login');
  113. await page.fill('[name="email"]', 'test@example.com');
  114. await page.fill('[name="password"]', 'password');
  115. await page.click('button[type="submit"]');
  116. await page.waitForURL('/dashboard');
  117. await use(page);
  118. },
  119. authToken: async ({ request }, use) => {
  120. // Get auth token for API tests
  121. const response = await request.post('/api/auth/login', {
  122. data: { email: 'test@example.com', password: 'password' },
  123. });
  124. const { token } = await response.json();
  125. await use(token);
  126. },
  127. });
  128. ```
  129. **B) Data Factories** (`tests/fixtures/data-factories.ts`):
  130. ```typescript
  131. import { faker } from '@faker-js/faker';
  132. export const createUserData = (overrides = {}) => ({
  133. name: faker.person.fullName(),
  134. email: faker.internet.email(),
  135. ...overrides,
  136. });
  137. export const createProductData = (overrides = {}) => ({
  138. name: faker.commerce.productName(),
  139. price: faker.number.int({ min: 10, max: 1000 }),
  140. ...overrides,
  141. });
  142. ```
  143. **C) Network Mocks** (`tests/fixtures/network-mocks.ts`):
  144. ```typescript
  145. import { Page } from '@playwright/test';
  146. export const mockPaymentSuccess = async (page: Page) => {
  147. await page.route('/api/payment/**', (route) => {
  148. route.fulfill({
  149. status: 200,
  150. body: JSON.stringify({ success: true, transactionId: '12345' }),
  151. });
  152. });
  153. };
  154. ```
  155. **D) Helper Utilities** (`tests/fixtures/helpers.ts`):
  156. ```typescript
  157. import { Page } from '@playwright/test';
  158. import { interceptNetworkCall } from '@seontechnologies/playwright-utils/intercept-network-call';
  159. export const observeApiCall = (page: Page, urlPattern: string, method: string = 'GET') => {
  160. return interceptNetworkCall({
  161. page,
  162. method,
  163. url: urlPattern,
  164. });
  165. };
  166. ```
  167. ---
  168. ### 5. Calculate Summary Statistics
  169. **Aggregate test counts (based on `{detected_stack}`):**
  170. ```javascript
  171. const e2eCount = e2eTestsOutput ? e2eTestsOutput.test_count : 0;
  172. const backendCount = backendTestsOutput ? (backendTestsOutput.coverageSummary?.totalTests ?? 0) : 0;
  173. const resolvedMode = subagentContext?.execution?.resolvedMode;
  174. const subagentExecutionLabel =
  175. resolvedMode === 'sequential'
  176. ? 'SEQUENTIAL (API then dependent workers)'
  177. : resolvedMode === 'agent-team'
  178. ? 'AGENT-TEAM (parallel worker squad)'
  179. : resolvedMode === 'subagent'
  180. ? 'SUBAGENT (parallel subagents)'
  181. : `PARALLEL (based on ${detected_stack})`;
  182. const performanceGainLabel =
  183. resolvedMode === 'sequential'
  184. ? 'baseline (no parallel speedup)'
  185. : resolvedMode === 'agent-team' || resolvedMode === 'subagent'
  186. ? '~40-70% faster than sequential'
  187. : 'mode-dependent';
  188. const summary = {
  189. detected_stack: '{detected_stack}',
  190. total_tests: apiTestsOutput.test_count + e2eCount + backendCount,
  191. api_tests: apiTestsOutput.test_count,
  192. e2e_tests: e2eCount,
  193. backend_tests: backendCount,
  194. fixtures_created: uniqueFixtures.length,
  195. api_test_files: apiTestsOutput.tests.length,
  196. e2e_test_files: e2eTestsOutput ? e2eTestsOutput.tests.length : 0,
  197. backend_test_files: backendTestsOutput ? backendTestsOutput.testsGenerated.length : 0,
  198. priority_coverage: {
  199. P0:
  200. (apiTestsOutput.priority_coverage?.P0 ?? 0) +
  201. (e2eTestsOutput?.priority_coverage?.P0 ?? 0) +
  202. (backendTestsOutput?.testsGenerated?.reduce((sum, t) => sum + (t.priority_coverage?.P0 ?? 0), 0) ?? 0),
  203. P1:
  204. (apiTestsOutput.priority_coverage?.P1 ?? 0) +
  205. (e2eTestsOutput?.priority_coverage?.P1 ?? 0) +
  206. (backendTestsOutput?.testsGenerated?.reduce((sum, t) => sum + (t.priority_coverage?.P1 ?? 0), 0) ?? 0),
  207. P2:
  208. (apiTestsOutput.priority_coverage?.P2 ?? 0) +
  209. (e2eTestsOutput?.priority_coverage?.P2 ?? 0) +
  210. (backendTestsOutput?.testsGenerated?.reduce((sum, t) => sum + (t.priority_coverage?.P2 ?? 0), 0) ?? 0),
  211. P3:
  212. (apiTestsOutput.priority_coverage?.P3 ?? 0) +
  213. (e2eTestsOutput?.priority_coverage?.P3 ?? 0) +
  214. (backendTestsOutput?.testsGenerated?.reduce((sum, t) => sum + (t.priority_coverage?.P3 ?? 0), 0) ?? 0),
  215. },
  216. knowledge_fragments_used: [
  217. ...apiTestsOutput.knowledge_fragments_used,
  218. ...(e2eTestsOutput ? e2eTestsOutput.knowledge_fragments_used : []),
  219. ...(backendTestsOutput ? backendTestsOutput.knowledge_fragments_used || [] : []),
  220. ],
  221. subagent_execution: subagentExecutionLabel,
  222. performance_gain: performanceGainLabel,
  223. };
  224. ```
  225. **Store summary for Step 4:**
  226. Save summary to temp file for validation step:
  227. ```javascript
  228. fs.writeFileSync('/tmp/tea-automate-summary-{{timestamp}}.json', JSON.stringify(summary, null, 2), 'utf8');
  229. ```
  230. ---
  231. ### 6. Optional Cleanup
  232. **Clean up subagent temp files** (optional - can keep for debugging):
  233. ```javascript
  234. fs.unlinkSync(apiTestsPath);
  235. if (e2eTestsOutput) fs.unlinkSync('/tmp/tea-automate-e2e-tests-{{timestamp}}.json');
  236. if (backendTestsOutput) fs.unlinkSync('/tmp/tea-automate-backend-tests-{{timestamp}}.json');
  237. console.log('✅ Subagent temp files cleaned up');
  238. ```
  239. ---
  240. ## OUTPUT SUMMARY
  241. Display to user:
  242. ```
  243. ✅ Test Generation Complete ({subagent_execution})
  244. 📊 Summary:
  245. - Stack Type: {detected_stack}
  246. - Total Tests: {total_tests}
  247. - API Tests: {api_tests} ({api_test_files} files)
  248. - E2E Tests: {e2e_tests} ({e2e_test_files} files) [if frontend/fullstack]
  249. - Backend Tests: {backend_tests} ({backend_test_files} files) [if backend/fullstack]
  250. - Fixtures Created: {fixtures_created}
  251. - Priority Coverage:
  252. - P0 (Critical): {P0} tests
  253. - P1 (High): {P1} tests
  254. - P2 (Medium): {P2} tests
  255. - P3 (Low): {P3} tests
  256. 🚀 Performance: {performance_gain}
  257. 📂 Generated Files:
  258. - tests/api/[feature].spec.ts [always]
  259. - tests/e2e/[feature].spec.ts [if frontend/fullstack]
  260. - tests/unit/[feature].test.* [if backend/fullstack]
  261. - tests/integration/[feature].test.* [if backend/fullstack]
  262. - tests/fixtures/ or tests/support/ [shared infrastructure]
  263. ✅ Ready for validation (Step 4)
  264. ```
  265. ---
  266. ## EXIT CONDITION
  267. Proceed to Step 4 when:
  268. - ✅ All test files written to disk (API + E2E and/or Backend, based on `{detected_stack}`)
  269. - ✅ All fixtures and helpers created
  270. - ✅ Summary statistics calculated and saved
  271. - ✅ Output displayed to user
  272. ---
  273. ### 7. Save Progress
  274. **Save this step's accumulated work to `{outputFile}`.**
  275. - **If `{outputFile}` does not exist** (first save), create it with YAML frontmatter:
  276. ```yaml
  277. ---
  278. stepsCompleted: ['step-03c-aggregate']
  279. lastStep: 'step-03c-aggregate'
  280. lastSaved: '{date}'
  281. ---
  282. ```
  283. Then write this step's output below the frontmatter.
  284. - **If `{outputFile}` already exists**, update:
  285. - Add `'step-03c-aggregate'` to `stepsCompleted` array (only if not already present)
  286. - Set `lastStep: 'step-03c-aggregate'`
  287. - Set `lastSaved: '{date}'`
  288. - Append this step's output to the appropriate section.
  289. Load next step: `{nextStepFile}`
  290. ---
  291. ## 🚨 SYSTEM SUCCESS/FAILURE METRICS:
  292. ### ✅ SUCCESS:
  293. - All launched subagents succeeded (based on `{detected_stack}`)
  294. - All test files written to disk
  295. - Fixtures generated based on subagent needs
  296. - Summary complete and accurate
  297. ### ❌ SYSTEM FAILURE:
  298. - One or more subagents failed
  299. - Test files not written to disk
  300. - Fixtures missing or incomplete
  301. - Summary missing or inaccurate
  302. **Master Rule:** Do NOT proceed to Step 4 if aggregation incomplete.