@avi770/testteam 1.2.0

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.
Files changed (325) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +167 -0
  4. package/agents/01-analyst.ts +100 -0
  5. package/agents/02-seed-architect.ts +59 -0
  6. package/agents/03-test-generator.ts +191 -0
  7. package/agents/04-unit-runner.ts +160 -0
  8. package/agents/05-browser-crawler.ts +790 -0
  9. package/agents/06-api-exerciser.ts +311 -0
  10. package/agents/07-security-scout.ts +188 -0
  11. package/agents/08-a11y-guardian.ts +212 -0
  12. package/agents/09-healer.ts +228 -0
  13. package/agents/10-reporter.ts +266 -0
  14. package/agents/11-fixer.ts +253 -0
  15. package/agents/12-ux-inspector.ts +444 -0
  16. package/agents/13-performance-profiler.ts +271 -0
  17. package/agents/14-data-integrity-auditor.ts +417 -0
  18. package/agents/15-regression-sentinel.ts +307 -0
  19. package/agents/16-chaos-agent.ts +228 -0
  20. package/agents/17-documentation-validator.ts +266 -0
  21. package/agents/18-integration-watchdog.ts +178 -0
  22. package/agents/19-tenant-isolation-auditor.ts +199 -0
  23. package/agents/20-workflow-completion-tester.ts +203 -0
  24. package/agents/21-state-session-tester.ts +262 -0
  25. package/agents/22-email-notification-verifier.ts +244 -0
  26. package/agents/23-migration-tester.ts +80 -0
  27. package/agents/__tests__/01-analyst.test.ts +188 -0
  28. package/agents/__tests__/02-seed-architect.test.ts +152 -0
  29. package/agents/__tests__/03-test-generator-full.test.ts +321 -0
  30. package/agents/__tests__/03-test-generator.test.ts +318 -0
  31. package/agents/__tests__/04-unit-runner.test.ts +320 -0
  32. package/agents/__tests__/05-browser-crawler-beta.test.ts +492 -0
  33. package/agents/__tests__/05-browser-crawler-release.test.ts +412 -0
  34. package/agents/__tests__/05-browser-crawler-uat.test.ts +578 -0
  35. package/agents/__tests__/05-browser-crawler.test.ts +518 -0
  36. package/agents/__tests__/06-api-exerciser.test.ts +619 -0
  37. package/agents/__tests__/07-security-scout.test.ts +382 -0
  38. package/agents/__tests__/08-a11y-guardian.test.ts +530 -0
  39. package/agents/__tests__/09-healer.test.ts +384 -0
  40. package/agents/__tests__/10-reporter.test.ts +366 -0
  41. package/agents/__tests__/11-fixer.test.ts +406 -0
  42. package/agents/__tests__/12-ux-inspector-extended.test.ts +465 -0
  43. package/agents/__tests__/12-ux-inspector.test.ts +443 -0
  44. package/agents/__tests__/13-performance-profiler.test.ts +411 -0
  45. package/agents/__tests__/14-data-integrity-auditor-extended.test.ts +573 -0
  46. package/agents/__tests__/14-data-integrity-auditor.test.ts +407 -0
  47. package/agents/__tests__/15-regression-sentinel.test.ts +657 -0
  48. package/agents/__tests__/16-chaos-agent.test.ts +427 -0
  49. package/agents/__tests__/17-documentation-validator.test.ts +402 -0
  50. package/agents/__tests__/18-integration-watchdog.test.ts +263 -0
  51. package/agents/__tests__/19-tenant-isolation-auditor.test.ts +400 -0
  52. package/agents/__tests__/20-workflow-completion-tester.test.ts +586 -0
  53. package/agents/__tests__/21-state-session-tester.test.ts +374 -0
  54. package/agents/__tests__/22-email-notification-verifier.test.ts +441 -0
  55. package/agents/__tests__/23-migration-tester.test.ts +145 -0
  56. package/agents/__tests__/base-agent.test.ts +188 -0
  57. package/agents/__tests__/registry.test.ts +218 -0
  58. package/agents/base-agent.ts +77 -0
  59. package/agents/registry.ts +136 -0
  60. package/baselines/api-schemas/.gitkeep +0 -0
  61. package/baselines/performance/.gitkeep +0 -0
  62. package/baselines/screenshots/.gitkeep +0 -0
  63. package/bin/testteam.js +10 -0
  64. package/core/__tests__/ci-output.test.ts +430 -0
  65. package/core/__tests__/cli.test.ts +387 -0
  66. package/core/__tests__/config.test.ts +78 -0
  67. package/core/__tests__/cost-tracker.test.ts +158 -0
  68. package/core/__tests__/evidence.test.ts +265 -0
  69. package/core/__tests__/fix-loop.test.ts +210 -0
  70. package/core/__tests__/health-check.test.ts +44 -0
  71. package/core/__tests__/init.test.ts +609 -0
  72. package/core/__tests__/integration.test.ts +204 -0
  73. package/core/__tests__/license-gen.test.ts +227 -0
  74. package/core/__tests__/license.test.ts +326 -0
  75. package/core/__tests__/multi-browser.test.ts +278 -0
  76. package/core/__tests__/orchestrator.test.ts +519 -0
  77. package/core/__tests__/phase-gate.test.ts +43 -0
  78. package/core/__tests__/report-html.test.ts +398 -0
  79. package/core/__tests__/report-upload.test.ts +325 -0
  80. package/core/__tests__/run-counter.test.ts +234 -0
  81. package/core/ci-output.ts +240 -0
  82. package/core/cli.ts +232 -0
  83. package/core/config.ts +178 -0
  84. package/core/cost-tracker.ts +59 -0
  85. package/core/evidence.ts +132 -0
  86. package/core/fix-loop.ts +85 -0
  87. package/core/health-check.ts +54 -0
  88. package/core/init.ts +546 -0
  89. package/core/license-gen.ts +212 -0
  90. package/core/license.ts +211 -0
  91. package/core/messages.ts +67 -0
  92. package/core/multi-browser.ts +136 -0
  93. package/core/orchestrator.ts +354 -0
  94. package/core/phase-gate.ts +55 -0
  95. package/core/report-html.ts +657 -0
  96. package/core/report-upload.ts +188 -0
  97. package/core/run-counter.ts +175 -0
  98. package/core/types.ts +57 -0
  99. package/dist/agents/01-analyst.d.ts +11 -0
  100. package/dist/agents/01-analyst.d.ts.map +1 -0
  101. package/dist/agents/01-analyst.js +75 -0
  102. package/dist/agents/01-analyst.js.map +1 -0
  103. package/dist/agents/02-seed-architect.d.ts +11 -0
  104. package/dist/agents/02-seed-architect.d.ts.map +1 -0
  105. package/dist/agents/02-seed-architect.js +51 -0
  106. package/dist/agents/02-seed-architect.js.map +1 -0
  107. package/dist/agents/03-test-generator.d.ts +9 -0
  108. package/dist/agents/03-test-generator.d.ts.map +1 -0
  109. package/dist/agents/03-test-generator.js +167 -0
  110. package/dist/agents/03-test-generator.js.map +1 -0
  111. package/dist/agents/04-unit-runner.d.ts +9 -0
  112. package/dist/agents/04-unit-runner.d.ts.map +1 -0
  113. package/dist/agents/04-unit-runner.js +113 -0
  114. package/dist/agents/04-unit-runner.js.map +1 -0
  115. package/dist/agents/05-browser-crawler.d.ts +30 -0
  116. package/dist/agents/05-browser-crawler.d.ts.map +1 -0
  117. package/dist/agents/05-browser-crawler.js +685 -0
  118. package/dist/agents/05-browser-crawler.js.map +1 -0
  119. package/dist/agents/06-api-exerciser.d.ts +23 -0
  120. package/dist/agents/06-api-exerciser.d.ts.map +1 -0
  121. package/dist/agents/06-api-exerciser.js +253 -0
  122. package/dist/agents/06-api-exerciser.js.map +1 -0
  123. package/dist/agents/07-security-scout.d.ts +11 -0
  124. package/dist/agents/07-security-scout.d.ts.map +1 -0
  125. package/dist/agents/07-security-scout.js +142 -0
  126. package/dist/agents/07-security-scout.js.map +1 -0
  127. package/dist/agents/08-a11y-guardian.d.ts +13 -0
  128. package/dist/agents/08-a11y-guardian.d.ts.map +1 -0
  129. package/dist/agents/08-a11y-guardian.js +176 -0
  130. package/dist/agents/08-a11y-guardian.js.map +1 -0
  131. package/dist/agents/09-healer.d.ts +33 -0
  132. package/dist/agents/09-healer.d.ts.map +1 -0
  133. package/dist/agents/09-healer.js +167 -0
  134. package/dist/agents/09-healer.js.map +1 -0
  135. package/dist/agents/10-reporter.d.ts +26 -0
  136. package/dist/agents/10-reporter.d.ts.map +1 -0
  137. package/dist/agents/10-reporter.js +215 -0
  138. package/dist/agents/10-reporter.js.map +1 -0
  139. package/dist/agents/11-fixer.d.ts +26 -0
  140. package/dist/agents/11-fixer.d.ts.map +1 -0
  141. package/dist/agents/11-fixer.js +195 -0
  142. package/dist/agents/11-fixer.js.map +1 -0
  143. package/dist/agents/12-ux-inspector.d.ts +15 -0
  144. package/dist/agents/12-ux-inspector.d.ts.map +1 -0
  145. package/dist/agents/12-ux-inspector.js +364 -0
  146. package/dist/agents/12-ux-inspector.js.map +1 -0
  147. package/dist/agents/13-performance-profiler.d.ts +13 -0
  148. package/dist/agents/13-performance-profiler.d.ts.map +1 -0
  149. package/dist/agents/13-performance-profiler.js +216 -0
  150. package/dist/agents/13-performance-profiler.js.map +1 -0
  151. package/dist/agents/14-data-integrity-auditor.d.ts +12 -0
  152. package/dist/agents/14-data-integrity-auditor.d.ts.map +1 -0
  153. package/dist/agents/14-data-integrity-auditor.js +356 -0
  154. package/dist/agents/14-data-integrity-auditor.js.map +1 -0
  155. package/dist/agents/15-regression-sentinel.d.ts +25 -0
  156. package/dist/agents/15-regression-sentinel.d.ts.map +1 -0
  157. package/dist/agents/15-regression-sentinel.js +251 -0
  158. package/dist/agents/15-regression-sentinel.js.map +1 -0
  159. package/dist/agents/16-chaos-agent.d.ts +9 -0
  160. package/dist/agents/16-chaos-agent.d.ts.map +1 -0
  161. package/dist/agents/16-chaos-agent.js +207 -0
  162. package/dist/agents/16-chaos-agent.js.map +1 -0
  163. package/dist/agents/17-documentation-validator.d.ts +31 -0
  164. package/dist/agents/17-documentation-validator.d.ts.map +1 -0
  165. package/dist/agents/17-documentation-validator.js +246 -0
  166. package/dist/agents/17-documentation-validator.js.map +1 -0
  167. package/dist/agents/18-integration-watchdog.d.ts +10 -0
  168. package/dist/agents/18-integration-watchdog.d.ts.map +1 -0
  169. package/dist/agents/18-integration-watchdog.js +138 -0
  170. package/dist/agents/18-integration-watchdog.js.map +1 -0
  171. package/dist/agents/19-tenant-isolation-auditor.d.ts +9 -0
  172. package/dist/agents/19-tenant-isolation-auditor.d.ts.map +1 -0
  173. package/dist/agents/19-tenant-isolation-auditor.js +166 -0
  174. package/dist/agents/19-tenant-isolation-auditor.js.map +1 -0
  175. package/dist/agents/20-workflow-completion-tester.d.ts +12 -0
  176. package/dist/agents/20-workflow-completion-tester.d.ts.map +1 -0
  177. package/dist/agents/20-workflow-completion-tester.js +159 -0
  178. package/dist/agents/20-workflow-completion-tester.js.map +1 -0
  179. package/dist/agents/21-state-session-tester.d.ts +10 -0
  180. package/dist/agents/21-state-session-tester.d.ts.map +1 -0
  181. package/dist/agents/21-state-session-tester.js +233 -0
  182. package/dist/agents/21-state-session-tester.js.map +1 -0
  183. package/dist/agents/22-email-notification-verifier.d.ts +11 -0
  184. package/dist/agents/22-email-notification-verifier.d.ts.map +1 -0
  185. package/dist/agents/22-email-notification-verifier.js +199 -0
  186. package/dist/agents/22-email-notification-verifier.js.map +1 -0
  187. package/dist/agents/23-migration-tester.d.ts +10 -0
  188. package/dist/agents/23-migration-tester.d.ts.map +1 -0
  189. package/dist/agents/23-migration-tester.js +74 -0
  190. package/dist/agents/23-migration-tester.js.map +1 -0
  191. package/dist/agents/base-agent.d.ts +19 -0
  192. package/dist/agents/base-agent.d.ts.map +1 -0
  193. package/dist/agents/base-agent.js +67 -0
  194. package/dist/agents/base-agent.js.map +1 -0
  195. package/dist/agents/registry.d.ts +29 -0
  196. package/dist/agents/registry.d.ts.map +1 -0
  197. package/dist/agents/registry.js +117 -0
  198. package/dist/agents/registry.js.map +1 -0
  199. package/dist/core/ci-output.d.ts +35 -0
  200. package/dist/core/ci-output.d.ts.map +1 -0
  201. package/dist/core/ci-output.js +193 -0
  202. package/dist/core/ci-output.js.map +1 -0
  203. package/dist/core/cli.d.ts +11 -0
  204. package/dist/core/cli.d.ts.map +1 -0
  205. package/dist/core/cli.js +197 -0
  206. package/dist/core/cli.js.map +1 -0
  207. package/dist/core/config.d.ts +111 -0
  208. package/dist/core/config.d.ts.map +1 -0
  209. package/dist/core/config.js +42 -0
  210. package/dist/core/config.js.map +1 -0
  211. package/dist/core/cost-tracker.d.ts +22 -0
  212. package/dist/core/cost-tracker.d.ts.map +1 -0
  213. package/dist/core/cost-tracker.js +41 -0
  214. package/dist/core/cost-tracker.js.map +1 -0
  215. package/dist/core/evidence.d.ts +28 -0
  216. package/dist/core/evidence.d.ts.map +1 -0
  217. package/dist/core/evidence.js +95 -0
  218. package/dist/core/evidence.js.map +1 -0
  219. package/dist/core/fix-loop.d.ts +29 -0
  220. package/dist/core/fix-loop.d.ts.map +1 -0
  221. package/dist/core/fix-loop.js +70 -0
  222. package/dist/core/fix-loop.js.map +1 -0
  223. package/dist/core/health-check.d.ts +21 -0
  224. package/dist/core/health-check.d.ts.map +1 -0
  225. package/dist/core/health-check.js +26 -0
  226. package/dist/core/health-check.js.map +1 -0
  227. package/dist/core/init.d.ts +2 -0
  228. package/dist/core/init.d.ts.map +1 -0
  229. package/dist/core/init.js +435 -0
  230. package/dist/core/init.js.map +1 -0
  231. package/dist/core/license-gen.d.ts +12 -0
  232. package/dist/core/license-gen.d.ts.map +1 -0
  233. package/dist/core/license-gen.js +169 -0
  234. package/dist/core/license-gen.js.map +1 -0
  235. package/dist/core/license.d.ts +33 -0
  236. package/dist/core/license.d.ts.map +1 -0
  237. package/dist/core/license.js +170 -0
  238. package/dist/core/license.js.map +1 -0
  239. package/dist/core/messages.d.ts +10 -0
  240. package/dist/core/messages.d.ts.map +1 -0
  241. package/dist/core/messages.js +47 -0
  242. package/dist/core/messages.js.map +1 -0
  243. package/dist/core/multi-browser.d.ts +36 -0
  244. package/dist/core/multi-browser.d.ts.map +1 -0
  245. package/dist/core/multi-browser.js +88 -0
  246. package/dist/core/multi-browser.js.map +1 -0
  247. package/dist/core/orchestrator.d.ts +48 -0
  248. package/dist/core/orchestrator.d.ts.map +1 -0
  249. package/dist/core/orchestrator.js +291 -0
  250. package/dist/core/orchestrator.js.map +1 -0
  251. package/dist/core/phase-gate.d.ts +4 -0
  252. package/dist/core/phase-gate.d.ts.map +1 -0
  253. package/dist/core/phase-gate.js +39 -0
  254. package/dist/core/phase-gate.js.map +1 -0
  255. package/dist/core/report-html.d.ts +9 -0
  256. package/dist/core/report-html.d.ts.map +1 -0
  257. package/dist/core/report-html.js +617 -0
  258. package/dist/core/report-html.js.map +1 -0
  259. package/dist/core/report-upload.d.ts +16 -0
  260. package/dist/core/report-upload.d.ts.map +1 -0
  261. package/dist/core/report-upload.js +124 -0
  262. package/dist/core/report-upload.js.map +1 -0
  263. package/dist/core/run-counter.d.ts +40 -0
  264. package/dist/core/run-counter.d.ts.map +1 -0
  265. package/dist/core/run-counter.js +120 -0
  266. package/dist/core/run-counter.js.map +1 -0
  267. package/dist/core/types.d.ts +53 -0
  268. package/dist/core/types.d.ts.map +1 -0
  269. package/dist/core/types.js +2 -0
  270. package/dist/core/types.js.map +1 -0
  271. package/dist/helpers/api-client.d.ts +30 -0
  272. package/dist/helpers/api-client.d.ts.map +1 -0
  273. package/dist/helpers/api-client.js +77 -0
  274. package/dist/helpers/api-client.js.map +1 -0
  275. package/dist/helpers/element-discovery.d.ts +18 -0
  276. package/dist/helpers/element-discovery.d.ts.map +1 -0
  277. package/dist/helpers/element-discovery.js +82 -0
  278. package/dist/helpers/element-discovery.js.map +1 -0
  279. package/dist/helpers/env-resolver.d.ts +29 -0
  280. package/dist/helpers/env-resolver.d.ts.map +1 -0
  281. package/dist/helpers/env-resolver.js +51 -0
  282. package/dist/helpers/env-resolver.js.map +1 -0
  283. package/dist/helpers/form-filler.d.ts +13 -0
  284. package/dist/helpers/form-filler.d.ts.map +1 -0
  285. package/dist/helpers/form-filler.js +98 -0
  286. package/dist/helpers/form-filler.js.map +1 -0
  287. package/dist/helpers/modal-handler.d.ts +16 -0
  288. package/dist/helpers/modal-handler.d.ts.map +1 -0
  289. package/dist/helpers/modal-handler.js +95 -0
  290. package/dist/helpers/modal-handler.js.map +1 -0
  291. package/dist/helpers/navigation.d.ts +37 -0
  292. package/dist/helpers/navigation.d.ts.map +1 -0
  293. package/dist/helpers/navigation.js +83 -0
  294. package/dist/helpers/navigation.js.map +1 -0
  295. package/dist/helpers/quality-gate.d.ts +17 -0
  296. package/dist/helpers/quality-gate.d.ts.map +1 -0
  297. package/dist/helpers/quality-gate.js +144 -0
  298. package/dist/helpers/quality-gate.js.map +1 -0
  299. package/dist/helpers/screenshot.d.ts +24 -0
  300. package/dist/helpers/screenshot.d.ts.map +1 -0
  301. package/dist/helpers/screenshot.js +76 -0
  302. package/dist/helpers/screenshot.js.map +1 -0
  303. package/dist/helpers/seed-validator.d.ts +15 -0
  304. package/dist/helpers/seed-validator.d.ts.map +1 -0
  305. package/dist/helpers/seed-validator.js +53 -0
  306. package/dist/helpers/seed-validator.js.map +1 -0
  307. package/helpers/__tests__/api-client.test.ts +199 -0
  308. package/helpers/__tests__/element-discovery.test.ts +202 -0
  309. package/helpers/__tests__/form-filler-extended.test.ts +212 -0
  310. package/helpers/__tests__/form-filler.test.ts +99 -0
  311. package/helpers/__tests__/modal-handler.test.ts +152 -0
  312. package/helpers/__tests__/navigation.test.ts +214 -0
  313. package/helpers/__tests__/quality-gate.test.ts +117 -0
  314. package/helpers/__tests__/screenshot.test.ts +139 -0
  315. package/helpers/__tests__/seed-validator.test.ts +114 -0
  316. package/helpers/api-client.ts +111 -0
  317. package/helpers/element-discovery.ts +105 -0
  318. package/helpers/env-resolver.ts +69 -0
  319. package/helpers/form-filler.ts +126 -0
  320. package/helpers/modal-handler.ts +108 -0
  321. package/helpers/navigation.ts +100 -0
  322. package/helpers/quality-gate.ts +180 -0
  323. package/helpers/screenshot.ts +111 -0
  324. package/helpers/seed-validator.ts +70 -0
  325. package/package.json +88 -0
@@ -0,0 +1,204 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { validateConfig } from '../config';
3
+ import { Orchestrator } from '../orchestrator';
4
+ import type { TestTeamConfig } from '../config';
5
+
6
+ /**
7
+ * Inline sample config that mirrors testteam.config.ts.
8
+ * Using an inline copy keeps the integration test self-contained and avoids
9
+ * a top-level await / dynamic-import requirement in the test runner.
10
+ */
11
+ const sampleConfig: TestTeamConfig = {
12
+ schemaVersion: 1,
13
+ name: 'my-app',
14
+
15
+ auth: {
16
+ loginUrl: '/login',
17
+ credentials: {
18
+ alpha: { email: 'admin@example.com', password: 'test-placeholder' },
19
+ uat: { email: '', password: '' },
20
+ },
21
+ roles: [
22
+ { name: 'owner', email: 'admin@example.com' },
23
+ { name: 'senior_accountant', email: 'sarah@example.com' },
24
+ { name: 'accountant', email: 'mike@example.com' },
25
+ ],
26
+ },
27
+
28
+ modules: [
29
+ { id: 'overview', route: '/', sidebarIcon: true },
30
+ { id: 'tasks', route: '/tasks', sidebarIcon: true },
31
+ { id: 'kanban', route: '/kanban', sidebarIcon: true },
32
+ { id: 'triage', route: '/triage', sidebarIcon: true },
33
+ { id: 'calendar', route: '/calendar', sidebarIcon: true },
34
+ { id: 'compliance', route: '/compliance', sidebarIcon: true },
35
+ { id: 'client-portal', route: '/client-portal', sidebarIcon: true },
36
+ { id: 'client-health', route: '/client-health', sidebarIcon: true },
37
+ { id: 'communications', route: '/communications', sidebarIcon: true },
38
+ { id: 'documents', route: '/documents', sidebarIcon: true },
39
+ { id: 'workflows', route: '/workflows', sidebarIcon: true },
40
+ { id: 'recurring', route: '/recurring', sidebarIcon: true },
41
+ { id: 'task-dependencies', route: '/task-dependencies', sidebarIcon: true },
42
+ { id: 'time-tracking', route: '/time-tracking', sidebarIcon: true },
43
+ { id: 'staff-workload', route: '/staff-workload', sidebarIcon: true },
44
+ { id: 'staff-onboarding', route: '/staff-onboarding', sidebarIcon: true },
45
+ { id: 'quick-notes', route: '/quick-notes', sidebarIcon: true },
46
+ { id: 'announcements', route: '/announcements', sidebarIcon: true },
47
+ { id: 'activity', route: '/activity', sidebarIcon: true },
48
+ { id: 'analytics', route: '/analytics', sidebarIcon: true },
49
+ { id: 'reports', route: '/reports', sidebarIcon: true },
50
+ { id: 'xero', route: '/xero', sidebarIcon: true },
51
+ { id: 'integrations', route: '/integrations', sidebarIcon: true },
52
+ { id: 'settings', route: '/settings', sidebarIcon: true },
53
+ ],
54
+
55
+ environments: {
56
+ alpha: { baseUrl: 'http://localhost:3000', seed: true },
57
+ beta: { baseUrl: 'http://staging.example.com', seed: false },
58
+ uat: { baseUrl: 'https://app.example.com', seed: false },
59
+ },
60
+
61
+ portals: [
62
+ { name: 'bookkeeper', queryParam: null },
63
+ { name: 'client', queryParam: '?portal=client' },
64
+ ],
65
+
66
+ breakpoints: [1920, 1366, 768, 375],
67
+
68
+ integrations: [
69
+ { name: 'xero', type: 'oauth', sandboxAvailable: true },
70
+ { name: 'stripe', type: 'webhook', sandboxAvailable: true },
71
+ { name: 'email-ingest', type: 'imap', sandboxAvailable: false },
72
+ { name: 'ocr-textract', type: 'aws', sandboxAvailable: true },
73
+ ],
74
+
75
+ workers: [
76
+ { name: 'email-ingest' },
77
+ { name: 'ocr-textract' },
78
+ { name: 'subscription-renewer' },
79
+ { name: 'xero-fullsync' },
80
+ { name: 'xero-incremental' },
81
+ ],
82
+
83
+ workflows: [
84
+ {
85
+ name: 'Order Fulfillment',
86
+ steps: [
87
+ { action: 'navigate', target: '/triage', verify: 'section-loaded' },
88
+ { action: 'click', target: '[data-testid="unreconciled-item"]:first-child', verify: 'item-selected' },
89
+ { action: 'click', target: '[data-testid="reconcile-btn"]', verify: 'toast-success' },
90
+ { action: 'navigate', target: '/workflows', verify: 'section-loaded' },
91
+ { action: 'click', target: '[data-testid="trigger-bas"]', verify: 'workflow-started' },
92
+ { action: 'wait', target: '[data-testid="bas-report"]', timeout: 10000 },
93
+ { action: 'click', target: '[data-testid="send-for-approval"]', verify: 'toast-success' },
94
+ { action: 'navigate', target: '/?portal=client', verify: 'portal-switched' },
95
+ { action: 'click', target: '[data-testid="approve-bas"]', verify: 'toast-success' },
96
+ { action: 'navigate', target: '/workflows', verify: 'status-approved' },
97
+ ],
98
+ },
99
+ {
100
+ name: 'New Client Onboarding',
101
+ steps: [
102
+ { action: 'navigate', target: '/client-portal', verify: 'section-loaded' },
103
+ { action: 'click', target: '[data-testid="create-client-btn"]', verify: 'modal-open' },
104
+ { action: 'fill-form', target: '[data-testid="client-form"]', data: 'seed:new-client' },
105
+ { action: 'click', target: '[data-testid="submit-client"]', verify: 'toast-success' },
106
+ { action: 'verify', target: '[data-testid="client-list"]', contains: 'seed:new-client.name' },
107
+ { action: 'navigate', target: '/integrations', verify: 'section-loaded' },
108
+ { action: 'click', target: '[data-testid="connect-xero"]', verify: 'xero-oauth-started' },
109
+ { action: 'verify', target: '[data-testid="sync-status"]', contains: 'syncing' },
110
+ ],
111
+ },
112
+ ],
113
+
114
+ accuracy: {
115
+ enabled: true,
116
+ decimalPrecision: 2,
117
+ currencySymbol: 'USD',
118
+ timezone: 'America/New_York',
119
+ },
120
+
121
+ tenancy: {
122
+ enabled: true,
123
+ isolationField: 'firmId',
124
+ testFirms: ['firm-demo-001'],
125
+ },
126
+
127
+ costBudget: {
128
+ maxPerRun: 50,
129
+ maxPerAgent: 10,
130
+ alertThreshold: 0.8,
131
+ onExceeded: 'abort',
132
+ },
133
+
134
+ agentClassification: {
135
+ blocking: [1, 2, 3, 4, 5, 6, 7, 8, 11, 14, 19, 23],
136
+ advisory: [12, 13, 15, 16, 17, 20, 21, 22],
137
+ },
138
+
139
+ thresholds: {
140
+ unitCoverage: { lines: 80, functions: 80, branches: 70, statements: 80 },
141
+ lighthouse: { accessibility: 90, performance: 85, bestPractices: 85, seo: 80 },
142
+ apiResponseTime: 500,
143
+ bundleSizeLimit: 500,
144
+ maxConsoleErrors: 0,
145
+ },
146
+
147
+ disabledAgents: [],
148
+ };
149
+
150
+ describe('Sample Platform — TestTeam Integration', () => {
151
+ it('validates the sample config without throwing', () => {
152
+ expect(() => validateConfig(sampleConfig)).not.toThrow();
153
+ });
154
+
155
+ it('validateConfig returns a ValidatedConfig with disabledAgentSet', () => {
156
+ const validated = validateConfig(sampleConfig);
157
+ expect(validated.disabledAgentSet).toBeInstanceOf(Set);
158
+ expect(validated.disabledAgentSet.size).toBe(0);
159
+ });
160
+
161
+ it('validated config preserves all 24 modules', () => {
162
+ const validated = validateConfig(sampleConfig);
163
+ expect(validated.modules).toHaveLength(24);
164
+ });
165
+
166
+ it('validated config preserves three environments', () => {
167
+ const validated = validateConfig(sampleConfig);
168
+ expect(Object.keys(validated.environments)).toEqual(['alpha', 'beta', 'uat']);
169
+ });
170
+
171
+ describe('Orchestrator.dryRun with sample config', () => {
172
+ it('returns agent IDs [1, 2, 23, 3, 4, 5] for alpha phase', () => {
173
+ const validated = validateConfig(sampleConfig);
174
+ const orchestrator = new Orchestrator(validated);
175
+ const plan = orchestrator.dryRun('alpha');
176
+
177
+ expect(plan.map(e => e.agentId)).toEqual([1, 2, 23, 3, 4, 5]);
178
+ });
179
+
180
+ it('returns agent IDs [5, 6, 7, 8, 12, 13, 14, 15, 16, 18, 19, 21, 22] for beta phase', () => {
181
+ const validated = validateConfig(sampleConfig);
182
+ const orchestrator = new Orchestrator(validated);
183
+ const plan = orchestrator.dryRun('beta');
184
+
185
+ expect(plan.map(e => e.agentId)).toEqual([5, 6, 7, 8, 12, 13, 14, 15, 16, 18, 19, 21, 22]);
186
+ });
187
+
188
+ it('marks all alpha agents as unregistered when no agents are registered', () => {
189
+ const validated = validateConfig(sampleConfig);
190
+ const orchestrator = new Orchestrator(validated);
191
+ const plan = orchestrator.dryRun('alpha');
192
+
193
+ expect(plan.every(e => e.status === 'unregistered')).toBe(true);
194
+ });
195
+
196
+ it('marks all beta agents as unregistered when no agents are registered', () => {
197
+ const validated = validateConfig(sampleConfig);
198
+ const orchestrator = new Orchestrator(validated);
199
+ const plan = orchestrator.dryRun('beta');
200
+
201
+ expect(plan.every(e => e.status === 'unregistered')).toBe(true);
202
+ });
203
+ });
204
+ });
@@ -0,0 +1,227 @@
1
+ import { describe, it, expect, beforeAll } from 'vitest';
2
+ import { generateKeyPair, generateLicenseKey } from '../license-gen';
3
+ import { validateLicense } from '../license';
4
+ import type { LicensePayload, LicenseTier } from '../license';
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Shared keypair
8
+ // ---------------------------------------------------------------------------
9
+
10
+ let publicKey: string;
11
+ let privateKey: string;
12
+
13
+ beforeAll(() => {
14
+ const keys = generateKeyPair();
15
+ publicKey = keys.publicKey;
16
+ privateKey = keys.privateKey;
17
+ });
18
+
19
+ function buildPayload(
20
+ overrides: Partial<Omit<LicensePayload, 'iat'>> = {},
21
+ ): Omit<LicensePayload, 'iat'> {
22
+ return {
23
+ tier: 'pro',
24
+ exp: Math.floor(Date.now() / 1000) + 3600,
25
+ sub: 'test@example.com',
26
+ maxProjects: 3,
27
+ maxRunsPerMonth: 100,
28
+ features: [],
29
+ ...overrides,
30
+ };
31
+ }
32
+
33
+ // ---------------------------------------------------------------------------
34
+ // generateKeyPair extended tests
35
+ // ---------------------------------------------------------------------------
36
+
37
+ describe('generateKeyPair — extended', () => {
38
+ it('returns an object with publicKey and privateKey strings', () => {
39
+ const keys = generateKeyPair();
40
+ expect(typeof keys.publicKey).toBe('string');
41
+ expect(typeof keys.privateKey).toBe('string');
42
+ });
43
+
44
+ it('generates EC P-256 keys (SPKI/PKCS8 PEM format)', () => {
45
+ const keys = generateKeyPair();
46
+ expect(keys.publicKey).toContain('BEGIN PUBLIC KEY');
47
+ expect(keys.publicKey).toContain('END PUBLIC KEY');
48
+ expect(keys.privateKey).toContain('BEGIN PRIVATE KEY');
49
+ expect(keys.privateKey).toContain('END PRIVATE KEY');
50
+ });
51
+
52
+ it('generates different keys on each call', () => {
53
+ const keys1 = generateKeyPair();
54
+ const keys2 = generateKeyPair();
55
+ expect(keys1.publicKey).not.toBe(keys2.publicKey);
56
+ expect(keys1.privateKey).not.toBe(keys2.privateKey);
57
+ });
58
+
59
+ it('keypair can sign and verify a license', () => {
60
+ const keys = generateKeyPair();
61
+ const payload = buildPayload();
62
+ const key = generateLicenseKey(payload, keys.privateKey);
63
+ const result = validateLicense(key, keys.publicKey);
64
+ expect(result).not.toBeNull();
65
+ expect(result!.tier).toBe('pro');
66
+ });
67
+ });
68
+
69
+ // ---------------------------------------------------------------------------
70
+ // generateLicenseKey extended tests
71
+ // ---------------------------------------------------------------------------
72
+
73
+ describe('generateLicenseKey — extended', () => {
74
+ it('produces a valid JWT with three base64url-encoded parts', () => {
75
+ const key = generateLicenseKey(buildPayload(), privateKey);
76
+ const parts = key.split('.');
77
+ expect(parts).toHaveLength(3);
78
+
79
+ // Each part should be valid base64url
80
+ for (const part of parts) {
81
+ expect(() => Buffer.from(part, 'base64url')).not.toThrow();
82
+ }
83
+ });
84
+
85
+ it('header declares alg=ES256 and typ=JWT', () => {
86
+ const key = generateLicenseKey(buildPayload(), privateKey);
87
+ const headerJson = Buffer.from(key.split('.')[0], 'base64url').toString('utf8');
88
+ const header = JSON.parse(headerJson) as Record<string, string>;
89
+ expect(header.alg).toBe('ES256');
90
+ expect(header.typ).toBe('JWT');
91
+ });
92
+
93
+ it('payload includes all fields from input', () => {
94
+ const payload = buildPayload({
95
+ tier: 'enterprise',
96
+ sub: 'enterprise@corp.com',
97
+ maxProjects: 999,
98
+ maxRunsPerMonth: 999999,
99
+ features: ['sso', 'audit-trail'],
100
+ });
101
+
102
+ const key = generateLicenseKey(payload, privateKey);
103
+ const result = validateLicense(key, publicKey);
104
+
105
+ expect(result).not.toBeNull();
106
+ expect(result!.tier).toBe('enterprise');
107
+ expect(result!.sub).toBe('enterprise@corp.com');
108
+ expect(result!.maxProjects).toBe(999);
109
+ expect(result!.maxRunsPerMonth).toBe(999999);
110
+ expect(result!.features).toEqual(['sso', 'audit-trail']);
111
+ });
112
+
113
+ it('sets iat to approximately current timestamp', () => {
114
+ const before = Math.floor(Date.now() / 1000);
115
+ const key = generateLicenseKey(buildPayload(), privateKey);
116
+ const after = Math.floor(Date.now() / 1000);
117
+
118
+ const result = validateLicense(key, publicKey);
119
+ expect(result).not.toBeNull();
120
+ expect(result!.iat).toBeGreaterThanOrEqual(before);
121
+ expect(result!.iat).toBeLessThanOrEqual(after);
122
+ });
123
+
124
+ it('generates different signatures for different payloads', () => {
125
+ const key1 = generateLicenseKey(buildPayload({ sub: 'user1@test.com' }), privateKey);
126
+ const key2 = generateLicenseKey(buildPayload({ sub: 'user2@test.com' }), privateKey);
127
+
128
+ const sig1 = key1.split('.')[2];
129
+ const sig2 = key2.split('.')[2];
130
+ expect(sig1).not.toBe(sig2);
131
+ });
132
+
133
+ it('works with all license tiers', () => {
134
+ const tiers: LicenseTier[] = ['free', 'pro', 'enterprise'];
135
+
136
+ for (const tier of tiers) {
137
+ const payload = buildPayload({ tier });
138
+ const key = generateLicenseKey(payload, privateKey);
139
+ const result = validateLicense(key, publicKey);
140
+ expect(result).not.toBeNull();
141
+ expect(result!.tier).toBe(tier);
142
+ }
143
+ });
144
+
145
+ it('works with empty features array', () => {
146
+ const payload = buildPayload({ features: [] });
147
+ const key = generateLicenseKey(payload, privateKey);
148
+ const result = validateLicense(key, publicKey);
149
+ expect(result).not.toBeNull();
150
+ expect(result!.features).toEqual([]);
151
+ });
152
+
153
+ it('works with multiple features', () => {
154
+ const features = ['ci-mode', 'sso', 'parallel-agents', 'custom-agents', 'audit-trail'];
155
+ const payload = buildPayload({ features });
156
+ const key = generateLicenseKey(payload, privateKey);
157
+ const result = validateLicense(key, publicKey);
158
+ expect(result).not.toBeNull();
159
+ expect(result!.features).toEqual(features);
160
+ });
161
+
162
+ it('handles maxProjects and maxRunsPerMonth of 0', () => {
163
+ const payload = buildPayload({ maxProjects: 0, maxRunsPerMonth: 0 });
164
+ const key = generateLicenseKey(payload, privateKey);
165
+ const result = validateLicense(key, publicKey);
166
+ expect(result).not.toBeNull();
167
+ expect(result!.maxProjects).toBe(0);
168
+ expect(result!.maxRunsPerMonth).toBe(0);
169
+ });
170
+
171
+ it('handles very large expiry timestamps', () => {
172
+ const farFuture = Math.floor(Date.now() / 1000) + 10 * 365 * 86400; // 10 years
173
+ const payload = buildPayload({ exp: farFuture });
174
+ const key = generateLicenseKey(payload, privateKey);
175
+ const result = validateLicense(key, publicKey);
176
+ expect(result).not.toBeNull();
177
+ expect(result!.exp).toBe(farFuture);
178
+ });
179
+
180
+ it('produces expired license that validateLicense rejects', () => {
181
+ const payload = buildPayload({ exp: Math.floor(Date.now() / 1000) - 3600 });
182
+ const key = generateLicenseKey(payload, privateKey);
183
+ const result = validateLicense(key, publicKey);
184
+ expect(result).toBeNull();
185
+ });
186
+
187
+ it('signed with wrong key is rejected by validateLicense', () => {
188
+ const otherKeys = generateKeyPair();
189
+ const payload = buildPayload();
190
+ const key = generateLicenseKey(payload, otherKeys.privateKey);
191
+ const result = validateLicense(key, publicKey);
192
+ expect(result).toBeNull();
193
+ });
194
+
195
+ it('handles unicode characters in sub field', () => {
196
+ const payload = buildPayload({ sub: 'ユーザー@test.com' });
197
+ const key = generateLicenseKey(payload, privateKey);
198
+ const result = validateLicense(key, publicKey);
199
+ expect(result).not.toBeNull();
200
+ expect(result!.sub).toBe('ユーザー@test.com');
201
+ });
202
+
203
+ it('handles very long sub field', () => {
204
+ const longSub = 'a'.repeat(500) + '@test.com';
205
+ const payload = buildPayload({ sub: longSub });
206
+ const key = generateLicenseKey(payload, privateKey);
207
+ const result = validateLicense(key, publicKey);
208
+ expect(result).not.toBeNull();
209
+ expect(result!.sub).toBe(longSub);
210
+ });
211
+
212
+ it('handles enterprise-scale maxProjects and maxRunsPerMonth', () => {
213
+ const payload = buildPayload({ tier: 'enterprise', maxProjects: 999, maxRunsPerMonth: 999999 });
214
+ const key = generateLicenseKey(payload, privateKey);
215
+ const result = validateLicense(key, publicKey);
216
+ expect(result).not.toBeNull();
217
+ expect(result!.maxProjects).toBe(999);
218
+ expect(result!.maxRunsPerMonth).toBe(999999);
219
+ });
220
+
221
+ it('signature is 64 bytes raw (r||s) for P-256', () => {
222
+ const key = generateLicenseKey(buildPayload(), privateKey);
223
+ const sigB64 = key.split('.')[2];
224
+ const sigBuf = Buffer.from(sigB64, 'base64url');
225
+ expect(sigBuf.length).toBe(64);
226
+ });
227
+ });