@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,23 @@
1
+ /**
2
+ * 🎯 INTERCEPTAÇÃO MÁGICA REAL E FUNCIONAL
3
+ *
4
+ * Sistema que REALMENTE intercepta criação de classes Statements
5
+ * ESTRATÉGIA DIRETA: Interceptação manual via função específica
6
+ */
7
+ /**
8
+ * 🌟 Ativar interceptação mágica global que FUNCIONA
9
+ */
10
+ export declare function ativarInterceptacaoMagica(): void;
11
+ /**
12
+ * 🛑 Desativar interceptação
13
+ */
14
+ export declare function desativarInterceptacaoMagica(): void;
15
+ /**
16
+ * 🔧 Função para interceptar classes específicas manualmente
17
+ */
18
+ export declare function interceptarClasse<T extends new (...args: any[]) => any>(StatementsClass: T): T;
19
+ /**
20
+ * 🎯 FUNÇÃO DIRETA PARA INTERCEPTAR UMA CLASSE STATEMENT
21
+ * Esta função deve ser chamada DIRETAMENTE quando uma classe Statement é definida
22
+ */
23
+ export declare function interceptarStatementClasseDireta(StatementsClass: any, className?: string): Promise<any>;
@@ -0,0 +1,365 @@
1
+ /**
2
+ * 🎯 INTERCEPTAÇÃO MÁGICA REAL E FUNCIONAL
3
+ *
4
+ * Sistema que REALMENTE intercepta criação de classes Statements
5
+ * ESTRATÉGIA DIRETA: Interceptação manual via função específica
6
+ */
7
+ import { StatementTracker } from '../hubdocs/StatementTracker.js';
8
+ import { TestContext } from '../testContext/TestContext.js';
9
+ import { StatementLogger } from './StatementLogger.js';
10
+ import { Logger } from './Logger.js';
11
+ // Estado da interceptação
12
+ let interceptacaoAtiva = false;
13
+ const classesInterceptadas = new Set();
14
+ /**
15
+ * 🌟 Ativar interceptação mágica global que FUNCIONA
16
+ */
17
+ export function ativarInterceptacaoMagica() {
18
+ if (interceptacaoAtiva)
19
+ return;
20
+ StatementLogger.ativar();
21
+ interceptacaoAtiva = true;
22
+ // ✅ ESTRATÉGIA COMO API: Interceptação automática via polling das classes conhecidas
23
+ setupAutoStatementDetection();
24
+ }
25
+ /**
26
+ * 🎯 ESTRATÉGIA COMO API: Detectar automaticamente classes Statement disponíveis
27
+ * Similar a como ApiActions registra suas próprias ações automaticamente
28
+ */
29
+ function setupAutoStatementDetection() {
30
+ // ✅ POLLING INTELIGENTE: Verificar periodicamente por novas classes Statement
31
+ const checkInterval = 2000; // Verificar a cada 2 segundos
32
+ let checkCount = 0;
33
+ const maxChecks = 30; // Máximo 60 segundos de verificação
34
+ const intervalId = setInterval(async () => {
35
+ checkCount++;
36
+ try {
37
+ await detectAndInterceptStatementClasses();
38
+ // Parar verificação após o limite
39
+ if (checkCount >= maxChecks) {
40
+ clearInterval(intervalId);
41
+ }
42
+ }
43
+ catch (error) {
44
+ Logger.warning(`⚠️ [AutoIntercept] Erro na verificação automática: ${error}`);
45
+ }
46
+ }, checkInterval);
47
+ // ✅ VERIFICAÇÃO INICIAL IMEDIATA
48
+ setTimeout(async () => {
49
+ try {
50
+ await detectAndInterceptStatementClasses();
51
+ }
52
+ catch (error) {
53
+ Logger.warning(`⚠️ [AutoIntercept] Erro na verificação inicial: ${error}`);
54
+ }
55
+ }, 100);
56
+ }
57
+ /**
58
+ * � Detectar e interceptar classes Statement disponíveis globalmente
59
+ */
60
+ async function detectAndInterceptStatementClasses() {
61
+ // ✅ ESTRATÉGIA 1: VERIFICAR CLASSES NO CONTEXTO GLOBAL
62
+ const globalObjects = [globalThis, global].filter(Boolean);
63
+ for (const globalObj of globalObjects) {
64
+ if (!globalObj)
65
+ continue;
66
+ // Procurar por todas as propriedades que podem ser classes Statement
67
+ const propertyNames = Object.getOwnPropertyNames(globalObj);
68
+ for (const propName of propertyNames) {
69
+ try {
70
+ const value = globalObj[propName];
71
+ // Verificar se é uma classe Statement válida
72
+ if (typeof value === 'function' &&
73
+ value.prototype &&
74
+ isStatementClassName(propName) &&
75
+ !classesInterceptadas.has(propName)) {
76
+ Logger.info(`🎯 [AutoIntercept] DETECTADA classe Statement global: ${propName}`);
77
+ await interceptStatementClass(value, propName);
78
+ }
79
+ }
80
+ catch (error) {
81
+ // Ignorar erros de acesso a propriedades protegidas
82
+ }
83
+ }
84
+ }
85
+ // ✅ ESTRATÉGIA 2: VERIFICAR MÓDULOS REALMENTE CARREGADOS (CommonJS)
86
+ await scanLoadedModules();
87
+ // ✅ ESTRATÉGIA 3: DETECÇÃO ESM-NATIVE usando globalThis e import.meta
88
+ await scanESMStatements();
89
+ // ✅ ESTRATÉGIA 4: IMPORTAÇÃO DINÂMICA DE ARQUIVOS CONHECIDOS
90
+ await tryImportKnownStatementFiles();
91
+ }
92
+ /**
93
+ * 🔍 ESTRATÉGIA INTELIGENTE: Escanear apenas módulos realmente carregados pelo Node.js
94
+ * ✅ ESM COMPATIBLE: Verificação segura de require.cache
95
+ */
96
+ async function scanLoadedModules() {
97
+ // ✅ ESM COMPATIBILITY: Verificar se require existe antes de usar
98
+ if (typeof require === 'undefined' || !require.cache) {
99
+ return;
100
+ }
101
+ const loadedModules = Object.keys(require.cache);
102
+ let foundCount = 0;
103
+ for (const modulePath of loadedModules) {
104
+ // Focar apenas em módulos que claramente contêm classes Statement
105
+ if (modulePath.toLowerCase().includes('statement') ||
106
+ modulePath.includes('/statements/') ||
107
+ modulePath.includes('\\statements\\')) {
108
+ try {
109
+ const module = require(modulePath);
110
+ if (module && typeof module === 'object') {
111
+ await processModuleForStatements(module, `carregado:${modulePath.split(/[/\\]/).pop()}`);
112
+ foundCount++;
113
+ }
114
+ }
115
+ catch (error) {
116
+ // Ignorar erros de módulos corrompidos
117
+ }
118
+ }
119
+ }
120
+ Logger.info(`🔍 [AutoIntercept] Escaneados ${foundCount} módulos Statement carregados`);
121
+ }
122
+ /**
123
+ * 🚀 ESTRATÉGIA ESM-NATIVE: Detectar classes Statement em ambiente ESM
124
+ * ✅ Usa globalThis, import.meta e módulos ESM nativos
125
+ */
126
+ async function scanESMStatements() {
127
+ let foundCount = 0;
128
+ try {
129
+ // ✅ ESTRATÉGIA 1: Verificar globalThis para classes Statement
130
+ const globalKeys = Object.getOwnPropertyNames(globalThis);
131
+ for (const key of globalKeys) {
132
+ if (isStatementClassName(key) && !classesInterceptadas.has(key)) {
133
+ try {
134
+ const StatementClass = globalThis[key];
135
+ if (typeof StatementClass === 'function' &&
136
+ StatementClass.prototype) {
137
+ Logger.info(`🌍 [ESM] Detectada classe Statement global: ${key}`);
138
+ await interceptStatementClass(StatementClass, key);
139
+ foundCount++;
140
+ }
141
+ }
142
+ catch (error) {
143
+ // Ignorar erros de acesso
144
+ }
145
+ }
146
+ }
147
+ // ✅ ESTRATÉGIA 2: Verificar window (se estiver em browser)
148
+ if (typeof globalThis !== 'undefined' && globalThis.window) {
149
+ const windowObj = globalThis.window;
150
+ const windowKeys = Object.getOwnPropertyNames(windowObj);
151
+ for (const key of windowKeys) {
152
+ if (isStatementClassName(key) && !classesInterceptadas.has(key)) {
153
+ try {
154
+ const StatementClass = windowObj[key];
155
+ if (typeof StatementClass === 'function' &&
156
+ StatementClass.prototype) {
157
+ Logger.info(`🪟 [ESM] Detectada classe Statement no window: ${key}`);
158
+ await interceptStatementClass(StatementClass, key);
159
+ foundCount++;
160
+ }
161
+ }
162
+ catch (error) {
163
+ // Ignorar erros de acesso
164
+ }
165
+ }
166
+ }
167
+ }
168
+ // ✅ ESTRATÉGIA 3: Verificar process.mainModule (Node.js ESM)
169
+ if (typeof process !== 'undefined' &&
170
+ process.mainModule &&
171
+ process.mainModule.exports) {
172
+ const moduleExports = process.mainModule.exports;
173
+ for (const [key, value] of Object.entries(moduleExports)) {
174
+ if (isStatementClassName(key) &&
175
+ typeof value === 'function' &&
176
+ value.prototype &&
177
+ !classesInterceptadas.has(key)) {
178
+ Logger.info(`📦 [ESM] Detectada classe Statement no mainModule: ${key}`);
179
+ await interceptStatementClass(value, key);
180
+ foundCount++;
181
+ }
182
+ }
183
+ }
184
+ }
185
+ catch (error) {
186
+ Logger.warning(`⚠️ [ESM] Erro na detecção ESM: ${error}`);
187
+ }
188
+ }
189
+ /**
190
+ * 📁 Detectar dinamicamente TODOS os arquivos Statement no projeto - 100% SEM LISTA FIXA
191
+ * ✅ ESM COMPATIBLE: Detecção segura sem dependência de require.cache
192
+ */
193
+ async function tryImportKnownStatementFiles() {
194
+ // ✅ ESM COMPATIBILITY: Verificar se require existe antes de usar
195
+ if (typeof require === 'undefined') {
196
+ return;
197
+ }
198
+ // ✅ ÚNICA ESTRATÉGIA: Verificar APENAS módulos realmente carregados pelo Node.js
199
+ const loadedModules = Object.keys(require.cache || {});
200
+ let foundCount = 0;
201
+ for (const modulePath of loadedModules) {
202
+ // Detectar QUALQUER módulo que contenha "statement" (case-insensitive)
203
+ const pathLower = modulePath.toLowerCase();
204
+ if (pathLower.includes('statement')) {
205
+ try {
206
+ const module = require(modulePath);
207
+ await processModuleForStatements(module, `dynamic:${modulePath.split(/[/\\]/).pop()}`);
208
+ foundCount++;
209
+ }
210
+ catch (error) {
211
+ // Ignorar erros de módulos corrompidos
212
+ }
213
+ }
214
+ }
215
+ Logger.info(`🎯 [AutoIntercept] Detecção dinâmica: ${foundCount} módulos Statement processados`);
216
+ // ✅ DETECÇÃO ADICIONAL: Verificar objetos globais com padrão Statement*
217
+ if (typeof global !== 'undefined') {
218
+ const globalKeys = Object.getOwnPropertyNames(global);
219
+ for (const key of globalKeys) {
220
+ if (isStatementClassName(key) && !classesInterceptadas.has(key)) {
221
+ try {
222
+ const StatementClass = global[key];
223
+ if (typeof StatementClass === 'function' &&
224
+ StatementClass.prototype) {
225
+ Logger.info(`🌍 [AutoIntercept] Detectada classe Statement global: ${key}`);
226
+ await interceptStatementClass(StatementClass, key);
227
+ }
228
+ }
229
+ catch (error) {
230
+ // Ignorar erros de acesso
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ /**
237
+ * 🔍 Processar módulo em busca de classes Statement
238
+ */
239
+ async function processModuleForStatements(module, source) {
240
+ if (!module)
241
+ return;
242
+ // Verificar todas as exportações do módulo
243
+ for (const [exportName, exportValue] of Object.entries(module)) {
244
+ if (typeof exportValue === 'function' &&
245
+ exportValue.prototype &&
246
+ isStatementClassName(exportName) &&
247
+ !classesInterceptadas.has(exportName)) {
248
+ Logger.info(`🎯 [AutoIntercept] DETECTADA classe Statement em módulo: ${exportName} (${source})`);
249
+ await interceptStatementClass(exportValue, exportName);
250
+ }
251
+ }
252
+ }
253
+ /**
254
+ * 🔍 Detectar se é nome de classe Statement
255
+ */
256
+ function isStatementClassName(name) {
257
+ if (!name)
258
+ return false;
259
+ return ((name.startsWith('Statements') ||
260
+ (name.includes('Statement') && !name.includes('Tracker')) ||
261
+ name.endsWith('Statement')) &&
262
+ // 🚫 FILTRAR: Ignorar classes do sistema interno
263
+ !(name.includes('Tracker') ||
264
+ name.includes('Logger') ||
265
+ name.includes('Manager') ||
266
+ name.includes('Helper') ||
267
+ name.includes('Actions')));
268
+ }
269
+ /**
270
+ * 🎯 Interceptar classe Statement
271
+ */
272
+ async function interceptStatementClass(StatementClass, className) {
273
+ if (classesInterceptadas.has(className))
274
+ return;
275
+ classesInterceptadas.add(className);
276
+ try {
277
+ Logger.info(`🔄 [InterceptacaoMagica] Interceptando ${className}...`);
278
+ // 🚫 REMOVIDO: NÃO criar testes automáticos
279
+ // O teste real já existe (ex: "CT01 - Consumo de Voz VC1")
280
+ // Apenas interceptamos os métodos para que sejam detectados como CTs
281
+ // Analisar métodos da classe
282
+ const methodNames = Object.getOwnPropertyNames(StatementClass.prototype).filter((name) => {
283
+ if (name === 'constructor')
284
+ return false;
285
+ if (name.startsWith('_'))
286
+ return false;
287
+ const descriptor = Object.getOwnPropertyDescriptor(StatementClass.prototype, name);
288
+ return descriptor && typeof descriptor.value === 'function';
289
+ });
290
+ Logger.info(`📋 [InterceptacaoMagica] ${className} tem ${methodNames.length} métodos: ${methodNames.join(', ')}`);
291
+ // Interceptar cada método DIRETAMENTE no prototype
292
+ for (const methodName of methodNames) {
293
+ const originalMethod = StatementClass.prototype[methodName];
294
+ if (typeof originalMethod === 'function') {
295
+ StatementClass.prototype[methodName] = async function (...args) {
296
+ // 🎯 DETECTAR NOME REAL DO CT: Tentar extrair do contexto do teste
297
+ let realCTName = `CT - ${className}.${methodName}`; // Nome padrão
298
+ try {
299
+ const testInfo = TestContext.getSafeTestInfo();
300
+ if (testInfo?.title) {
301
+ // 🎯 USAR NOME REAL DO TESTE: "CT01 - Consumo de Voz VC1"
302
+ realCTName = testInfo.title;
303
+ Logger.info(`🎯 [CT-REAL] Detectado nome real do CT: "${realCTName}"`);
304
+ }
305
+ }
306
+ catch (error) {
307
+ // Usar nome padrão se não conseguir detectar
308
+ Logger.info(`⚠️ [CT-REAL] Usando nome padrão: "${realCTName}"`);
309
+ }
310
+ Logger.info(`🚀 [CT-INDIVIDUAL] Criando CT individual: ${realCTName}`);
311
+ // Criar CT individual com nome real
312
+ StatementTracker.startCT(realCTName);
313
+ const startTime = Date.now();
314
+ try {
315
+ const result = await originalMethod.apply(this, args);
316
+ const endTime = Date.now();
317
+ const duration = endTime - startTime;
318
+ // Finalizar CT com sucesso
319
+ StatementTracker.endCT(realCTName, true);
320
+ Logger.success(`✅ [CT-INDIVIDUAL] CT "${realCTName}" concluído com sucesso (${duration}ms)`);
321
+ return result;
322
+ }
323
+ catch (error) {
324
+ const endTime = Date.now();
325
+ const duration = endTime - startTime;
326
+ // Finalizar CT com erro
327
+ StatementTracker.endCT(realCTName, false);
328
+ Logger.info(`❌ [CT-INDIVIDUAL] CT "${realCTName}" falhou (${duration}ms): ${error}`);
329
+ throw error;
330
+ }
331
+ };
332
+ }
333
+ }
334
+ Logger.success(`✅ [InterceptacaoMagica] ${className} interceptado - ${methodNames.length} métodos podem criar CTs automaticamente`);
335
+ }
336
+ catch (error) {
337
+ Logger.warning(`⚠️ [InterceptacaoMagica] Erro ao interceptar ${className}: ${error}`);
338
+ }
339
+ }
340
+ /**
341
+ * 🛑 Desativar interceptação
342
+ */
343
+ export function desativarInterceptacaoMagica() {
344
+ if (!interceptacaoAtiva)
345
+ return;
346
+ interceptacaoAtiva = false;
347
+ classesInterceptadas.clear();
348
+ Logger.info('🛑 Interceptação mágica desativada');
349
+ }
350
+ /**
351
+ * 🔧 Função para interceptar classes específicas manualmente
352
+ */
353
+ export function interceptarClasse(StatementsClass) {
354
+ return StatementLogger.interceptClass(StatementsClass);
355
+ }
356
+ /**
357
+ * 🎯 FUNÇÃO DIRETA PARA INTERCEPTAR UMA CLASSE STATEMENT
358
+ * Esta função deve ser chamada DIRETAMENTE quando uma classe Statement é definida
359
+ */
360
+ export async function interceptarStatementClasseDireta(StatementsClass, className) {
361
+ const nome = className || StatementsClass.name;
362
+ Logger.info(`🎯 [InterceptacaoMagica] INTERCEPTAÇÃO DIRETA: ${nome}`);
363
+ await interceptStatementClass(StatementsClass, nome);
364
+ return StatementsClass;
365
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Sanitizador de dados sensíveis para uso em logs e outputs.
3
+ *
4
+ * Garante que tokens, senhas, API keys e outros segredos nunca
5
+ * sejam expostos em logs do framework.
6
+ *
7
+ * @module utils/LogSanitizer
8
+ */
9
+ /**
10
+ * Verifica se uma chave parece conter dados sensíveis.
11
+ */
12
+ export declare function isSensitiveKey(key: string): boolean;
13
+ /**
14
+ * Verifica se um valor parece ser um segredo.
15
+ */
16
+ export declare function isSensitiveValue(value: string): boolean;
17
+ /**
18
+ * Mascara um valor sensível, mantendo início e fim para debug.
19
+ * Ex.: `abc123xyz` → `abc***xyz`
20
+ */
21
+ export declare function maskValue(value: string): string;
22
+ /**
23
+ * Sanitiza um objeto genérico, mascarando campos sensíveis.
24
+ * Funciona recursivamente em objetos aninhados.
25
+ */
26
+ export declare function sanitize(data: unknown): unknown;
27
+ /**
28
+ * Sanitiza uma string de log, mascarando padrões de segredo inline.
29
+ * Útil para mensagens de log que podem conter tokens concatenados.
30
+ */
31
+ export declare function sanitizeLogMessage(message: string): string;
32
+ /**
33
+ * Sanitiza headers HTTP, mascarando Authorization e outros campos sensíveis.
34
+ */
35
+ export declare function sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Sanitizador de dados sensíveis para uso em logs e outputs.
3
+ *
4
+ * Garante que tokens, senhas, API keys e outros segredos nunca
5
+ * sejam expostos em logs do framework.
6
+ *
7
+ * @module utils/LogSanitizer
8
+ */
9
+ /** Padrões de chaves que devem ser mascarados (case-insensitive). */
10
+ const SENSITIVE_KEY_PATTERNS = [
11
+ /password/i,
12
+ /passwd/i,
13
+ /secret/i,
14
+ /token/i,
15
+ /api[_-]?key/i,
16
+ /auth/i,
17
+ /bearer/i,
18
+ /credential/i,
19
+ /private[_-]?key/i,
20
+ /access[_-]?key/i,
21
+ /session[_-]?id/i,
22
+ /cookie/i,
23
+ /x-api-key/i,
24
+ /authorization/i,
25
+ ];
26
+ /** Padrões de valores que parecem segredos (ex.: JWT, base64 longo). */
27
+ const SENSITIVE_VALUE_PATTERNS = [
28
+ /^eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/, // JWT
29
+ /^Bearer\s+.{10,}/i, // Bearer token
30
+ /^Basic\s+[A-Za-z0-9+/=]{10,}/i, // Basic auth
31
+ /^ghp_[A-Za-z0-9]{30,}/, // GitHub PAT
32
+ /^sk-[A-Za-z0-9]{30,}/, // OpenAI-style key
33
+ ];
34
+ const MASK = '[REDACTED]';
35
+ /**
36
+ * Verifica se uma chave parece conter dados sensíveis.
37
+ */
38
+ export function isSensitiveKey(key) {
39
+ return SENSITIVE_KEY_PATTERNS.some((p) => p.test(key));
40
+ }
41
+ /**
42
+ * Verifica se um valor parece ser um segredo.
43
+ */
44
+ export function isSensitiveValue(value) {
45
+ return SENSITIVE_VALUE_PATTERNS.some((p) => p.test(value));
46
+ }
47
+ /**
48
+ * Mascara um valor sensível, mantendo início e fim para debug.
49
+ * Ex.: `abc123xyz` → `abc***xyz`
50
+ */
51
+ export function maskValue(value) {
52
+ if (value.length <= 8)
53
+ return MASK;
54
+ return `${value.slice(0, 3)}***${value.slice(-3)}`;
55
+ }
56
+ /**
57
+ * Sanitiza um objeto genérico, mascarando campos sensíveis.
58
+ * Funciona recursivamente em objetos aninhados.
59
+ */
60
+ export function sanitize(data) {
61
+ if (data === null || data === undefined)
62
+ return data;
63
+ if (typeof data === 'string') {
64
+ return isSensitiveValue(data) ? maskValue(data) : data;
65
+ }
66
+ if (Array.isArray(data)) {
67
+ return data.map((item) => sanitize(item));
68
+ }
69
+ if (typeof data === 'object') {
70
+ const result = {};
71
+ for (const [key, value] of Object.entries(data)) {
72
+ if (isSensitiveKey(key) && typeof value === 'string') {
73
+ result[key] = maskValue(value);
74
+ }
75
+ else {
76
+ result[key] = sanitize(value);
77
+ }
78
+ }
79
+ return result;
80
+ }
81
+ return data;
82
+ }
83
+ /**
84
+ * Sanitiza uma string de log, mascarando padrões de segredo inline.
85
+ * Útil para mensagens de log que podem conter tokens concatenados.
86
+ */
87
+ export function sanitizeLogMessage(message) {
88
+ // Mascarar JWTs inline
89
+ let result = message.replace(/eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]*/g, MASK);
90
+ // Mascarar Bearer tokens
91
+ result = result.replace(/Bearer\s+[A-Za-z0-9_.-]{10,}/gi, `Bearer ${MASK}`);
92
+ // Mascarar password=... em query strings
93
+ result = result.replace(/(password|token|secret|api_key|apikey|access_key)=([^&\s]{4,})/gi, (_, key) => `${key}=${MASK}`);
94
+ return result;
95
+ }
96
+ /**
97
+ * Sanitiza headers HTTP, mascarando Authorization e outros campos sensíveis.
98
+ */
99
+ export function sanitizeHeaders(headers) {
100
+ const result = {};
101
+ for (const [key, value] of Object.entries(headers)) {
102
+ if (isSensitiveKey(key)) {
103
+ result[key] = maskValue(value);
104
+ }
105
+ else {
106
+ result[key] = value;
107
+ }
108
+ }
109
+ return result;
110
+ }
@@ -0,0 +1,65 @@
1
+ import type { Page } from '@playwright/test';
2
+ import type { IPage } from '../interfaces.js';
3
+ type PageLike = Page | IPage | any;
4
+ export declare class Logger {
5
+ static logLevel: string;
6
+ static logLevels: {
7
+ [key: string]: number;
8
+ };
9
+ /**
10
+ * Sanitiza uma mensagem antes de logar, mascarando segredos.
11
+ */
12
+ private static safe;
13
+ /**
14
+ * ATUALIZADO: Registra logs de sucesso e integra com UnifiedReportManager
15
+ */
16
+ static success(message: string): void;
17
+ /**
18
+ * ATUALIZADO: Registra logs informativos e integra com UnifiedReportManager
19
+ */
20
+ static info(message: string): void;
21
+ /**
22
+ * ATUALIZADO: Registra logs de aviso e integra com UnifiedReportManager
23
+ */
24
+ static warning(message: string): void;
25
+ /**
26
+ * ATUALIZADO: Registra logs de erro e integra com UnifiedReportManager
27
+ */
28
+ static error(message: string, error?: unknown): void;
29
+ /**
30
+ * ATUALIZADO: Captura screenshot integrado com UnifiedReportManager
31
+ */
32
+ static captureScreenshot(page: PageLike, nome?: string): Promise<void>;
33
+ static shouldLog(level: string): boolean;
34
+ static bloco(titulo: string): void;
35
+ static object(valor: any): void;
36
+ /**
37
+ * NOVO: Log específico para inicialização de teste
38
+ */
39
+ static testStart(testName: string, testType: string): void;
40
+ /**
41
+ * NOVO: Log específico para finalização de teste
42
+ */
43
+ static testEnd(testName: string, testType: string, duration: number, success: boolean): void;
44
+ /**
45
+ * NOVO: Log específico para ações de UI
46
+ */
47
+ static action(action: string, element?: string, description?: string): void;
48
+ /**
49
+ * NOVO: Log específico para validações
50
+ */
51
+ static validation(description: string, success: boolean, expected?: any, actual?: any): void;
52
+ /**
53
+ * NOVO: Log específico para métricas e performance
54
+ */
55
+ static metric(metricName: string, value: number, unit?: string, context?: string): void;
56
+ /**
57
+ * NOVO: Log para debug de desenvolvimento
58
+ */
59
+ static debug(message: string, data?: any): void;
60
+ /**
61
+ * NOVO: Log para separadores visuais
62
+ */
63
+ static separator(title?: string): void;
64
+ }
65
+ export {};