@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.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { HTMLTemplate } from '../utils/HTMLTemplate.js';
|
|
4
|
+
import { Logger } from '../utils/Logger.js';
|
|
5
|
+
import { StatementTracker } from '../hubdocs/StatementTracker.js';
|
|
6
|
+
function getAutoCoreVersion() {
|
|
7
|
+
try {
|
|
8
|
+
const root = process.cwd();
|
|
9
|
+
const pkgPath = path.join(root, 'package.json');
|
|
10
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
11
|
+
return (pkg.dependencies?.['@silasfmartins/testhub'] ||
|
|
12
|
+
pkg.devDependencies?.['@silasfmartins/testhub'] ||
|
|
13
|
+
'1.1.X');
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return '1.1.X';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class UnifiedHtmlGenerator {
|
|
20
|
+
static async generate(testes, inicio, fim, isIndividual = false, tituloCustomizado, projectName, environment, autocoreVersion) {
|
|
21
|
+
// Garante que todos os testes tenham logs como array e preserva dados de CTs
|
|
22
|
+
const testesComLogs = testes.map((t) => ({
|
|
23
|
+
...t,
|
|
24
|
+
logs: Array.isArray(t.logs) ? t.logs : [],
|
|
25
|
+
// ✅ CORRIGIDO: Preservar dados de CTs que vêm do UnifiedReportManager
|
|
26
|
+
cts: Array.isArray(t.cts) ? t.cts : [],
|
|
27
|
+
totalCTs: t.totalCTs || 0,
|
|
28
|
+
passedCTs: t.passedCTs || 0,
|
|
29
|
+
failedCTs: t.failedCTs || 0,
|
|
30
|
+
skippedCTs: t.skippedCTs || 0,
|
|
31
|
+
}));
|
|
32
|
+
const totalTestes = testesComLogs.length;
|
|
33
|
+
const testesPassaram = testesComLogs.filter((t) => t.resultado === 'PASS').length;
|
|
34
|
+
const testesFalharam = testesComLogs.filter((t) => t.resultado === 'FAIL').length;
|
|
35
|
+
const titulo = isIndividual
|
|
36
|
+
? `Relatório Individual: ${tituloCustomizado || 'Teste'}`
|
|
37
|
+
: 'Relatório Geral Unificado de Testes';
|
|
38
|
+
const subtitulo = isIndividual
|
|
39
|
+
? 'Relatório específico do teste selecionado'
|
|
40
|
+
: 'Relatório consolidado de todos os tipos de teste executados';
|
|
41
|
+
const estatisticasPorTipo = UnifiedHtmlGenerator.calcularEstatisticasPorTipo(testesComLogs);
|
|
42
|
+
const coresDosTipos = UnifiedHtmlGenerator.getCoresDosTipos();
|
|
43
|
+
const env = environment || process.env.ENV || process.env.NODE_ENV || 'N/A';
|
|
44
|
+
const version = autocoreVersion || getAutoCoreVersion();
|
|
45
|
+
const projName = projectName ||
|
|
46
|
+
process.env.PROJECT_NAME ||
|
|
47
|
+
(process.env.npm_package_name
|
|
48
|
+
? process.env.npm_package_name
|
|
49
|
+
: 'TestHUB Project');
|
|
50
|
+
// 📋 Obter logs do terminal se disponível
|
|
51
|
+
let terminalLogs = null;
|
|
52
|
+
try {
|
|
53
|
+
if (globalThis.TerminalLogCapture) {
|
|
54
|
+
const logCapture = globalThis.TerminalLogCapture;
|
|
55
|
+
const logsByTest = logCapture.getLogsByTest();
|
|
56
|
+
const stats = logCapture.getStats();
|
|
57
|
+
// Converter Map para objeto simples
|
|
58
|
+
const logsObject = {};
|
|
59
|
+
for (const [testName, logs] of logsByTest.entries()) {
|
|
60
|
+
logsObject[testName] = logs;
|
|
61
|
+
}
|
|
62
|
+
terminalLogs = {
|
|
63
|
+
totalLogs: stats.totalLogs,
|
|
64
|
+
byLevel: stats.byLevel,
|
|
65
|
+
byTest: logsObject,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
Logger.warning(`⚠️ Erro ao obter logs do terminal para relatório: ${error}`);
|
|
71
|
+
}
|
|
72
|
+
// 🆕 CRÍTICO: Buscar dados dos CTs do ARQUIVO JSON (fonte de verdade única)
|
|
73
|
+
let allCNsData = new Map();
|
|
74
|
+
try {
|
|
75
|
+
// ✅ CORREÇÃO: Ler do arquivo JSON ao invés da memória
|
|
76
|
+
const jsonPath = path.join(process.cwd(), '.rbqa', 'ct-execution-data.json');
|
|
77
|
+
if (fs.existsSync(jsonPath)) {
|
|
78
|
+
const jsonContent = fs.readFileSync(jsonPath, 'utf-8');
|
|
79
|
+
const jsonData = JSON.parse(jsonContent);
|
|
80
|
+
// Converter array de testes do JSON para Map
|
|
81
|
+
if (jsonData.tests && Array.isArray(jsonData.tests)) {
|
|
82
|
+
for (const testData of jsonData.tests) {
|
|
83
|
+
allCNsData.set(testData.testName, testData);
|
|
84
|
+
Logger.info(` 📋 CN: "${testData.testName}" - ${testData.cts?.length || 0} CTs (${testData.totalCTs} total)`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
Logger.warning(`⚠️ [UnifiedHtmlGenerator] Arquivo JSON não encontrado: ${jsonPath}`);
|
|
90
|
+
Logger.warning('⚠️ [UnifiedHtmlGenerator] Usando dados da memória como fallback');
|
|
91
|
+
// Fallback: usar dados da memória
|
|
92
|
+
const allExecutions = StatementTracker.getExecutions();
|
|
93
|
+
allCNsData = new Map(allExecutions);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
Logger.warning(`⚠️ Erro ao buscar dados do arquivo JSON: ${error}`);
|
|
98
|
+
Logger.warning('⚠️ Tentando fallback para dados da memória...');
|
|
99
|
+
// Fallback: usar dados da memória
|
|
100
|
+
try {
|
|
101
|
+
const allExecutions = StatementTracker.getExecutions();
|
|
102
|
+
allCNsData = new Map(allExecutions);
|
|
103
|
+
Logger.info(`📊 [UnifiedHtmlGenerator] Fallback: ${allCNsData.size} CNs da memória`);
|
|
104
|
+
}
|
|
105
|
+
catch (fallbackError) {
|
|
106
|
+
Logger.error('❌ [UnifiedHtmlGenerator] Falha no fallback', fallbackError);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// 📊 Agregar totais globais de CTs (alinhado com envio para AutoCore Hub)
|
|
110
|
+
let globalTotalCTs = 0;
|
|
111
|
+
let globalPassedCTs = 0;
|
|
112
|
+
let globalFailedCTs = 0;
|
|
113
|
+
let globalSkippedCTs = 0;
|
|
114
|
+
const aggregateFromCTs = (ctList) => {
|
|
115
|
+
for (const ct of ctList) {
|
|
116
|
+
globalTotalCTs += 1;
|
|
117
|
+
const status = String(ct.status || '').toLowerCase();
|
|
118
|
+
if (status === 'passed') {
|
|
119
|
+
globalPassedCTs += 1;
|
|
120
|
+
}
|
|
121
|
+
else if (status === 'skipped') {
|
|
122
|
+
globalSkippedCTs += 1;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Inclui failed, running, undefined -> tratado como falha (mesma lógica do payload batch)
|
|
126
|
+
globalFailedCTs += 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
if (allCNsData.size > 0) {
|
|
131
|
+
for (const cnData of allCNsData.values()) {
|
|
132
|
+
const cts = Array.isArray(cnData.cts)
|
|
133
|
+
? cnData.cts
|
|
134
|
+
: [];
|
|
135
|
+
if (cts.length > 0) {
|
|
136
|
+
aggregateFromCTs(cts);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const total = Number(cnData.totalCTs || 0);
|
|
140
|
+
if (total > 0) {
|
|
141
|
+
globalTotalCTs += total;
|
|
142
|
+
const passed = Number(cnData.passedCTs || 0);
|
|
143
|
+
const failed = Number(cnData.failedCTs || 0);
|
|
144
|
+
const skipped = Number(cnData.skippedCTs || 0);
|
|
145
|
+
const inferredFailed = Math.max(total - passed - skipped, failed);
|
|
146
|
+
globalPassedCTs += passed;
|
|
147
|
+
globalSkippedCTs += skipped;
|
|
148
|
+
globalFailedCTs += Math.max(inferredFailed, 0);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
Logger.info('⚠️ [CT-AGGREGATION] allCNsData vazio, usando fallback de testesComLogs');
|
|
155
|
+
// Fallback: utilizar dados agregados de testes (quando mapa ainda não está disponível)
|
|
156
|
+
testesComLogs.forEach((teste) => {
|
|
157
|
+
const ctList = Array.isArray(teste.cts)
|
|
158
|
+
? teste.cts
|
|
159
|
+
: [];
|
|
160
|
+
if (ctList.length > 0) {
|
|
161
|
+
aggregateFromCTs(ctList);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const total = Number(teste.totalCTs || 0);
|
|
165
|
+
if (total === 0)
|
|
166
|
+
return;
|
|
167
|
+
globalTotalCTs += total;
|
|
168
|
+
const passed = Number(teste.passedCTs || 0);
|
|
169
|
+
const skipped = Number(teste.skippedCTs || 0);
|
|
170
|
+
const failed = Number(teste.failedCTs || 0);
|
|
171
|
+
const inferredFailed = Math.max(total - passed - skipped, failed);
|
|
172
|
+
globalPassedCTs += passed;
|
|
173
|
+
globalSkippedCTs += skipped;
|
|
174
|
+
globalFailedCTs += Math.max(inferredFailed, 0);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const data = {
|
|
178
|
+
testes: testesComLogs,
|
|
179
|
+
titulo,
|
|
180
|
+
subtitulo,
|
|
181
|
+
totalTestes,
|
|
182
|
+
testesPassaram,
|
|
183
|
+
testesFalharam,
|
|
184
|
+
estatisticasPorTipo,
|
|
185
|
+
coresDosTipos,
|
|
186
|
+
chartLabels: Object.keys(estatisticasPorTipo).filter((tipo) => estatisticasPorTipo[tipo].total > 0),
|
|
187
|
+
chartData: Object.keys(estatisticasPorTipo)
|
|
188
|
+
.filter((tipo) => estatisticasPorTipo[tipo].total > 0)
|
|
189
|
+
.map((tipo) => estatisticasPorTipo[tipo].total),
|
|
190
|
+
chartColors: Object.keys(estatisticasPorTipo)
|
|
191
|
+
.filter((tipo) => estatisticasPorTipo[tipo].total > 0)
|
|
192
|
+
.map((tipo) => coresDosTipos[tipo]),
|
|
193
|
+
barLabels: testesComLogs.map((t) => t.nome),
|
|
194
|
+
barData: testesComLogs.map((t) => t.duracao),
|
|
195
|
+
pieLabels: ['Passou', 'Falhou'],
|
|
196
|
+
pieData: [testesPassaram, testesFalharam],
|
|
197
|
+
logsLabels: testesComLogs.map((t) => t.nome),
|
|
198
|
+
logsData: testesComLogs.map((t) => Array.isArray(t.logs) ? t.logs.length : 0),
|
|
199
|
+
getIconePorTipo: UnifiedHtmlGenerator.getIconePorTipo,
|
|
200
|
+
projectName: projName,
|
|
201
|
+
environment: env,
|
|
202
|
+
executionDate: new Date().toLocaleString('pt-BR'),
|
|
203
|
+
autocoreVersion: version,
|
|
204
|
+
terminalLogs, // ✅ NOVO: Logs do terminal
|
|
205
|
+
allCNsData, // 🆕 CRÍTICO: Dados dos CTs do StatementTracker
|
|
206
|
+
globalTotalCTs,
|
|
207
|
+
globalPassedCTs,
|
|
208
|
+
globalFailedCTs,
|
|
209
|
+
globalSkippedCTs,
|
|
210
|
+
};
|
|
211
|
+
const html = HTMLTemplate(data);
|
|
212
|
+
return Buffer.from(html, 'utf-8');
|
|
213
|
+
}
|
|
214
|
+
static calcularEstatisticasPorTipo(testes) {
|
|
215
|
+
const tipos = [
|
|
216
|
+
'API',
|
|
217
|
+
'Frontend',
|
|
218
|
+
'Mobile',
|
|
219
|
+
'SSH',
|
|
220
|
+
'Banco',
|
|
221
|
+
'Mixed',
|
|
222
|
+
'Scenarios',
|
|
223
|
+
];
|
|
224
|
+
const stats = {};
|
|
225
|
+
// Inicializa todos os tipos com zero
|
|
226
|
+
for (const tipo of tipos) {
|
|
227
|
+
stats[tipo] = { total: 0, passou: 0, falhou: 0 };
|
|
228
|
+
}
|
|
229
|
+
for (const teste of testes) {
|
|
230
|
+
if (!stats[teste.tipo]) {
|
|
231
|
+
stats[teste.tipo] = { total: 0, passou: 0, falhou: 0 };
|
|
232
|
+
}
|
|
233
|
+
stats[teste.tipo].total++;
|
|
234
|
+
if (teste.resultado === 'PASS')
|
|
235
|
+
stats[teste.tipo].passou++;
|
|
236
|
+
else
|
|
237
|
+
stats[teste.tipo].falhou++;
|
|
238
|
+
}
|
|
239
|
+
return stats;
|
|
240
|
+
}
|
|
241
|
+
static getCoresDosTipos() {
|
|
242
|
+
return {
|
|
243
|
+
API: '#3b82f6',
|
|
244
|
+
Frontend: '#10b981',
|
|
245
|
+
Mobile: '#f59e0b',
|
|
246
|
+
SSH: '#ef4444',
|
|
247
|
+
Banco: '#8b5cf6',
|
|
248
|
+
Mixed: '#6b7280',
|
|
249
|
+
Scenarios: '#6366f1',
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
static getIconePorTipo(tipo) {
|
|
253
|
+
const icones = {
|
|
254
|
+
API: '🔌',
|
|
255
|
+
Frontend: '🌐',
|
|
256
|
+
Mobile: '📱',
|
|
257
|
+
SSH: '🔧',
|
|
258
|
+
Banco: '🗄️',
|
|
259
|
+
Mixed: '🔀',
|
|
260
|
+
Scenarios: '📋',
|
|
261
|
+
};
|
|
262
|
+
return icones[tipo];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
export type TestContextType = 'API' | 'Frontend' | 'Mobile' | 'SSH' | 'Banco' | 'Mixed' | 'Scenarios';
|
|
2
|
+
/**
|
|
3
|
+
* 🆕 CT Individual (Cenário de Teste)
|
|
4
|
+
*/
|
|
5
|
+
export interface CTExecution {
|
|
6
|
+
ctId: string;
|
|
7
|
+
ctName: string;
|
|
8
|
+
ctOrder: number;
|
|
9
|
+
status: 'running' | 'passed' | 'failed' | 'skipped';
|
|
10
|
+
duration: number;
|
|
11
|
+
timestamp: Date;
|
|
12
|
+
error?: string;
|
|
13
|
+
className: string;
|
|
14
|
+
methodName: string;
|
|
15
|
+
}
|
|
16
|
+
export interface TestResult {
|
|
17
|
+
nome: string;
|
|
18
|
+
resultado: 'PASS' | 'FAIL';
|
|
19
|
+
tipo: TestContextType;
|
|
20
|
+
duracao: number;
|
|
21
|
+
logs: string[];
|
|
22
|
+
timestamp: Date;
|
|
23
|
+
metadata?: {
|
|
24
|
+
requests?: number;
|
|
25
|
+
validations?: number;
|
|
26
|
+
screenshots?: number;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
cts?: CTExecution[];
|
|
30
|
+
totalCTs?: number;
|
|
31
|
+
passedCTs?: number;
|
|
32
|
+
failedCTs?: number;
|
|
33
|
+
skippedCTs?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface UnifiedMetrics {
|
|
36
|
+
totalTestes: number;
|
|
37
|
+
testesPorTipo: Record<TestContextType, number>;
|
|
38
|
+
resultadosPorTipo: Record<TestContextType, {
|
|
39
|
+
passou: number;
|
|
40
|
+
falhou: number;
|
|
41
|
+
}>;
|
|
42
|
+
inicio: Date | null;
|
|
43
|
+
fim: Date | null;
|
|
44
|
+
duracao: number;
|
|
45
|
+
testes: TestResult[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* ✅ Interface para dados globais dos testes
|
|
49
|
+
*/
|
|
50
|
+
interface TestData {
|
|
51
|
+
nome: string;
|
|
52
|
+
tipo: TestContextType;
|
|
53
|
+
inicio: Date;
|
|
54
|
+
fim: Date | null;
|
|
55
|
+
duracao: number;
|
|
56
|
+
status: 'running' | 'passed' | 'failed' | 'skipped';
|
|
57
|
+
logs: string[];
|
|
58
|
+
screenshots: string[];
|
|
59
|
+
dados: any;
|
|
60
|
+
cts?: any[];
|
|
61
|
+
}
|
|
62
|
+
type FinalizeTestOptions = {
|
|
63
|
+
cnName?: string;
|
|
64
|
+
ctName?: string;
|
|
65
|
+
errorMessage?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Gerenciador unificado de relatórios para todos os tipos de teste
|
|
69
|
+
*/
|
|
70
|
+
export declare class UnifiedReportManager {
|
|
71
|
+
private static inicioExecucao;
|
|
72
|
+
private static fimExecucao;
|
|
73
|
+
private static testes;
|
|
74
|
+
private static contextoPorTeste;
|
|
75
|
+
private static logsPorTeste;
|
|
76
|
+
private static metadataPorTeste;
|
|
77
|
+
private static duracoesPorTeste;
|
|
78
|
+
private static ctToCnMap;
|
|
79
|
+
/**
|
|
80
|
+
* ✅ Dados globais estruturados
|
|
81
|
+
*/
|
|
82
|
+
private static dadosGlobais;
|
|
83
|
+
/**
|
|
84
|
+
* ✅ NOVO: Sistema de detecção automática
|
|
85
|
+
*/
|
|
86
|
+
private static autoDetectionActive;
|
|
87
|
+
private static currentTestName;
|
|
88
|
+
private static testStartTime;
|
|
89
|
+
private static monitoringInterval;
|
|
90
|
+
/**
|
|
91
|
+
* Registra relacionamento entre CT (test.title) e CN (test.describe)
|
|
92
|
+
*/
|
|
93
|
+
static registrarCtParaCn(ctName: string, cnName: string): void;
|
|
94
|
+
private static obterCnRegistrado;
|
|
95
|
+
private static limparRegistroCt;
|
|
96
|
+
/**
|
|
97
|
+
* ❌ DESABILITADO: Auto-inicialização que causava registro duplicado
|
|
98
|
+
* O registro correto já é feito via TestAnnotations.Api/SSH/Banco/etc
|
|
99
|
+
*/
|
|
100
|
+
private static autoInit;
|
|
101
|
+
/**
|
|
102
|
+
* ✅ NOVO: Monitoramento automático de mudanças de teste
|
|
103
|
+
*/
|
|
104
|
+
private static iniciarMonitoramentoAutomatico;
|
|
105
|
+
/**
|
|
106
|
+
* ✅ NOVO: Interceptar TestContext para detectar mudanças automaticamente
|
|
107
|
+
*/
|
|
108
|
+
private static interceptarTestContext;
|
|
109
|
+
/**
|
|
110
|
+
* ✅ NOVO: Detectar novo teste automaticamente
|
|
111
|
+
*/
|
|
112
|
+
private static detectarNovoTeste;
|
|
113
|
+
/**
|
|
114
|
+
* ✅ NOVO: Iniciar teste automaticamente
|
|
115
|
+
*/
|
|
116
|
+
private static iniciarTesteAutomatico;
|
|
117
|
+
/**
|
|
118
|
+
* ✅ NOVO: Finalizar teste automaticamente
|
|
119
|
+
*/
|
|
120
|
+
private static finalizarTesteAutomatico;
|
|
121
|
+
static setTestContext(testeName: string, contexto: TestContextType): void;
|
|
122
|
+
static iniciarTeste(testeName: string, contexto?: TestContextType): void;
|
|
123
|
+
static registrarInicioExecucao(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Registra informações do ambiente CI (Azure Pipelines, GitHub Actions, etc)
|
|
126
|
+
* e as anexa como metadados globais para o relatório.
|
|
127
|
+
*/
|
|
128
|
+
static registrarCIInfo(): void;
|
|
129
|
+
static registrarFimExecucao(): void;
|
|
130
|
+
/**
|
|
131
|
+
* ✅ NOVO: Registra explicitamente um teste no sistema
|
|
132
|
+
*/
|
|
133
|
+
static registrarTeste(testName: string, contextType: TestContextType): void;
|
|
134
|
+
/**
|
|
135
|
+
* 🆕 HELPER: Obter o nome correto do CN (test.describe) do TestInfo
|
|
136
|
+
*/
|
|
137
|
+
private static getCNNameFromTestInfo;
|
|
138
|
+
/**
|
|
139
|
+
* ✅ NOVO: Marca explicitamente o fim de um teste
|
|
140
|
+
*/
|
|
141
|
+
static marcarFimTeste(testName: string, status: 'passed' | 'failed' | 'skipped', options?: FinalizeTestOptions): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* ✅ NOVO: Corrige status dos CTs quando teste PASSA
|
|
144
|
+
* Marca todos os CTs "running" do teste como "passed"
|
|
145
|
+
*/
|
|
146
|
+
private static corrigirStatusCTsQuandoTestePassou;
|
|
147
|
+
/**
|
|
148
|
+
* ✅ NOVO: Corrige status dos CTs quando teste FALHA
|
|
149
|
+
* Marca todos os CTs "running" do teste como "failed"
|
|
150
|
+
*/
|
|
151
|
+
private static corrigirStatusCTsQuandoTesteFalha;
|
|
152
|
+
static coletarDadosDoTeste(testeName?: string): Promise<any>;
|
|
153
|
+
static adicionarLog(testeName: string, message: string): void;
|
|
154
|
+
static setTestMetadata(testeName: string, metadata: any): void;
|
|
155
|
+
static setTestDuration(testeName: string, duracao: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* ✅ NOVO: Obter logs de um teste específico
|
|
158
|
+
*/
|
|
159
|
+
static getTestLogs(testName: string): string[];
|
|
160
|
+
static anexarRelatorioIndividual(): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* ✅ CORRIGIDO: Anexa relatório geral unificado
|
|
163
|
+
*/
|
|
164
|
+
static anexarRelatorioGeral(): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* 🔍 DEBUG: Método para acessar dados globais
|
|
167
|
+
*/
|
|
168
|
+
static getDadosGlobais(): {
|
|
169
|
+
totalTestes: number;
|
|
170
|
+
testesPassados: number;
|
|
171
|
+
testesFalharam: number;
|
|
172
|
+
testes: Record<string, TestData>;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* ✅ ÚNICO: Método getMetrics unificado
|
|
176
|
+
*/
|
|
177
|
+
static getMetrics(): UnifiedMetrics;
|
|
178
|
+
static reset(): void;
|
|
179
|
+
static finalizarTeste(testName?: string, status?: 'passed' | 'failed' | 'skipped'): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* ✅ NOVO: Interceptar e registrar erros de teste automaticamente
|
|
182
|
+
* @param testName Nome do teste
|
|
183
|
+
* @param error Erro capturado
|
|
184
|
+
*/
|
|
185
|
+
static registrarErroTeste(testName: string, error: Error | string): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* ✅ NOVO: Configurar interceptação global de erros para testes AutoCore
|
|
188
|
+
*/
|
|
189
|
+
static configurarInterceptacaoErros(): void;
|
|
190
|
+
/**
|
|
191
|
+
* ✅ NOVO: Interceptar logs do console para detectar ações automaticamente
|
|
192
|
+
*/
|
|
193
|
+
private static interceptarConsole;
|
|
194
|
+
/**
|
|
195
|
+
* ✅ NOVO: Adiciona um CT ao teste
|
|
196
|
+
*/
|
|
197
|
+
static adicionarCT(testName: string, ct: any): void;
|
|
198
|
+
/**
|
|
199
|
+
* ✅ NOVO: Gera o relatório unificado final
|
|
200
|
+
*/
|
|
201
|
+
static gerarRelatorioUnificado(): Promise<string>;
|
|
202
|
+
/**
|
|
203
|
+
* ✅ HELPER: Calcula duração total
|
|
204
|
+
*/
|
|
205
|
+
private static calcularDuracaoTotal;
|
|
206
|
+
/**
|
|
207
|
+
* ✅ HELPER: Pega contextos únicos
|
|
208
|
+
*/
|
|
209
|
+
private static getContextosUnicos;
|
|
210
|
+
}
|
|
211
|
+
export {};
|