@silasfmartins/testhub 1.0.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 (296) hide show
  1. package/.github/copilot-instructions.md +520 -0
  2. package/biome.json +37 -0
  3. package/dist/index.d.ts +45 -0
  4. package/dist/index.js +169 -0
  5. package/dist/scripts/consumer-postinstall.d.ts +15 -0
  6. package/dist/scripts/consumer-postinstall.js +785 -0
  7. package/dist/scripts/generate-docs.d.ts +16 -0
  8. package/dist/scripts/generate-docs.js +1363 -0
  9. package/dist/scripts/generate-index.d.ts +2 -0
  10. package/dist/scripts/generate-index.js +314 -0
  11. package/dist/scripts/init-api.d.ts +2 -0
  12. package/dist/scripts/init-api.js +525 -0
  13. package/dist/scripts/init-banco.d.ts +2 -0
  14. package/dist/scripts/init-banco.js +347 -0
  15. package/dist/scripts/init-frontend.d.ts +2 -0
  16. package/dist/scripts/init-frontend.js +627 -0
  17. package/dist/scripts/init-mobile.d.ts +2 -0
  18. package/dist/scripts/init-mobile.js +481 -0
  19. package/dist/scripts/init-scenarios.d.ts +2 -0
  20. package/dist/scripts/init-scenarios.js +846 -0
  21. package/dist/scripts/init-ssh.d.ts +2 -0
  22. package/dist/scripts/init-ssh.js +639 -0
  23. package/dist/scripts/package-versions.d.ts +57 -0
  24. package/dist/scripts/package-versions.js +768 -0
  25. package/dist/scripts/postinstall.d.ts +1 -0
  26. package/dist/scripts/postinstall.js +527 -0
  27. package/dist/scripts/robust-build.d.ts +7 -0
  28. package/dist/scripts/robust-build.js +88 -0
  29. package/dist/scripts/setup-local-packages.d.ts +31 -0
  30. package/dist/scripts/setup-local-packages.js +237 -0
  31. package/dist/scripts/smart-override.d.ts +2 -0
  32. package/dist/scripts/smart-override.js +1360 -0
  33. package/dist/scripts/sync-configs.d.ts +27 -0
  34. package/dist/scripts/sync-configs.js +248 -0
  35. package/dist/scripts/test-biome-parse.d.ts +5 -0
  36. package/dist/scripts/test-biome-parse.js +84 -0
  37. package/dist/scripts/ultracite-setup.d.ts +4 -0
  38. package/dist/scripts/ultracite-setup.js +310 -0
  39. package/dist/scripts/update-all-init-scripts.d.ts +2 -0
  40. package/dist/scripts/update-all-init-scripts.js +52 -0
  41. package/dist/scripts/update-biome-schema.d.ts +15 -0
  42. package/dist/scripts/update-biome-schema.js +124 -0
  43. package/dist/src/AutoCoreFacade.d.ts +145 -0
  44. package/dist/src/AutoCoreFacade.js +217 -0
  45. package/dist/src/api/ApiActions.d.ts +297 -0
  46. package/dist/src/api/ApiActions.js +1905 -0
  47. package/dist/src/api/Certificate.d.ts +60 -0
  48. package/dist/src/api/Certificate.js +79 -0
  49. package/dist/src/api/JsonResponse.d.ts +116 -0
  50. package/dist/src/api/JsonResponse.js +206 -0
  51. package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
  52. package/dist/src/appium/DeviceFarmViewer.js +1083 -0
  53. package/dist/src/appium/MobileActions.d.ts +347 -0
  54. package/dist/src/appium/MobileActions.js +1632 -0
  55. package/dist/src/appium/MobileConnection.d.ts +160 -0
  56. package/dist/src/appium/MobileConnection.js +772 -0
  57. package/dist/src/config/envLoader.d.ts +123 -0
  58. package/dist/src/config/envLoader.js +361 -0
  59. package/dist/src/config/jest-safe-setup.d.ts +19 -0
  60. package/dist/src/config/jest-safe-setup.js +369 -0
  61. package/dist/src/config/timeouts.d.ts +32 -0
  62. package/dist/src/config/timeouts.js +38 -0
  63. package/dist/src/desktop/DesktopActions.d.ts +46 -0
  64. package/dist/src/desktop/DesktopActions.js +398 -0
  65. package/dist/src/desktop/DesktopConnection.d.ts +32 -0
  66. package/dist/src/desktop/DesktopConnection.js +84 -0
  67. package/dist/src/domain/entities/TestExecution.d.ts +117 -0
  68. package/dist/src/domain/entities/TestExecution.js +150 -0
  69. package/dist/src/domain/entities/TestReport.d.ts +114 -0
  70. package/dist/src/domain/entities/TestReport.js +179 -0
  71. package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
  72. package/dist/src/domain/repositories/ITestRepository.js +14 -0
  73. package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
  74. package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
  75. package/dist/src/functions/errors/BaseError.d.ts +78 -0
  76. package/dist/src/functions/errors/BaseError.js +245 -0
  77. package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
  78. package/dist/src/functions/errors/ConfigurationError.js +48 -0
  79. package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
  80. package/dist/src/functions/errors/ErrorCatalog.js +157 -0
  81. package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
  82. package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
  83. package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
  84. package/dist/src/functions/errors/IntegrationError.js +51 -0
  85. package/dist/src/functions/errors/SecurityError.d.ts +14 -0
  86. package/dist/src/functions/errors/SecurityError.js +42 -0
  87. package/dist/src/functions/errors/SystemError.d.ts +12 -0
  88. package/dist/src/functions/errors/SystemError.js +36 -0
  89. package/dist/src/functions/errors/ValidationError.d.ts +14 -0
  90. package/dist/src/functions/errors/ValidationError.js +61 -0
  91. package/dist/src/functions/errors/index.d.ts +12 -0
  92. package/dist/src/functions/errors/index.js +13 -0
  93. package/dist/src/global-setup.d.ts +1 -0
  94. package/dist/src/global-setup.js +1037 -0
  95. package/dist/src/helpers/BancoActions.d.ts +188 -0
  96. package/dist/src/helpers/BancoActions.js +581 -0
  97. package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
  98. package/dist/src/helpers/EnviromentHelper.js +66 -0
  99. package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
  100. package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
  101. package/dist/src/helpers/SyncSignal.d.ts +15 -0
  102. package/dist/src/helpers/SyncSignal.js +44 -0
  103. package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
  104. package/dist/src/hubdocs/CategoryDetector.js +401 -0
  105. package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
  106. package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
  107. package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
  108. package/dist/src/hubdocs/ExecutionTracker.js +702 -0
  109. package/dist/src/hubdocs/HubDocs.d.ts +395 -0
  110. package/dist/src/hubdocs/HubDocs.js +3586 -0
  111. package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
  112. package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
  113. package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
  114. package/dist/src/hubdocs/StatementTracker.js +2419 -0
  115. package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
  116. package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
  117. package/dist/src/hubdocs/index.d.ts +9 -0
  118. package/dist/src/hubdocs/index.js +9 -0
  119. package/dist/src/hubdocs/types.d.ts +114 -0
  120. package/dist/src/hubdocs/types.js +5 -0
  121. package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
  122. package/dist/src/infrastructure/DependencyContainer.js +250 -0
  123. package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
  124. package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
  125. package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
  126. package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
  127. package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
  128. package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
  129. package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
  130. package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
  131. package/dist/src/interfaces.d.ts +501 -0
  132. package/dist/src/interfaces.js +25 -0
  133. package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
  134. package/dist/src/internal/fakes/__fake-actions__.js +21 -0
  135. package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
  136. package/dist/src/internal/fakes/__forbidden__.js +18 -0
  137. package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
  138. package/dist/src/internal/fakes/__honeypot__.js +24 -0
  139. package/dist/src/octane/OctaneReporter.d.ts +13 -0
  140. package/dist/src/octane/OctaneReporter.js +61 -0
  141. package/dist/src/playwright/CryptoActions.d.ts +20 -0
  142. package/dist/src/playwright/CryptoActions.js +75 -0
  143. package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
  144. package/dist/src/playwright/EnhancedWebActions.js +65 -0
  145. package/dist/src/playwright/WebActions.d.ts +1599 -0
  146. package/dist/src/playwright/WebActions.js +11788 -0
  147. package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
  148. package/dist/src/playwright/actions/ActionTimeline.js +101 -0
  149. package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
  150. package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
  151. package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
  152. package/dist/src/playwright/actions/SelectorCache.js +96 -0
  153. package/dist/src/playwright/actions/index.d.ts +13 -0
  154. package/dist/src/playwright/actions/index.js +14 -0
  155. package/dist/src/playwright/actions/types.d.ts +147 -0
  156. package/dist/src/playwright/actions/types.js +5 -0
  157. package/dist/src/playwright/fixtures.d.ts +112 -0
  158. package/dist/src/playwright/fixtures.js +718 -0
  159. package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
  160. package/dist/src/playwright/network-logs-reporter.js +66 -0
  161. package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
  162. package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
  163. package/dist/src/security/BuildSecurity.d.ts +12 -0
  164. package/dist/src/security/BuildSecurity.js +138 -0
  165. package/dist/src/security/EulaProtection.d.ts +70 -0
  166. package/dist/src/security/EulaProtection.js +155 -0
  167. package/dist/src/security/HoneypotManager.d.ts +46 -0
  168. package/dist/src/security/HoneypotManager.js +234 -0
  169. package/dist/src/security/KeysManager.d.ts +36 -0
  170. package/dist/src/security/KeysManager.js +158 -0
  171. package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
  172. package/dist/src/security/ProofOfWorkIntegration.js +206 -0
  173. package/dist/src/security/SecurityValidation.d.ts +21 -0
  174. package/dist/src/security/SecurityValidation.js +163 -0
  175. package/dist/src/security/SourceMapProtection.d.ts +55 -0
  176. package/dist/src/security/SourceMapProtection.js +220 -0
  177. package/dist/src/security/protector.d.ts +1 -0
  178. package/dist/src/security/protector.js +97 -0
  179. package/dist/src/ssh/SSHActions.d.ts +262 -0
  180. package/dist/src/ssh/SSHActions.js +790 -0
  181. package/dist/src/ssh/SSHClient.d.ts +99 -0
  182. package/dist/src/ssh/SSHClient.js +409 -0
  183. package/dist/src/statements/BaseStatement.d.ts +38 -0
  184. package/dist/src/statements/BaseStatement.js +78 -0
  185. package/dist/src/testContext/AuthStateManager.d.ts +93 -0
  186. package/dist/src/testContext/AuthStateManager.js +256 -0
  187. package/dist/src/testContext/CoverageManager.d.ts +198 -0
  188. package/dist/src/testContext/CoverageManager.js +917 -0
  189. package/dist/src/testContext/TestAnnotations.d.ts +476 -0
  190. package/dist/src/testContext/TestAnnotations.js +2647 -0
  191. package/dist/src/testContext/TestContext.d.ts +138 -0
  192. package/dist/src/testContext/TestContext.js +369 -0
  193. package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
  194. package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
  195. package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
  196. package/dist/src/testContext/UnifiedReportManager.js +1206 -0
  197. package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
  198. package/dist/src/testhub/DynamicConfigManager.js +320 -0
  199. package/dist/src/testhub/SystemsManager.d.ts +119 -0
  200. package/dist/src/testhub/SystemsManager.js +365 -0
  201. package/dist/src/testhub/TestHubClient.d.ts +335 -0
  202. package/dist/src/testhub/TestHubClient.js +1215 -0
  203. package/dist/src/testhub/TestHubReporter.d.ts +62 -0
  204. package/dist/src/testhub/TestHubReporter.js +576 -0
  205. package/dist/src/testhub/TestHubVars.d.ts +116 -0
  206. package/dist/src/testhub/TestHubVars.js +273 -0
  207. package/dist/src/utils/ActionInterceptor.d.ts +59 -0
  208. package/dist/src/utils/ActionInterceptor.js +741 -0
  209. package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
  210. package/dist/src/utils/ArtifactsCompressor.js +181 -0
  211. package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
  212. package/dist/src/utils/AutoLogsFinal.js +148 -0
  213. package/dist/src/utils/CodeGenSession.d.ts +114 -0
  214. package/dist/src/utils/CodeGenSession.js +264 -0
  215. package/dist/src/utils/ConfigLogger.d.ts +133 -0
  216. package/dist/src/utils/ConfigLogger.js +611 -0
  217. package/dist/src/utils/CustomReporter.d.ts +22 -0
  218. package/dist/src/utils/CustomReporter.js +352 -0
  219. package/dist/src/utils/DataStore.d.ts +171 -0
  220. package/dist/src/utils/DataStore.js +484 -0
  221. package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
  222. package/dist/src/utils/DatabaseInterceptor.js +295 -0
  223. package/dist/src/utils/DateHelper.d.ts +16 -0
  224. package/dist/src/utils/DateHelper.js +120 -0
  225. package/dist/src/utils/DateValidator.d.ts +4 -0
  226. package/dist/src/utils/DateValidator.js +51 -0
  227. package/dist/src/utils/DocumentGenerator.d.ts +35 -0
  228. package/dist/src/utils/DocumentGenerator.js +129 -0
  229. package/dist/src/utils/EvidenceCapture.d.ts +90 -0
  230. package/dist/src/utils/EvidenceCapture.js +600 -0
  231. package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
  232. package/dist/src/utils/EvidenceReportGenerator.js +799 -0
  233. package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
  234. package/dist/src/utils/FrameManagementUtil.js +75 -0
  235. package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
  236. package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
  237. package/dist/src/utils/HTMLTemplate.d.ts +1 -0
  238. package/dist/src/utils/HTMLTemplate.js +1034 -0
  239. package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
  240. package/dist/src/utils/InterceptacaoMagica.js +365 -0
  241. package/dist/src/utils/LogSanitizer.d.ts +35 -0
  242. package/dist/src/utils/LogSanitizer.js +110 -0
  243. package/dist/src/utils/Logger.d.ts +65 -0
  244. package/dist/src/utils/Logger.js +284 -0
  245. package/dist/src/utils/McpLocalClient.d.ts +141 -0
  246. package/dist/src/utils/McpLocalClient.js +871 -0
  247. package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
  248. package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
  249. package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
  250. package/dist/src/utils/SpecFileAnalyzer.js +209 -0
  251. package/dist/src/utils/StatementInterceptor.d.ts +18 -0
  252. package/dist/src/utils/StatementInterceptor.js +87 -0
  253. package/dist/src/utils/StatementLogger.d.ts +33 -0
  254. package/dist/src/utils/StatementLogger.js +113 -0
  255. package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
  256. package/dist/src/utils/StatementsInterceptor.js +1 -0
  257. package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
  258. package/dist/src/utils/TeamsFlushHook.js +168 -0
  259. package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
  260. package/dist/src/utils/TerminalLogCapture.js +531 -0
  261. package/dist/src/utils/TestMethodLogger.d.ts +70 -0
  262. package/dist/src/utils/TestMethodLogger.js +95 -0
  263. package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
  264. package/dist/src/utils/UnifiedTeardown.js +400 -0
  265. package/dist/src/utils/XPathCatalog.d.ts +152 -0
  266. package/dist/src/utils/XPathCatalog.js +350 -0
  267. package/dist/src/utils/generators.d.ts +90 -0
  268. package/dist/src/utils/generators.js +167 -0
  269. package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
  270. package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
  271. package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
  272. package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
  273. package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
  274. package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
  275. package/dist/vitest.config.d.ts +2 -0
  276. package/dist/vitest.config.js +59 -0
  277. package/dist/wdio.conf.d.ts +1 -0
  278. package/dist/wdio.conf.js +420 -0
  279. package/package.json +137 -0
  280. package/protect-loader.mjs +643 -0
  281. package/scripts/consumer-postinstall.ts +975 -0
  282. package/scripts/generate-index.ts +343 -0
  283. package/scripts/init-api.ts +613 -0
  284. package/scripts/init-banco.ts +437 -0
  285. package/scripts/init-frontend.ts +727 -0
  286. package/scripts/init-mobile.ts +558 -0
  287. package/scripts/init-scenarios.ts +925 -0
  288. package/scripts/init-ssh.ts +734 -0
  289. package/scripts/package-versions.ts +978 -0
  290. package/scripts/postinstall.ts +605 -0
  291. package/scripts/smart-override.ts +1675 -0
  292. package/scripts/sync-configs.ts +302 -0
  293. package/scripts/ultracite-setup.ts +370 -0
  294. package/src/types/globals.d.ts +48 -0
  295. package/tsconfig.json +29 -0
  296. package/types/autocore-sync-signal.d.ts +10 -0
@@ -0,0 +1,183 @@
1
+ /**
2
+ * 🚀 ParallelExecutionHelper
3
+ *
4
+ * Helper para executar operações de diferentes contextos (Frontend, API, SSH, etc) em paralelo.
5
+ * Útil quando você precisa que uma ação API rode simultaneamente com uma ação Frontend.
6
+ *
7
+ * @example
8
+ * // Executar dashboard Frontend + API em paralelo
9
+ * await ParallelExecutionHelper.executeInParallel([
10
+ * {
11
+ * type: 'Frontend',
12
+ * system: 'SALESFORCE_SANITY',
13
+ * action: async () => {
14
+ * await new PageDashboard().attDashboard()
15
+ * }
16
+ * },
17
+ * {
18
+ * type: 'Api',
19
+ * system: 'API',
20
+ * action: async () => {
21
+ * await new StatementsAPI().sendData()
22
+ * }
23
+ * }
24
+ * ])
25
+ */
26
+ import type { TestInfo } from "@playwright/test";
27
+ export interface ParallelTask {
28
+ /** Tipo de contexto (Frontend, Api, Mobile, SSH, Banco) */
29
+ type: "Frontend" | "Api" | "Mobile" | "SSH" | "Banco";
30
+ /** Nome do sistema a ser usado */
31
+ system: string;
32
+ /** Ambiente (opcional, usa o padrão se não informado) */
33
+ environment?: string;
34
+ /** Função assíncrona a ser executada */
35
+ action: () => Promise<void>;
36
+ /** Descrição da task (para logs) */
37
+ description?: string;
38
+ /** Timeout opcional da task (ms). Se estourar, a task falha */
39
+ timeoutMs?: number;
40
+ }
41
+ export interface ParallelExecutionOptions {
42
+ /**
43
+ * Define qual contexto deve ficar ativo ao final.
44
+ * - frontend: prioriza task Frontend (default)
45
+ * - first: usa a primeira task informada
46
+ * - none: não altera contexto após o paralelo
47
+ */
48
+ restoreContext?: "frontend" | "first" | "none";
49
+ }
50
+ export declare class ParallelExecutionHelper {
51
+ private static applyTaskTestInfo;
52
+ private static runTaskAction;
53
+ /**
54
+ * Executa múltiplas tasks em paralelo, cada uma com seu próprio contexto.
55
+ *
56
+ * @param tasks Array de tasks a serem executadas em paralelo
57
+ * @param testInfo TestInfo do Playwright (obrigatório)
58
+ *
59
+ * @example
60
+ * test('CT001', async ({}, testInfo: TestInfo) => {
61
+ * await ParallelExecutionHelper.executeInParallel([
62
+ * {
63
+ * type: 'Frontend',
64
+ * system: 'SALESFORCE',
65
+ * description: 'Atualizar Dashboard',
66
+ * action: async () => {
67
+ * await new PageDashboard().attDashboard()
68
+ * }
69
+ * },
70
+ * {
71
+ * type: 'Api',
72
+ * system: 'API_BACKEND',
73
+ * description: 'Enviar dados via API',
74
+ * action: async () => {
75
+ * await new StatementsAPI().sendData()
76
+ * }
77
+ * }
78
+ * ], testInfo)
79
+ * })
80
+ */
81
+ static executeInParallel(tasks: ParallelTask[], testInfo: TestInfo, options?: ParallelExecutionOptions): Promise<void>;
82
+ /**
83
+ * 🔥 ATALHOS PARA COMBINAÇÕES COMUNS
84
+ */
85
+ /**
86
+ * Frontend + API em paralelo
87
+ */
88
+ static frontendWithApi(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, apiTask: Omit<ParallelTask, "type">): Promise<void>;
89
+ /**
90
+ * Frontend + Banco em paralelo
91
+ */
92
+ static frontendWithBanco(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
93
+ /**
94
+ * Frontend + SSH em paralelo
95
+ */
96
+ static frontendWithSsh(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
97
+ /**
98
+ * Frontend + Mobile em paralelo
99
+ */
100
+ static frontendWithMobile(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, mobileTask: Omit<ParallelTask, "type">): Promise<void>;
101
+ /**
102
+ * API + Banco em paralelo
103
+ */
104
+ static apiWithBanco(testInfo: TestInfo, apiTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
105
+ /**
106
+ * API + SSH em paralelo
107
+ */
108
+ static apiWithSsh(testInfo: TestInfo, apiTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
109
+ /**
110
+ * API + Mobile em paralelo
111
+ */
112
+ static apiWithMobile(testInfo: TestInfo, apiTask: Omit<ParallelTask, "type">, mobileTask: Omit<ParallelTask, "type">): Promise<void>;
113
+ /**
114
+ * Mobile + Banco em paralelo
115
+ */
116
+ static mobileWithBanco(testInfo: TestInfo, mobileTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
117
+ /**
118
+ * Mobile + SSH em paralelo
119
+ */
120
+ static mobileWithSsh(testInfo: TestInfo, mobileTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
121
+ /**
122
+ * SSH + Banco em paralelo
123
+ */
124
+ static sshWithBanco(testInfo: TestInfo, sshTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
125
+ /**
126
+ * 🎯 COMBINAÇÕES TRIPLAS
127
+ */
128
+ /**
129
+ * Frontend + API + Banco em paralelo
130
+ */
131
+ static frontendApiBanco(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, apiTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
132
+ /**
133
+ * Frontend + API + SSH em paralelo
134
+ */
135
+ static frontendApiSsh(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, apiTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
136
+ /**
137
+ * Frontend + API + Mobile em paralelo
138
+ */
139
+ static frontendApiMobile(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, apiTask: Omit<ParallelTask, "type">, mobileTask: Omit<ParallelTask, "type">): Promise<void>;
140
+ /**
141
+ * Frontend + Banco + SSH em paralelo
142
+ */
143
+ static frontendBancoSsh(testInfo: TestInfo, frontendTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
144
+ /**
145
+ * API + Banco + SSH em paralelo
146
+ */
147
+ static apiBancoSsh(testInfo: TestInfo, apiTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">, sshTask: Omit<ParallelTask, "type">): Promise<void>;
148
+ /**
149
+ * Mobile + API + Banco em paralelo
150
+ */
151
+ static mobileApiBanco(testInfo: TestInfo, mobileTask: Omit<ParallelTask, "type">, apiTask: Omit<ParallelTask, "type">, bancoTask: Omit<ParallelTask, "type">): Promise<void>;
152
+ /**
153
+ * Executa uma ação principal e aguarda um tempo antes de executar ações secundárias em paralelo.
154
+ * Útil quando você precisa que uma ação comece antes das outras.
155
+ *
156
+ * @example
157
+ * test('CT001', async ({}, testInfo: TestInfo) => {
158
+ * await ParallelExecutionHelper.executeWithDelay(
159
+ * testInfo,
160
+ * {
161
+ * type: 'Frontend',
162
+ * system: 'SALESFORCE',
163
+ * action: async () => {
164
+ * await new PageLogin().login()
165
+ * await new PageDashboard().openDashboard() // Começa primeiro
166
+ * }
167
+ * },
168
+ * [
169
+ * {
170
+ * type: 'Api',
171
+ * system: 'API',
172
+ * action: async () => {
173
+ * await new StatementsAPI().sendData() // Roda em paralelo após delay
174
+ * }
175
+ * }
176
+ * ],
177
+ * 2000 // 2 segundos de delay
178
+ * )
179
+ * })
180
+ */
181
+ static executeWithDelay(testInfo: TestInfo, primaryTask: ParallelTask, secondaryTasks: ParallelTask[], delayMs: number): Promise<void>;
182
+ }
183
+ export default ParallelExecutionHelper;
@@ -0,0 +1,375 @@
1
+ /**
2
+ * 🚀 ParallelExecutionHelper
3
+ *
4
+ * Helper para executar operações de diferentes contextos (Frontend, API, SSH, etc) em paralelo.
5
+ * Útil quando você precisa que uma ação API rode simultaneamente com uma ação Frontend.
6
+ *
7
+ * @example
8
+ * // Executar dashboard Frontend + API em paralelo
9
+ * await ParallelExecutionHelper.executeInParallel([
10
+ * {
11
+ * type: 'Frontend',
12
+ * system: 'SALESFORCE_SANITY',
13
+ * action: async () => {
14
+ * await new PageDashboard().attDashboard()
15
+ * }
16
+ * },
17
+ * {
18
+ * type: 'Api',
19
+ * system: 'API',
20
+ * action: async () => {
21
+ * await new StatementsAPI().sendData()
22
+ * }
23
+ * }
24
+ * ])
25
+ */
26
+ import { TestAnnotations } from "../testContext/TestAnnotations.js";
27
+ import { Logger } from "../utils/Logger.js";
28
+ export class ParallelExecutionHelper {
29
+ static applyTaskTestInfo(taskType, testInfo) {
30
+ switch (taskType) {
31
+ case "Frontend":
32
+ TestAnnotations.Frontend.testInfo = testInfo;
33
+ break;
34
+ case "Api":
35
+ TestAnnotations.Api.testInfo = testInfo;
36
+ break;
37
+ case "Mobile":
38
+ TestAnnotations.Mobile.testInfo = testInfo;
39
+ break;
40
+ case "SSH":
41
+ TestAnnotations.SSH.testInfo = testInfo;
42
+ break;
43
+ case "Banco":
44
+ TestAnnotations.Banco.testInfo = testInfo;
45
+ break;
46
+ }
47
+ }
48
+ static async runTaskAction(task) {
49
+ if (!task.timeoutMs || task.timeoutMs <= 0) {
50
+ await task.action();
51
+ return;
52
+ }
53
+ await Promise.race([
54
+ task.action(),
55
+ new Promise((_, reject) => {
56
+ setTimeout(() => {
57
+ reject(new Error(`Task excedeu timeout de ${task.timeoutMs}ms (${task.description || task.system})`));
58
+ }, task.timeoutMs);
59
+ }),
60
+ ]);
61
+ }
62
+ /**
63
+ * Executa múltiplas tasks em paralelo, cada uma com seu próprio contexto.
64
+ *
65
+ * @param tasks Array de tasks a serem executadas em paralelo
66
+ * @param testInfo TestInfo do Playwright (obrigatório)
67
+ *
68
+ * @example
69
+ * test('CT001', async ({}, testInfo: TestInfo) => {
70
+ * await ParallelExecutionHelper.executeInParallel([
71
+ * {
72
+ * type: 'Frontend',
73
+ * system: 'SALESFORCE',
74
+ * description: 'Atualizar Dashboard',
75
+ * action: async () => {
76
+ * await new PageDashboard().attDashboard()
77
+ * }
78
+ * },
79
+ * {
80
+ * type: 'Api',
81
+ * system: 'API_BACKEND',
82
+ * description: 'Enviar dados via API',
83
+ * action: async () => {
84
+ * await new StatementsAPI().sendData()
85
+ * }
86
+ * }
87
+ * ], testInfo)
88
+ * })
89
+ */
90
+ static async executeInParallel(tasks, testInfo, options) {
91
+ Logger.info(`\n🚀 Executando ${tasks.length} tasks em paralelo...`);
92
+ // Criar promises para cada task
93
+ const promises = tasks.map(async (task, index) => {
94
+ const taskName = task.description || `Task ${index + 1} (${task.type})`;
95
+ Logger.info(`\n📋 [${taskName}] Iniciando...`);
96
+ Logger.info(` • Tipo: ${task.type}`);
97
+ Logger.info(` • Sistema: ${task.system}`);
98
+ try {
99
+ // Configurar contexto específico para esta task
100
+ this.applyTaskTestInfo(task.type, testInfo);
101
+ // Configurar sistema
102
+ await TestAnnotations.setSystem(task.system, task.environment);
103
+ // Executar action
104
+ await this.runTaskAction(task);
105
+ Logger.success(` ✅ [${taskName}] Concluída com sucesso`);
106
+ }
107
+ catch (error) {
108
+ Logger.error(` ❌ [${taskName}] Erro`, error);
109
+ throw error;
110
+ }
111
+ });
112
+ // Aguardar todas as tasks em paralelo sem fail-fast
113
+ const settled = await Promise.allSettled(promises);
114
+ // Restaurar contexto para evitar que chamadas após o paralelo fiquem no sistema errado
115
+ const restoreMode = options?.restoreContext || "frontend";
116
+ const restoreTask = restoreMode === "none"
117
+ ? null
118
+ : restoreMode === "first"
119
+ ? tasks[0]
120
+ : tasks.find((task) => task.type === "Frontend") || tasks[0];
121
+ if (restoreTask) {
122
+ try {
123
+ this.applyTaskTestInfo(restoreTask.type, testInfo);
124
+ await TestAnnotations.setSystem(restoreTask.system, restoreTask.environment);
125
+ Logger.info(`🔁 Contexto restaurado após paralelo: ${restoreTask.type} (${restoreTask.system})`);
126
+ }
127
+ catch (restoreError) {
128
+ Logger.warning(`⚠️ Não foi possível restaurar contexto após paralelo: ${restoreError instanceof Error ? restoreError.message : String(restoreError)}`);
129
+ }
130
+ }
131
+ const failures = settled
132
+ .map((result, index) => ({ result, task: tasks[index] }))
133
+ .filter((item) => item.result.status === "rejected");
134
+ if (failures.length > 0) {
135
+ const summary = failures
136
+ .map((item, index) => {
137
+ const reason = item.result.reason;
138
+ const message = reason instanceof Error ? reason.message : String(reason);
139
+ return `${index + 1}) ${item.task.description || item.task.system}: ${message}`;
140
+ })
141
+ .join(" | ");
142
+ throw new Error(`Falha em ${failures.length}/${tasks.length} task(s) do paralelo. ${summary}`);
143
+ }
144
+ Logger.success(`\n✅ Todas as ${tasks.length} tasks foram concluídas em paralelo\n`);
145
+ }
146
+ /**
147
+ * 🔥 ATALHOS PARA COMBINAÇÕES COMUNS
148
+ */
149
+ /**
150
+ * Frontend + API em paralelo
151
+ */
152
+ static async frontendWithApi(testInfo, frontendTask, apiTask) {
153
+ await this.executeInParallel([
154
+ { ...frontendTask, type: "Frontend" },
155
+ { ...apiTask, type: "Api" },
156
+ ], testInfo);
157
+ }
158
+ /**
159
+ * Frontend + Banco em paralelo
160
+ */
161
+ static async frontendWithBanco(testInfo, frontendTask, bancoTask) {
162
+ await this.executeInParallel([
163
+ { ...frontendTask, type: "Frontend" },
164
+ { ...bancoTask, type: "Banco" },
165
+ ], testInfo);
166
+ }
167
+ /**
168
+ * Frontend + SSH em paralelo
169
+ */
170
+ static async frontendWithSsh(testInfo, frontendTask, sshTask) {
171
+ await this.executeInParallel([
172
+ { ...frontendTask, type: "Frontend" },
173
+ { ...sshTask, type: "SSH" },
174
+ ], testInfo);
175
+ }
176
+ /**
177
+ * Frontend + Mobile em paralelo
178
+ */
179
+ static async frontendWithMobile(testInfo, frontendTask, mobileTask) {
180
+ await this.executeInParallel([
181
+ { ...frontendTask, type: "Frontend" },
182
+ { ...mobileTask, type: "Mobile" },
183
+ ], testInfo);
184
+ }
185
+ /**
186
+ * API + Banco em paralelo
187
+ */
188
+ static async apiWithBanco(testInfo, apiTask, bancoTask) {
189
+ await this.executeInParallel([
190
+ { ...apiTask, type: "Api" },
191
+ { ...bancoTask, type: "Banco" },
192
+ ], testInfo);
193
+ }
194
+ /**
195
+ * API + SSH em paralelo
196
+ */
197
+ static async apiWithSsh(testInfo, apiTask, sshTask) {
198
+ await this.executeInParallel([
199
+ { ...apiTask, type: "Api" },
200
+ { ...sshTask, type: "SSH" },
201
+ ], testInfo);
202
+ }
203
+ /**
204
+ * API + Mobile em paralelo
205
+ */
206
+ static async apiWithMobile(testInfo, apiTask, mobileTask) {
207
+ await this.executeInParallel([
208
+ { ...apiTask, type: "Api" },
209
+ { ...mobileTask, type: "Mobile" },
210
+ ], testInfo);
211
+ }
212
+ /**
213
+ * Mobile + Banco em paralelo
214
+ */
215
+ static async mobileWithBanco(testInfo, mobileTask, bancoTask) {
216
+ await this.executeInParallel([
217
+ { ...mobileTask, type: "Mobile" },
218
+ { ...bancoTask, type: "Banco" },
219
+ ], testInfo);
220
+ }
221
+ /**
222
+ * Mobile + SSH em paralelo
223
+ */
224
+ static async mobileWithSsh(testInfo, mobileTask, sshTask) {
225
+ await this.executeInParallel([
226
+ { ...mobileTask, type: "Mobile" },
227
+ { ...sshTask, type: "SSH" },
228
+ ], testInfo);
229
+ }
230
+ /**
231
+ * SSH + Banco em paralelo
232
+ */
233
+ static async sshWithBanco(testInfo, sshTask, bancoTask) {
234
+ await this.executeInParallel([
235
+ { ...sshTask, type: "SSH" },
236
+ { ...bancoTask, type: "Banco" },
237
+ ], testInfo);
238
+ }
239
+ /**
240
+ * 🎯 COMBINAÇÕES TRIPLAS
241
+ */
242
+ /**
243
+ * Frontend + API + Banco em paralelo
244
+ */
245
+ static async frontendApiBanco(testInfo, frontendTask, apiTask, bancoTask) {
246
+ await this.executeInParallel([
247
+ { ...frontendTask, type: "Frontend" },
248
+ { ...apiTask, type: "Api" },
249
+ { ...bancoTask, type: "Banco" },
250
+ ], testInfo);
251
+ }
252
+ /**
253
+ * Frontend + API + SSH em paralelo
254
+ */
255
+ static async frontendApiSsh(testInfo, frontendTask, apiTask, sshTask) {
256
+ await this.executeInParallel([
257
+ { ...frontendTask, type: "Frontend" },
258
+ { ...apiTask, type: "Api" },
259
+ { ...sshTask, type: "SSH" },
260
+ ], testInfo);
261
+ }
262
+ /**
263
+ * Frontend + API + Mobile em paralelo
264
+ */
265
+ static async frontendApiMobile(testInfo, frontendTask, apiTask, mobileTask) {
266
+ await this.executeInParallel([
267
+ { ...frontendTask, type: "Frontend" },
268
+ { ...apiTask, type: "Api" },
269
+ { ...mobileTask, type: "Mobile" },
270
+ ], testInfo);
271
+ }
272
+ /**
273
+ * Frontend + Banco + SSH em paralelo
274
+ */
275
+ static async frontendBancoSsh(testInfo, frontendTask, bancoTask, sshTask) {
276
+ await this.executeInParallel([
277
+ { ...frontendTask, type: "Frontend" },
278
+ { ...bancoTask, type: "Banco" },
279
+ { ...sshTask, type: "SSH" },
280
+ ], testInfo);
281
+ }
282
+ /**
283
+ * API + Banco + SSH em paralelo
284
+ */
285
+ static async apiBancoSsh(testInfo, apiTask, bancoTask, sshTask) {
286
+ await this.executeInParallel([
287
+ { ...apiTask, type: "Api" },
288
+ { ...bancoTask, type: "Banco" },
289
+ { ...sshTask, type: "SSH" },
290
+ ], testInfo);
291
+ }
292
+ /**
293
+ * Mobile + API + Banco em paralelo
294
+ */
295
+ static async mobileApiBanco(testInfo, mobileTask, apiTask, bancoTask) {
296
+ await this.executeInParallel([
297
+ { ...mobileTask, type: "Mobile" },
298
+ { ...apiTask, type: "Api" },
299
+ { ...bancoTask, type: "Banco" },
300
+ ], testInfo);
301
+ }
302
+ /**
303
+ * Executa uma ação principal e aguarda um tempo antes de executar ações secundárias em paralelo.
304
+ * Útil quando você precisa que uma ação comece antes das outras.
305
+ *
306
+ * @example
307
+ * test('CT001', async ({}, testInfo: TestInfo) => {
308
+ * await ParallelExecutionHelper.executeWithDelay(
309
+ * testInfo,
310
+ * {
311
+ * type: 'Frontend',
312
+ * system: 'SALESFORCE',
313
+ * action: async () => {
314
+ * await new PageLogin().login()
315
+ * await new PageDashboard().openDashboard() // Começa primeiro
316
+ * }
317
+ * },
318
+ * [
319
+ * {
320
+ * type: 'Api',
321
+ * system: 'API',
322
+ * action: async () => {
323
+ * await new StatementsAPI().sendData() // Roda em paralelo após delay
324
+ * }
325
+ * }
326
+ * ],
327
+ * 2000 // 2 segundos de delay
328
+ * )
329
+ * })
330
+ */
331
+ static async executeWithDelay(testInfo, primaryTask, secondaryTasks, delayMs) {
332
+ Logger.info(`\n🚀 Executando task principal com ${secondaryTasks.length} tasks secundárias (delay: ${delayMs}ms)...`);
333
+ // Iniciar task principal
334
+ const primaryPromise = (async () => {
335
+ const taskName = primaryTask.description || `Primary Task (${primaryTask.type})`;
336
+ Logger.info(`\n📋 [${taskName}] Iniciando...`);
337
+ try {
338
+ switch (primaryTask.type) {
339
+ case "Frontend":
340
+ TestAnnotations.Frontend.testInfo = testInfo;
341
+ break;
342
+ case "Api":
343
+ TestAnnotations.Api.testInfo = testInfo;
344
+ break;
345
+ case "Mobile":
346
+ TestAnnotations.Mobile.testInfo = testInfo;
347
+ break;
348
+ case "SSH":
349
+ TestAnnotations.SSH.testInfo = testInfo;
350
+ break;
351
+ case "Banco":
352
+ TestAnnotations.Banco.testInfo = testInfo;
353
+ break;
354
+ }
355
+ await TestAnnotations.setSystem(primaryTask.system, primaryTask.environment);
356
+ await primaryTask.action();
357
+ Logger.success(` ✅ [${taskName}] Concluída`);
358
+ }
359
+ catch (error) {
360
+ Logger.error(` ❌ [${taskName}] Erro`, error);
361
+ throw error;
362
+ }
363
+ })();
364
+ // Aguardar delay antes de iniciar tasks secundárias
365
+ const secondaryPromises = (async () => {
366
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
367
+ Logger.info(`\n⏰ Delay de ${delayMs}ms concluído, iniciando tasks secundárias...`);
368
+ await this.executeInParallel(secondaryTasks, testInfo);
369
+ })();
370
+ // Aguardar ambas em paralelo
371
+ await Promise.all([primaryPromise, secondaryPromises]);
372
+ Logger.success(`\n✅ Task principal e todas as tasks secundárias concluídas\n`);
373
+ }
374
+ }
375
+ export default ParallelExecutionHelper;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * SyncSignal - simples sinalização em memória para sincronizar tasks paralelas
3
+ * Uso:
4
+ * await SyncSignal.wait('api_done', 50000)
5
+ * SyncSignal.signal('api_done')
6
+ *
7
+ * Nota: é in-memory e funciona quando as tasks rodam no mesmo processo/worker.
8
+ * Para sincronização entre processos/hosts use Redis ou outro mecanismo externo.
9
+ */
10
+ export declare class SyncSignal {
11
+ static signal(name: string): void;
12
+ static reset(name: string): void;
13
+ static wait(name: string, timeoutMs?: number): Promise<void>;
14
+ }
15
+ export default SyncSignal;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * SyncSignal - simples sinalização em memória para sincronizar tasks paralelas
3
+ * Uso:
4
+ * await SyncSignal.wait('api_done', 50000)
5
+ * SyncSignal.signal('api_done')
6
+ *
7
+ * Nota: é in-memory e funciona quando as tasks rodam no mesmo processo/worker.
8
+ * Para sincronização entre processos/hosts use Redis ou outro mecanismo externo.
9
+ */
10
+ const signals = {};
11
+ export class SyncSignal {
12
+ static signal(name) {
13
+ if (!signals[name])
14
+ signals[name] = { resolved: true, resolvers: [] };
15
+ else {
16
+ signals[name].resolved = true;
17
+ for (const r of signals[name].resolvers)
18
+ r();
19
+ signals[name].resolvers = [];
20
+ }
21
+ }
22
+ static reset(name) {
23
+ signals[name] = { resolved: false, resolvers: [] };
24
+ }
25
+ static async wait(name, timeoutMs = 50000) {
26
+ if (!signals[name])
27
+ signals[name] = { resolved: false, resolvers: [] };
28
+ if (signals[name].resolved)
29
+ return;
30
+ return new Promise((resolve, reject) => {
31
+ const timer = setTimeout(() => {
32
+ // remove resolver
33
+ signals[name].resolvers = signals[name].resolvers.filter(r => r !== resolve);
34
+ reject(new Error(`SyncSignal.wait timeout after ${timeoutMs}ms for '${name}'`));
35
+ }, timeoutMs);
36
+ const resolver = () => {
37
+ clearTimeout(timer);
38
+ resolve();
39
+ };
40
+ signals[name].resolvers.push(resolver);
41
+ });
42
+ }
43
+ }
44
+ export default SyncSignal;