@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,20 @@
1
+ /**
2
+ * PDF Evidence Generator - Sistema Simplificado
3
+ * Gera relatorios PDF simples baseado nas evidencias coletadas
4
+ * TestHUB Team
5
+ * version 2.0.0
6
+ */
7
+ export declare class PDFEvidenceGenerator {
8
+ /**
9
+ * Gera PDF organizando evidencias dos projetos consumidores
10
+ */
11
+ static generatePDF(): Promise<void>;
12
+ /**
13
+ * Conta screenshots em uma pasta
14
+ */
15
+ private static countScreenshots;
16
+ /**
17
+ * Gera HTML simples para PDF
18
+ */
19
+ private static generateSimplePDFHTML;
20
+ }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * PDF Evidence Generator - Sistema Simplificado
3
+ * Gera relatorios PDF simples baseado nas evidencias coletadas
4
+ * TestHUB Team
5
+ * version 2.0.0
6
+ */
7
+ import * as fs from 'node:fs';
8
+ import * as path from 'node:path';
9
+ import { Logger } from './Logger.js';
10
+ export class PDFEvidenceGenerator {
11
+ /**
12
+ * Gera PDF organizando evidencias dos projetos consumidores
13
+ */
14
+ static async generatePDF() {
15
+ try {
16
+ Logger.info('PDFGenerator: Iniciando geracao de PDF simplificado...');
17
+ Logger.info('Sistema simplificado - apenas contagem de evidencias');
18
+ // Sistema simplificado - apenas contar evidencias
19
+ const userHome = process.env.USERPROFILE || process.env.HOME || '';
20
+ const webPath = path.join(userHome, 'PlayWright', 'test-simplifique-e2e', 'test-results', 'web-screenshots');
21
+ const mobilePath = path.join(userHome, 'PlayWright', 'mobile', 'test-results', 'mobile-screenshots');
22
+ let totalScreenshots = 0;
23
+ const projects = [];
24
+ if (fs.existsSync(webPath)) {
25
+ const webFiles = PDFEvidenceGenerator.countScreenshots(webPath);
26
+ totalScreenshots += webFiles;
27
+ projects.push({ type: 'Web', count: webFiles, path: webPath });
28
+ Logger.info(`Web: ${webFiles} screenshot(s)`);
29
+ }
30
+ if (fs.existsSync(mobilePath)) {
31
+ const mobileFiles = PDFEvidenceGenerator.countScreenshots(mobilePath);
32
+ totalScreenshots += mobileFiles;
33
+ projects.push({ type: 'Mobile', count: mobileFiles, path: mobilePath });
34
+ Logger.info(`Mobile: ${mobileFiles} screenshot(s)`);
35
+ }
36
+ Logger.info(`PDFGenerator Total: ${totalScreenshots} evidencias encontradas`);
37
+ if (totalScreenshots === 0) {
38
+ Logger.info('Nenhuma evidencia encontrada para gerar PDF');
39
+ return;
40
+ }
41
+ // Gerar HTML simples para PDF
42
+ const html = PDFEvidenceGenerator.generateSimplePDFHTML(projects, totalScreenshots);
43
+ // ✅ CORRIGIDO: Criar pasta playwright-report se não existir
44
+ const playwrightReportDir = path.join(process.cwd(), 'playwright-report');
45
+ if (!fs.existsSync(playwrightReportDir)) {
46
+ fs.mkdirSync(playwrightReportDir, { recursive: true });
47
+ }
48
+ // ✅ CORRIGIDO: Salvar como HTML em playwright-report
49
+ const outputPath = path.join(playwrightReportDir, 'relatorio-evidencias-pdf.html');
50
+ fs.writeFileSync(outputPath, html, 'utf8');
51
+ Logger.info(`PDFGenerator: Relatorio PDF HTML gerado: ${outputPath}`);
52
+ }
53
+ catch (error) {
54
+ Logger.error('Erro ao gerar PDF de evidencias', error);
55
+ }
56
+ }
57
+ /**
58
+ * Conta screenshots em uma pasta
59
+ */
60
+ static countScreenshots(folderPath) {
61
+ try {
62
+ if (!fs.existsSync(folderPath)) {
63
+ return 0;
64
+ }
65
+ const files = fs.readdirSync(folderPath);
66
+ return files.filter((file) => /\.(png|jpg|jpeg)$/i.test(file)).length;
67
+ }
68
+ catch (error) {
69
+ Logger.warning(`Erro ao contar screenshots em ${folderPath}: ${error}`);
70
+ return 0;
71
+ }
72
+ }
73
+ /**
74
+ * Gera HTML simples para PDF
75
+ */
76
+ static generateSimplePDFHTML(projects, total) {
77
+ const timestamp = new Date().toLocaleString('pt-BR');
78
+ const htmlContent = `<!DOCTYPE html>
79
+ <html lang="pt-BR">
80
+ <head>
81
+ <meta charset="UTF-8">
82
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
83
+ <title>Relatorio PDF de Evidencias - AutoCore</title>
84
+ <style>
85
+ * { margin: 0; padding: 0; box-sizing: border-box; }
86
+ body {
87
+ font-family: Arial, sans-serif;
88
+ background: #f5f7fa;
89
+ color: #2d3748;
90
+ padding: 20px;
91
+ }
92
+ .container {
93
+ max-width: 800px;
94
+ margin: 0 auto;
95
+ background: white;
96
+ padding: 2rem;
97
+ border-radius: 12px;
98
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
99
+ }
100
+ .header {
101
+ text-align: center;
102
+ margin-bottom: 2rem;
103
+ border-bottom: 2px solid #e2e8f0;
104
+ padding-bottom: 1rem;
105
+ }
106
+ .project {
107
+ margin: 1rem 0;
108
+ padding: 1rem;
109
+ background: #f8fafc;
110
+ border-left: 4px solid #4299e1;
111
+ border-radius: 4px;
112
+ }
113
+ .summary {
114
+ background: #e6fffa;
115
+ padding: 1rem;
116
+ border-radius: 8px;
117
+ margin-top: 2rem;
118
+ text-align: center;
119
+ }
120
+ </style>
121
+ </head>
122
+ <body>
123
+ <div class="container">
124
+ <div class="header">
125
+ <h1>Relatorio de Evidencias (PDF)</h1>
126
+ <p>Sistema AutoCore - Organizador de Evidencias</p>
127
+ <p><small>Gerado em: ${timestamp}</small></p>
128
+ </div>
129
+
130
+ <h2>Resumo por Projeto</h2>
131
+
132
+ ${projects
133
+ .map((project) => `
134
+ <div class="project">
135
+ <h3>${project.type}</h3>
136
+ <p><strong>Evidencias encontradas:</strong> ${project.count} screenshot(s)</p>
137
+ <p><small>Pasta: ${project.path}</small></p>
138
+ </div>
139
+ `)
140
+ .join('')}
141
+
142
+ <div class="summary">
143
+ <h3>Total Geral</h3>
144
+ <p><strong>${total} evidencias coletadas</strong> de ${projects.length} projeto(s)</p>
145
+ </div>
146
+
147
+ <div style="margin-top: 2rem; text-align: center; font-size: 0.9em; color: #666;">
148
+ <p>AutoCore coleta e organiza evidencias dos projetos consumidores</p>
149
+ <p>Para visualizar as evidencias, consulte o relatorio HTML detalhado</p>
150
+ </div>
151
+ </div>
152
+ </body>
153
+ </html>`;
154
+ return htmlContent;
155
+ }
156
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 🔍 ANALISADOR DE ARQUIVOS .SPEC.TS
3
+ *
4
+ * Detecta automaticamente CNs (Casos de Negócio) e CTs (Casos de Teste)
5
+ * a partir do arquivo .spec.ts que está sendo executado.
6
+ */
7
+ export type SpecAnalysisResult = {
8
+ cn: string | null;
9
+ ct: string | null;
10
+ statementClasses: string[];
11
+ filePath: string;
12
+ };
13
+ /**
14
+ * 🔍 Analisa o arquivo .spec.ts atual e extrai CNs, CTs e classes Statement
15
+ */
16
+ export declare function analyzeCurrentSpecFile(): SpecAnalysisResult;
17
+ /**
18
+ * 🔍 Analisa um arquivo .spec.ts específico
19
+ */
20
+ export declare function analyzeSpecFile(testFile: string): SpecAnalysisResult;
21
+ /**
22
+ * 🧹 Limpa o cache
23
+ */
24
+ export declare function clearSpecAnalysisCache(): void;
25
+ /**
26
+ * 📊 Obtém estatísticas do cache
27
+ */
28
+ export declare function getSpecAnalysisCacheStats(): {
29
+ size: number;
30
+ keys: string[];
31
+ };
32
+ /**
33
+ * 🎯 Obtém resultado específico do cache
34
+ */
35
+ export declare function getCachedSpecAnalysis(filePath: string): SpecAnalysisResult | null;
@@ -0,0 +1,209 @@
1
+ /**
2
+ * 🔍 ANALISADOR DE ARQUIVOS .SPEC.TS
3
+ *
4
+ * Detecta automaticamente CNs (Casos de Negócio) e CTs (Casos de Teste)
5
+ * a partir do arquivo .spec.ts que está sendo executado.
6
+ */
7
+ import { TestContext } from '../testContext/TestContext.js';
8
+ import { Logger } from './Logger.js';
9
+ // Regex patterns para performance (definidos no top level)
10
+ const CN_PATTERNS = [
11
+ // test.describe("CN001_Nome do CN", () => {
12
+ /test\.describe\s*\(\s*["'`]([^"'`]*CN\d*[^"'`]*)["'`]/,
13
+ // test.describe('CN001_Nome do CN', () => {
14
+ /describe\s*\(\s*["'`]([^"'`]*CN\d*[^"'`]*)["'`]/,
15
+ // Qualquer describe que contenha "CN"
16
+ /(?:test\.)?describe\s*\(\s*["'`]([^"'`]*CN[^"'`]*)["'`]/,
17
+ ];
18
+ const CT_PATTERNS = [
19
+ // test("CT001_Nome do CT", async () => {
20
+ /test\s*\(\s*["'`]([^"'`]*CT\d*[^"'`]*)["'`]/,
21
+ // it("CT001_Nome do CT", async () => {
22
+ /it\s*\(\s*["'`]([^"'`]*CT\d*[^"'`]*)["'`]/,
23
+ // Qualquer test que contenha "CT"
24
+ /(?:test|it)\s*\(\s*["'`]([^"'`]*CT[^"'`]*)["'`]/,
25
+ ];
26
+ const cache = new Map();
27
+ /**
28
+ * 🔍 Analisa o arquivo .spec.ts atual e extrai CNs, CTs e classes Statement
29
+ */
30
+ export function analyzeCurrentSpecFile() {
31
+ const testInfo = TestContext.getSafeTestInfo();
32
+ const filePath = testInfo?.file || 'unknown';
33
+ // Cache para evitar reprocessamento
34
+ if (cache.has(filePath)) {
35
+ return cache.get(filePath);
36
+ }
37
+ const result = analyzeSpecFile(filePath);
38
+ cache.set(filePath, result);
39
+ return result;
40
+ }
41
+ /**
42
+ * 🔍 Analisa um arquivo .spec.ts específico
43
+ */
44
+ export function analyzeSpecFile(testFile) {
45
+ const result = {
46
+ cn: null,
47
+ ct: null,
48
+ statementClasses: [],
49
+ filePath: testFile,
50
+ };
51
+ try {
52
+ const content = readSpecFile(testFile);
53
+ if (!content) {
54
+ return result;
55
+ }
56
+ // Detectar CN (test.describe)
57
+ result.cn = extractCN(content);
58
+ // Detectar CT (test)
59
+ result.ct = extractCT(content);
60
+ // Detectar classes Statement
61
+ result.statementClasses = extractStatementClasses(content);
62
+ if (process.env.AUTOCORE_DEBUG_LOGS === 'true') {
63
+ Logger.info(`📋 [SpecFileAnalyzer] Análise de ${testFile}:`);
64
+ Logger.info(` 📂 CN: ${result.cn || 'não detectado'}`);
65
+ Logger.info(` 🎯 CT: ${result.ct || 'não detectado'}`);
66
+ Logger.info(` 📚 Statement Classes: ${result.statementClasses.length} encontradas`);
67
+ }
68
+ }
69
+ catch (error) {
70
+ if (process.env.AUTOCORE_DEBUG_LOGS === 'true') {
71
+ Logger.warning(`⚠️ [SpecFileAnalyzer] Erro ao analisar ${testFile}: ${error}`);
72
+ }
73
+ }
74
+ return result;
75
+ }
76
+ /**
77
+ * 📖 Lê o conteúdo do arquivo .spec.ts
78
+ */
79
+ function readSpecFile(testFile) {
80
+ try {
81
+ // Obter módulo fs de forma compatível com ESM
82
+ const fs = getFileSystemModule();
83
+ if (!fs) {
84
+ return null;
85
+ }
86
+ // Tentar diferentes caminhos para encontrar o arquivo
87
+ const possiblePaths = [
88
+ testFile,
89
+ testFile.replace('C:\\Users\\A0169497\\PlayWright\\comp-autocore-v1\\', './'),
90
+ `./tests/${testFile.split('\\').pop()}`,
91
+ `./test/${testFile.split('\\').pop()}`,
92
+ `./${testFile.split('\\').pop()}`,
93
+ ];
94
+ for (const filePath of possiblePaths) {
95
+ try {
96
+ if (fs.existsSync?.(filePath)) {
97
+ return fs.readFileSync(filePath, 'utf-8');
98
+ }
99
+ }
100
+ catch {
101
+ // Continua tentando outros caminhos
102
+ }
103
+ }
104
+ return null;
105
+ }
106
+ catch {
107
+ return null;
108
+ }
109
+ }
110
+ /**
111
+ * 🎯 Extrai o nome do CN (Caso de Negócio) do test.describe
112
+ */
113
+ function extractCN(content) {
114
+ for (const pattern of CN_PATTERNS) {
115
+ const match = content.match(pattern);
116
+ if (match?.[1]) {
117
+ return match[1].trim();
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+ /**
123
+ * 🎯 Extrai o nome do CT (Caso de Teste) do test()
124
+ */
125
+ function extractCT(content) {
126
+ for (const pattern of CT_PATTERNS) {
127
+ const match = content.match(pattern);
128
+ if (match?.[1]) {
129
+ return match[1].trim();
130
+ }
131
+ }
132
+ return null;
133
+ }
134
+ /**
135
+ * 📚 Extrai classes Statement do conteúdo
136
+ */
137
+ function extractStatementClasses(content) {
138
+ const detectedClasses = new Set();
139
+ // 1. Imports diretos: import { StatementsToken } from "..."
140
+ const importDirectRegex = /import\s*{\s*([^}]*)\s*}\s*from\s*['"]/g;
141
+ let importMatch;
142
+ while ((importMatch = importDirectRegex.exec(content)) !== null) {
143
+ const importedItems = importMatch[1].split(',');
144
+ importedItems.forEach((item) => {
145
+ const cleanItem = item.trim();
146
+ if (cleanItem.includes('Statement') ||
147
+ cleanItem.startsWith('Statements')) {
148
+ detectedClasses.add(cleanItem);
149
+ }
150
+ });
151
+ }
152
+ // 2. Instanciações: new StatementsToken()
153
+ const newStatementRegex = /new\s+(\w*Statement\w*)\s*\(/g;
154
+ let newMatch;
155
+ while ((newMatch = newStatementRegex.exec(content)) !== null) {
156
+ if (newMatch[1]) {
157
+ detectedClasses.add(newMatch[1]);
158
+ }
159
+ }
160
+ // 3. Await new: await new StatementsToken()
161
+ const awaitNewRegex = /await\s+new\s+(\w*Statement\w*)\s*\(/g;
162
+ let awaitMatch;
163
+ while ((awaitMatch = awaitNewRegex.exec(content)) !== null) {
164
+ if (awaitMatch[1]) {
165
+ detectedClasses.add(awaitMatch[1]);
166
+ }
167
+ }
168
+ // 4. Exports da própria classe: export class StatementsToken
169
+ const exportClassRegex = /export\s+class\s+(\w*Statement\w*)/g;
170
+ let exportMatch;
171
+ while ((exportMatch = exportClassRegex.exec(content)) !== null) {
172
+ if (exportMatch[1]) {
173
+ detectedClasses.add(exportMatch[1]);
174
+ }
175
+ }
176
+ return Array.from(detectedClasses);
177
+ }
178
+ /**
179
+ * 🛠️ Obtém módulo fs compatível com ESM
180
+ */
181
+ function getFileSystemModule() {
182
+ try {
183
+ return globalThis.require?.('fs') || globalThis.fs;
184
+ }
185
+ catch {
186
+ return null;
187
+ }
188
+ }
189
+ /**
190
+ * 🧹 Limpa o cache
191
+ */
192
+ export function clearSpecAnalysisCache() {
193
+ cache.clear();
194
+ }
195
+ /**
196
+ * 📊 Obtém estatísticas do cache
197
+ */
198
+ export function getSpecAnalysisCacheStats() {
199
+ return {
200
+ size: cache.size,
201
+ keys: Array.from(cache.keys()),
202
+ };
203
+ }
204
+ /**
205
+ * 🎯 Obtém resultado específico do cache
206
+ */
207
+ export function getCachedSpecAnalysis(filePath) {
208
+ return cache.get(filePath) || null;
209
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 🎯 Utilitário para Interceptar Statements Automaticamente
3
+ * @description Intercepta dinamicamente classes que começam com "Statements"
4
+ * @author AutoCore Team
5
+ * @version 1.0.0
6
+ */
7
+ /**
8
+ * 🚀 Instalar interceptação automática para uma classe Statement
9
+ */
10
+ export declare function interceptStatement<T extends new (...args: any[]) => any>(StatementClass: T): T;
11
+ /**
12
+ * 🌐 Tentar interceptar todas as classes Statements no global
13
+ */
14
+ export declare function interceptAllStatements(): void;
15
+ /**
16
+ * 🔄 Hook para interceptar módulos ES6 importados
17
+ */
18
+ export declare function setupModuleInterception(): void;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * 🎯 Utilitário para Interceptar Statements Automaticamente
3
+ * @description Intercepta dinamicamente classes que começam com "Statements"
4
+ * @author AutoCore Team
5
+ * @version 1.0.0
6
+ */
7
+ import { StatementTracker } from '../hubdocs/StatementTracker.js';
8
+ import { Logger } from './Logger.js';
9
+ /**
10
+ * 🔍 Proxy handler para interceptar métodos de classes Statements
11
+ */
12
+ const statementsProxyHandler = {
13
+ construct(target, args) {
14
+ const instance = new target(...args);
15
+ // Interceptar todos os métodos da instância
16
+ return new Proxy(instance, {
17
+ get(obj, prop) {
18
+ const value = obj[prop];
19
+ // Se é uma função e não é constructor, interceptar
20
+ if (typeof value === 'function' && prop !== 'constructor') {
21
+ return async (...methodArgs) => {
22
+ const className = target.name;
23
+ const methodName = String(prop);
24
+ const timestamp = StatementTracker.startStatement(className, methodName);
25
+ try {
26
+ const result = await value.apply(obj, methodArgs);
27
+ StatementTracker.finishStatement(timestamp, true);
28
+ return result;
29
+ }
30
+ catch (error) {
31
+ StatementTracker.finishStatement(timestamp, false, String(error));
32
+ throw error;
33
+ }
34
+ };
35
+ }
36
+ return value;
37
+ },
38
+ });
39
+ },
40
+ };
41
+ /**
42
+ * 🚀 Instalar interceptação automática para uma classe Statement
43
+ */
44
+ export function interceptStatement(StatementClass) {
45
+ // Se já foi interceptada, retornar a classe original
46
+ if (StatementClass.__autocore_intercepted) {
47
+ return StatementClass;
48
+ }
49
+ // Criar um proxy da classe
50
+ const ProxiedClass = new Proxy(StatementClass, statementsProxyHandler);
51
+ ProxiedClass.__autocore_intercepted = true;
52
+ Logger.info(`🎯 Classe ${StatementClass.name} interceptada para rastreamento de CTs`);
53
+ return ProxiedClass;
54
+ }
55
+ /**
56
+ * 🌐 Tentar interceptar todas as classes Statements no global
57
+ */
58
+ export function interceptAllStatements() {
59
+ try {
60
+ if (typeof globalThis !== 'undefined') {
61
+ const globalObj = globalThis;
62
+ // Procurar por propriedades que começam com "Statements"
63
+ for (const key of Object.keys(globalObj)) {
64
+ if (key.startsWith('Statements') &&
65
+ typeof globalObj[key] === 'function') {
66
+ try {
67
+ globalObj[key] = interceptStatement(globalObj[key]);
68
+ }
69
+ catch (error) {
70
+ Logger.warning(`⚠️ Erro ao interceptar ${key}: ${error}`);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ catch (error) {
77
+ Logger.warning(`⚠️ Erro na interceptação automática de Statements: ${error}`);
78
+ }
79
+ }
80
+ /**
81
+ * 🔄 Hook para interceptar módulos ES6 importados
82
+ */
83
+ export function setupModuleInterception() {
84
+ // Para ES modules, a interceptação é mais complexa
85
+ // Por enquanto, vamos focar na abordagem manual
86
+ Logger.info('🔄 Module interception configurado (ES modules)');
87
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 🎯 SOLUÇÃO DEFINITIVA E FUNCIONAL
3
+ *
4
+ * Sistema que intercepta automaticamente classes Statements
5
+ * usando uma abordagem simples e eficaz.
6
+ */
7
+ /**
8
+ * 🔥 Sistema de AutoLogs que REALMENTE funciona
9
+ */
10
+ export declare class StatementLogger {
11
+ private static ativo;
12
+ private static interceptedClasses;
13
+ /**
14
+ * 🚀 Ativar sistema
15
+ */
16
+ static ativar(): void;
17
+ /**
18
+ * 🎨 Aplicar logs a uma instância manualmente
19
+ */
20
+ static loggar<T extends object>(instance: T): T;
21
+ /**
22
+ * 🎯 Interceptar classe globalmente via prototype
23
+ */
24
+ static interceptClass<T extends new (...args: any[]) => any>(StatementsClass: T): T;
25
+ }
26
+ /**
27
+ * 🌟 Função helper para criar Statements com logs
28
+ */
29
+ export declare function createStatements<T extends object>(StatementsClass: new (...args: any[]) => T, ...args: any[]): T;
30
+ /**
31
+ * 🔥 Função principal para ativar
32
+ */
33
+ export declare function ativarStatementLogs(): void;
@@ -0,0 +1,113 @@
1
+ import { Logger } from './Logger.js';
2
+ /**
3
+ * 🎯 SOLUÇÃO DEFINITIVA E FUNCIONAL
4
+ *
5
+ * Sistema que intercepta automaticamente classes Statements
6
+ * usando uma abordagem simples e eficaz.
7
+ */
8
+ /**
9
+ * 🔥 Sistema de AutoLogs que REALMENTE funciona
10
+ */
11
+ export class StatementLogger {
12
+ static ativo = false;
13
+ static interceptedClasses = new Set();
14
+ /**
15
+ * 🚀 Ativar sistema
16
+ */
17
+ static ativar() {
18
+ if (StatementLogger.ativo)
19
+ return;
20
+ StatementLogger.ativo = true;
21
+ }
22
+ /**
23
+ * 🎨 Aplicar logs a uma instância manualmente
24
+ */
25
+ static loggar(instance) {
26
+ if (!StatementLogger.ativo)
27
+ return instance;
28
+ const className = instance.constructor.name;
29
+ // Evitar re-wrapping
30
+ if (instance.__isStatementLogged) {
31
+ return instance;
32
+ }
33
+ const wrappedInstance = new Proxy(instance, {
34
+ get(target, prop) {
35
+ const value = Reflect.get(target, prop);
36
+ if (typeof value === 'function' &&
37
+ typeof prop === 'string' &&
38
+ !prop.startsWith('_') &&
39
+ prop !== 'constructor') {
40
+ return async (...args) => {
41
+ const startTime = Date.now();
42
+ // 🎯 NOVO: Log de início mais visível
43
+ Logger.info(`\n┌─`.repeat(40) + '┐');
44
+ Logger.info(`│ 🎯 MÉTODO: ${className}.${prop}`);
45
+ if (args.length > 0) {
46
+ const argStr = args
47
+ .map((a) => typeof a === 'string' && a.length > 30
48
+ ? `${a.substring(0, 27)}...`
49
+ : String(a))
50
+ .join(', ');
51
+ Logger.info(`│ 📝 Parâmetros: ${argStr}`);
52
+ }
53
+ Logger.info('└─'.repeat(40) + '┘');
54
+ try {
55
+ // Executar método original
56
+ const result = await value.apply(target, args);
57
+ // Log de sucesso
58
+ const duration = Date.now() - startTime;
59
+ Logger.success(`✅ ${className}.${prop} - Concluído em ${duration}ms`);
60
+ Logger.info('═'.repeat(80) + '\n');
61
+ return result;
62
+ }
63
+ catch (error) {
64
+ // Log de erro
65
+ const duration = Date.now() - startTime;
66
+ Logger.error(`❌ ${className}.${prop} - ERRO após ${duration}ms: ${error}`);
67
+ Logger.info('═'.repeat(80) + '\n');
68
+ throw error;
69
+ }
70
+ };
71
+ }
72
+ return value;
73
+ },
74
+ });
75
+ wrappedInstance.__isStatementLogged = true;
76
+ return wrappedInstance;
77
+ }
78
+ /**
79
+ * 🎯 Interceptar classe globalmente via prototype
80
+ */
81
+ static interceptClass(StatementsClass) {
82
+ if (!StatementLogger.ativo)
83
+ return StatementsClass;
84
+ const className = StatementsClass.name;
85
+ if (StatementLogger.interceptedClasses.has(className)) {
86
+ return StatementsClass;
87
+ }
88
+ StatementLogger.interceptedClasses.add(className);
89
+ // Criar proxy do constructor
90
+ const ProxiedClass = new Proxy(StatementsClass, {
91
+ construct(target, args) {
92
+ const instance = new target(...args);
93
+ Logger.info(`🎯 Auto-interceptado: ${className}`);
94
+ return StatementLogger.loggar(instance);
95
+ },
96
+ });
97
+ return ProxiedClass;
98
+ }
99
+ }
100
+ /**
101
+ * 🌟 Função helper para criar Statements com logs
102
+ */
103
+ export function createStatements(StatementsClass, ...args) {
104
+ StatementLogger.ativar();
105
+ const instance = new StatementsClass(...args);
106
+ return StatementLogger.loggar(instance);
107
+ }
108
+ /**
109
+ * 🔥 Função principal para ativar
110
+ */
111
+ export function ativarStatementLogs() {
112
+ StatementLogger.ativar();
113
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};