@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,611 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Gerenciador de logs de configuração para Playwright
|
|
6
|
+
* Fornece informações detalhadas sobre configurações e ambiente
|
|
7
|
+
* ATUALIZADO: Integrado com a nova arquitetura unificada
|
|
8
|
+
*/
|
|
9
|
+
export class ConfigLogger {
|
|
10
|
+
static logFile = null;
|
|
11
|
+
static projectName = 'Projeto desconhecido';
|
|
12
|
+
static logToFile = false;
|
|
13
|
+
static initialized = false;
|
|
14
|
+
static startTime = new Date();
|
|
15
|
+
/**
|
|
16
|
+
* Inicializa o logger de configurações
|
|
17
|
+
* @param options Opções de inicialização
|
|
18
|
+
*/
|
|
19
|
+
static init(options = {}) {
|
|
20
|
+
if (ConfigLogger.initialized || ConfigLogger.hasRunBefore())
|
|
21
|
+
return;
|
|
22
|
+
ConfigLogger.startTime = new Date();
|
|
23
|
+
ConfigLogger.projectName =
|
|
24
|
+
options.projectName || ConfigLogger.getProjectNameFromPackageJson();
|
|
25
|
+
ConfigLogger.logToFile = options.logToFile ?? false;
|
|
26
|
+
if (ConfigLogger.logToFile) {
|
|
27
|
+
const logDir = options.logDir || path.join(process.cwd(), 'logs');
|
|
28
|
+
if (!fs.existsSync(logDir)) {
|
|
29
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
32
|
+
ConfigLogger.logFile = path.join(logDir, `config-${timestamp}.log`);
|
|
33
|
+
}
|
|
34
|
+
ConfigLogger.initialized = true;
|
|
35
|
+
ConfigLogger.markAsRun();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Obtém o nome do projeto do package.json
|
|
39
|
+
*/
|
|
40
|
+
static getProjectNameFromPackageJson() {
|
|
41
|
+
try {
|
|
42
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
43
|
+
if (fs.existsSync(packagePath)) {
|
|
44
|
+
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
|
|
45
|
+
return packageJson.name || 'Projeto desconhecido';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
ConfigLogger.warning('Não foi possível ler o package.json');
|
|
50
|
+
}
|
|
51
|
+
return 'Projeto desconhecido';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Escreve no arquivo de log
|
|
55
|
+
*/
|
|
56
|
+
static appendToLogFile(message) {
|
|
57
|
+
if (!ConfigLogger.logFile)
|
|
58
|
+
return;
|
|
59
|
+
try {
|
|
60
|
+
const timestamp = new Date().toISOString();
|
|
61
|
+
fs.appendFileSync(ConfigLogger.logFile, `[${timestamp}] ${message}\n`);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('Erro ao escrever no arquivo de log:', error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Registra log informativo
|
|
69
|
+
*/
|
|
70
|
+
static info(message) {
|
|
71
|
+
console.log(`ℹ️ ${message}`);
|
|
72
|
+
if (ConfigLogger.logToFile) {
|
|
73
|
+
ConfigLogger.appendToLogFile(`INFO: ${message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Registra log de sucesso
|
|
78
|
+
*/
|
|
79
|
+
static success(message) {
|
|
80
|
+
console.log(`✅ ${message}`);
|
|
81
|
+
if (ConfigLogger.logToFile) {
|
|
82
|
+
ConfigLogger.appendToLogFile(`SUCCESS: ${message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Registra log de aviso
|
|
87
|
+
*/
|
|
88
|
+
static warning(message) {
|
|
89
|
+
console.warn(`⚠️ ${message}`);
|
|
90
|
+
if (ConfigLogger.logToFile) {
|
|
91
|
+
ConfigLogger.appendToLogFile(`WARNING: ${message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Registra log de erro
|
|
96
|
+
*/
|
|
97
|
+
static error(message, error) {
|
|
98
|
+
console.error(`❌ ${message}`);
|
|
99
|
+
if (error) {
|
|
100
|
+
console.error(error);
|
|
101
|
+
}
|
|
102
|
+
if (ConfigLogger.logToFile) {
|
|
103
|
+
ConfigLogger.appendToLogFile(`ERROR: ${message} ${error ? `\n${error.stack || error}` : ''}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Registra log crítico (erro grave que pode impedir a execução)
|
|
108
|
+
*/
|
|
109
|
+
static critical(message, error) {
|
|
110
|
+
console.error(`🔥 CRÍTICO: ${message}`);
|
|
111
|
+
if (error) {
|
|
112
|
+
console.error(error);
|
|
113
|
+
}
|
|
114
|
+
if (ConfigLogger.logToFile) {
|
|
115
|
+
ConfigLogger.appendToLogFile(`CRITICAL: ${message} ${error ? `\n${error.stack || error}` : ''}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Registra resumo da configuração do ambiente
|
|
120
|
+
*/
|
|
121
|
+
static logEnvironmentConfig() {
|
|
122
|
+
ConfigLogger.info('=== Configuração do Ambiente ===');
|
|
123
|
+
// Informações do sistema e runtime
|
|
124
|
+
ConfigLogger.info(`Node.js: ${process.version}`);
|
|
125
|
+
ConfigLogger.info(`Sistema operacional: ${process.platform} ${os.release()} (${process.arch})`);
|
|
126
|
+
ConfigLogger.info(`Memória total: ${Math.round(os.totalmem() / (1024 * 1024 * 1024))}GB`);
|
|
127
|
+
ConfigLogger.info(`Memória disponível: ${Math.round(os.freemem() / (1024 * 1024 * 1024))}GB`);
|
|
128
|
+
ConfigLogger.info(`CPUs: ${os.cpus().length} núcleos`);
|
|
129
|
+
ConfigLogger.info(`Usuário: ${os.userInfo().username}`);
|
|
130
|
+
ConfigLogger.info(`Nome da máquina: ${os.hostname()}`);
|
|
131
|
+
// Verificar variáveis de ambiente do CI
|
|
132
|
+
const isCi = process.env.CI === 'true' || process.env.TF_BUILD === 'true';
|
|
133
|
+
if (isCi) {
|
|
134
|
+
ConfigLogger.info('Executando em ambiente de CI/CD');
|
|
135
|
+
if (process.env.GITHUB_ACTIONS) {
|
|
136
|
+
ConfigLogger.info('CI: GitHub Actions');
|
|
137
|
+
}
|
|
138
|
+
else if (process.env.TF_BUILD) {
|
|
139
|
+
ConfigLogger.info('CI: Azure DevOps');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Registra variáveis de ambiente relevantes para o projeto
|
|
145
|
+
*/
|
|
146
|
+
static logEnvironmentVariables() {
|
|
147
|
+
ConfigLogger.info('Variáveis de ambiente relevantes:');
|
|
148
|
+
const relevantVars = [
|
|
149
|
+
'NODE_ENV',
|
|
150
|
+
'ENV',
|
|
151
|
+
'CI',
|
|
152
|
+
'DEBUG',
|
|
153
|
+
'PROJECT_TYPE',
|
|
154
|
+
'BASE_URL',
|
|
155
|
+
'API_URL',
|
|
156
|
+
'TEST_ENV',
|
|
157
|
+
'USE_MOBILE',
|
|
158
|
+
];
|
|
159
|
+
const apiVars = Object.keys(process.env)
|
|
160
|
+
.filter((key) => key.startsWith('BASE_URL_'))
|
|
161
|
+
.sort();
|
|
162
|
+
relevantVars.push(...apiVars);
|
|
163
|
+
// Log das variáveis encontradas
|
|
164
|
+
const foundVars = relevantVars.filter((varName) => process.env[varName]);
|
|
165
|
+
foundVars.forEach((varName) => {
|
|
166
|
+
const value = process.env[varName];
|
|
167
|
+
// Mascarar possíveis tokens/senhas
|
|
168
|
+
const maskedValue = varName.toLowerCase().includes('token') ||
|
|
169
|
+
varName.toLowerCase().includes('password') ||
|
|
170
|
+
varName.toLowerCase().includes('secret')
|
|
171
|
+
? '***masked***'
|
|
172
|
+
: value;
|
|
173
|
+
ConfigLogger.info(` ${varName}: ${maskedValue}`);
|
|
174
|
+
});
|
|
175
|
+
// Se encontrou variáveis de API, fazer seção separada
|
|
176
|
+
const apiBaseVars = apiVars.filter((varName) => process.env[varName]);
|
|
177
|
+
if (apiBaseVars.length > 0) {
|
|
178
|
+
ConfigLogger.info('API configurada:');
|
|
179
|
+
apiBaseVars.forEach((varName) => {
|
|
180
|
+
ConfigLogger.info(` ${varName}: ${process.env[varName]}`);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// NOVO: Log de variáveis por tipo de projeto
|
|
184
|
+
const projectType = process.env.PROJECT_TYPE;
|
|
185
|
+
if (projectType) {
|
|
186
|
+
ConfigLogger.info(`Variáveis específicas para projeto ${projectType}:`);
|
|
187
|
+
switch (projectType) {
|
|
188
|
+
case 'Mobile':
|
|
189
|
+
ConfigLogger.logMobileVariables();
|
|
190
|
+
break;
|
|
191
|
+
case 'SSH':
|
|
192
|
+
ConfigLogger.logSSHVariables();
|
|
193
|
+
break;
|
|
194
|
+
case 'Banco':
|
|
195
|
+
ConfigLogger.logDatabaseVariables();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* NOVO: Log específico para variáveis Mobile
|
|
202
|
+
*/
|
|
203
|
+
static logMobileVariables() {
|
|
204
|
+
const mobileVars = [
|
|
205
|
+
'USE_MOBILE',
|
|
206
|
+
'DEVICE_NAME',
|
|
207
|
+
'PLATFORM_NAME',
|
|
208
|
+
'PLATFORM_VERSION',
|
|
209
|
+
'APP_PACKAGE',
|
|
210
|
+
];
|
|
211
|
+
mobileVars.forEach((varName) => {
|
|
212
|
+
if (process.env[varName]) {
|
|
213
|
+
ConfigLogger.info(` ${varName}: ${process.env[varName]}`);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* NOVO: Log específico para variáveis SSH
|
|
219
|
+
*/
|
|
220
|
+
static logSSHVariables() {
|
|
221
|
+
const sshVars = ['SSH_HOST', 'SSH_PORT', 'SSH_USER'];
|
|
222
|
+
sshVars.forEach((varName) => {
|
|
223
|
+
if (process.env[varName]) {
|
|
224
|
+
const value = varName.includes('PASS') || varName.includes('KEY')
|
|
225
|
+
? '***masked***'
|
|
226
|
+
: process.env[varName];
|
|
227
|
+
ConfigLogger.info(` ${varName}: ${value}`);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* NOVO: Log específico para variáveis de Banco
|
|
233
|
+
*/
|
|
234
|
+
static logDatabaseVariables() {
|
|
235
|
+
const dbVars = ['DB_HOST', 'DB_PORT', 'DB_SERVICE', 'DB_USER'];
|
|
236
|
+
dbVars.forEach((varName) => {
|
|
237
|
+
if (process.env[varName]) {
|
|
238
|
+
const value = varName.includes('PASS')
|
|
239
|
+
? '***masked***'
|
|
240
|
+
: process.env[varName];
|
|
241
|
+
ConfigLogger.info(` ${varName}: ${value}`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Retorna o caminho do arquivo de lock usado para evitar inicialização múltipla
|
|
247
|
+
*/
|
|
248
|
+
static getLockFilePath() {
|
|
249
|
+
return path.join(process.cwd(), '.configlogger.lock');
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Verifica se o ConfigLogger já foi executado antes (evita inicialização múltipla)
|
|
253
|
+
*/
|
|
254
|
+
static hasRunBefore() {
|
|
255
|
+
return fs.existsSync(ConfigLogger.getLockFilePath());
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Marca o ConfigLogger como já inicializado
|
|
259
|
+
*/
|
|
260
|
+
static markAsRun() {
|
|
261
|
+
try {
|
|
262
|
+
fs.writeFileSync(ConfigLogger.getLockFilePath(), ConfigLogger.startTime.toISOString());
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
ConfigLogger.warning('Não foi possível criar arquivo de lock');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Limpa o estado e arquivos temporários do ConfigLogger
|
|
270
|
+
*/
|
|
271
|
+
static cleanup() {
|
|
272
|
+
try {
|
|
273
|
+
const lockFile = ConfigLogger.getLockFilePath();
|
|
274
|
+
if (fs.existsSync(lockFile)) {
|
|
275
|
+
fs.unlinkSync(lockFile);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
ConfigLogger.warning('Erro ao limpar arquivos temporários do ConfigLogger');
|
|
280
|
+
}
|
|
281
|
+
ConfigLogger.initialized = false;
|
|
282
|
+
ConfigLogger.logFile = null;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Registra informações sobre o Playwright (versão otimizada)
|
|
286
|
+
*/
|
|
287
|
+
static logPlaywrightConfig() {
|
|
288
|
+
if (!ConfigLogger.initialized) {
|
|
289
|
+
ConfigLogger.warning('ConfigLogger não foi inicializado antes de chamar logPlaywrightConfig');
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
ConfigLogger.info('=== Configuração do Playwright ===');
|
|
293
|
+
try {
|
|
294
|
+
const configInfo = ConfigLogger.readPlaywrightConfigFile();
|
|
295
|
+
if (configInfo.found) {
|
|
296
|
+
ConfigLogger.success(`Configuração encontrada: ${configInfo.filename}`);
|
|
297
|
+
// Mostrar informações extraídas do arquivo
|
|
298
|
+
if (configInfo.testDir) {
|
|
299
|
+
ConfigLogger.info(`Diretório de testes: ${configInfo.testDir}`);
|
|
300
|
+
}
|
|
301
|
+
if (configInfo.testMatch && configInfo.testMatch.length > 0) {
|
|
302
|
+
ConfigLogger.info(`Padrões de teste: ${configInfo.testMatch.join(', ')}`);
|
|
303
|
+
}
|
|
304
|
+
if (configInfo.timeout) {
|
|
305
|
+
ConfigLogger.info(`Timeout global: ${configInfo.timeout}ms`);
|
|
306
|
+
}
|
|
307
|
+
if (configInfo.expectTimeout) {
|
|
308
|
+
ConfigLogger.info(`Timeout de expectativas: ${configInfo.expectTimeout}ms`);
|
|
309
|
+
}
|
|
310
|
+
if (configInfo.workers !== undefined) {
|
|
311
|
+
ConfigLogger.info(`Workers: ${configInfo.workers === undefined ? 'automático' : configInfo.workers}`);
|
|
312
|
+
}
|
|
313
|
+
if (configInfo.retries !== undefined) {
|
|
314
|
+
ConfigLogger.info(`Retries: ${configInfo.retries}`);
|
|
315
|
+
}
|
|
316
|
+
if (configInfo.reporters && configInfo.reporters.length > 0) {
|
|
317
|
+
ConfigLogger.info(`Reporters: ${configInfo.reporters.join(', ')}`);
|
|
318
|
+
}
|
|
319
|
+
if (configInfo.projects !== undefined) {
|
|
320
|
+
ConfigLogger.info(`Projetos configurados: ${configInfo.projects}`);
|
|
321
|
+
}
|
|
322
|
+
if (configInfo.globalSetup) {
|
|
323
|
+
ConfigLogger.info(`Global Setup: ${configInfo.globalSetup}`);
|
|
324
|
+
}
|
|
325
|
+
if (configInfo.globalTeardown) {
|
|
326
|
+
ConfigLogger.info(`Global Teardown: ${configInfo.globalTeardown}`);
|
|
327
|
+
}
|
|
328
|
+
if (configInfo.baseURL) {
|
|
329
|
+
ConfigLogger.info(`URL Base: ${configInfo.baseURL}`);
|
|
330
|
+
}
|
|
331
|
+
if (configInfo.trace) {
|
|
332
|
+
ConfigLogger.info(`Trace: ${configInfo.trace}`);
|
|
333
|
+
}
|
|
334
|
+
if (configInfo.fullyParallel !== undefined) {
|
|
335
|
+
ConfigLogger.info(`Execução paralela: ${configInfo.fullyParallel ? 'habilitada' : 'desabilitada'}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
ConfigLogger.warning('Nenhum arquivo de configuração do Playwright encontrado');
|
|
340
|
+
ConfigLogger.info('Usando configurações padrão do Playwright');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
ConfigLogger.error('Erro ao ler configuração do Playwright', error);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Lê e extrai informações do arquivo de configuração do Playwright
|
|
349
|
+
* sem executar comandos externos (apenas parsing de texto)
|
|
350
|
+
*/
|
|
351
|
+
static readPlaywrightConfigFile() {
|
|
352
|
+
const configFiles = [
|
|
353
|
+
'playwright.config.ts',
|
|
354
|
+
'playwright.config.js',
|
|
355
|
+
'.playwright.config.ts',
|
|
356
|
+
'.playwright.config.js',
|
|
357
|
+
];
|
|
358
|
+
for (const filename of configFiles) {
|
|
359
|
+
const configPath = path.resolve(process.cwd(), filename);
|
|
360
|
+
if (fs.existsSync(configPath)) {
|
|
361
|
+
try {
|
|
362
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
363
|
+
const parsed = ConfigLogger.parseConfigContent(content);
|
|
364
|
+
return {
|
|
365
|
+
found: true,
|
|
366
|
+
filename,
|
|
367
|
+
...parsed,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
ConfigLogger.warning(`Erro ao ler ${filename}: ${error instanceof Error ? error.message : String(error)}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return { found: false };
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Extrai informações de configuração do conteúdo do arquivo usando regex
|
|
379
|
+
* (parsing simples sem executar código)
|
|
380
|
+
*/
|
|
381
|
+
static parseConfigContent(content) {
|
|
382
|
+
const result = {};
|
|
383
|
+
// Remove comentários e quebras de linha para facilitar parsing
|
|
384
|
+
const cleanContent = content
|
|
385
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove comentários /* */
|
|
386
|
+
.replace(/\/\/.*$/gm, '') // Remove comentários //
|
|
387
|
+
.replace(/\s+/g, ' ') // Normaliza espaços
|
|
388
|
+
.trim();
|
|
389
|
+
// Extrair testDir
|
|
390
|
+
const testDirMatch = cleanContent.match(/testDir:\s*['"`]([^'"`]+)['"`]/);
|
|
391
|
+
if (testDirMatch) {
|
|
392
|
+
result.testDir = testDirMatch[1];
|
|
393
|
+
}
|
|
394
|
+
// Extrair testMatch
|
|
395
|
+
const testMatchMatch = cleanContent.match(/testMatch:\s*\[(.*?)\]/);
|
|
396
|
+
if (testMatchMatch) {
|
|
397
|
+
const matches = testMatchMatch[1].match(/['"`]([^'"`]+)['"`]/g);
|
|
398
|
+
if (matches) {
|
|
399
|
+
result.testMatch = matches.map((m) => m.replace(/['"`]/g, ''));
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// Extrair timeout
|
|
403
|
+
const timeoutMatch = cleanContent.match(/timeout:\s*(\d+)/);
|
|
404
|
+
if (timeoutMatch) {
|
|
405
|
+
result.timeout = Number.parseInt(timeoutMatch[1]);
|
|
406
|
+
}
|
|
407
|
+
// Extrair expect timeout
|
|
408
|
+
const expectTimeoutMatch = cleanContent.match(/expect:\s*{[^}]*timeout:\s*(\d+)/);
|
|
409
|
+
if (expectTimeoutMatch) {
|
|
410
|
+
result.expectTimeout = Number.parseInt(expectTimeoutMatch[1]);
|
|
411
|
+
}
|
|
412
|
+
// Extrair workers
|
|
413
|
+
const workersMatch = cleanContent.match(/workers:\s*(?:process\.env\.CI\s*\?\s*(\d+)\s*:\s*(\d+)|(\d+))/);
|
|
414
|
+
if (workersMatch) {
|
|
415
|
+
result.workers = Number.parseInt(workersMatch[3] || workersMatch[2] || workersMatch[1]);
|
|
416
|
+
}
|
|
417
|
+
// Extrair retries
|
|
418
|
+
const retriesMatch = cleanContent.match(/retries:\s*(?:process\.env\.CI\s*\?\s*(\d+)\s*:\s*(\d+)|(\d+))/);
|
|
419
|
+
if (retriesMatch) {
|
|
420
|
+
result.retries = Number.parseInt(retriesMatch[3] || retriesMatch[2] || retriesMatch[1]);
|
|
421
|
+
}
|
|
422
|
+
// Extrair reporters - ATUALIZADO: detecta CustomReporter
|
|
423
|
+
const reporterMatch = cleanContent.match(/reporter:\s*\[(.*?)\]/);
|
|
424
|
+
if (reporterMatch) {
|
|
425
|
+
const reporters = reporterMatch[1].match(/['"`]([^'"`]+)['"`]/g);
|
|
426
|
+
if (reporters) {
|
|
427
|
+
result.reporters = reporters.map((r) => r.replace(/['"`]/g, ''));
|
|
428
|
+
}
|
|
429
|
+
// NOVO: Detectar se está usando o CustomReporter
|
|
430
|
+
if (reporterMatch[1].includes('CustomReporter') ||
|
|
431
|
+
reporterMatch[1].includes('@silasfmartins/testhub/reporter')) {
|
|
432
|
+
result.reporters = result.reporters || [];
|
|
433
|
+
if (!result.reporters.includes('CustomReporter')) {
|
|
434
|
+
result.reporters.push('CustomReporter (Unificado)');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// Contar projetos
|
|
439
|
+
const projectsMatch = cleanContent.match(/projects:\s*\[(.*?)\]/);
|
|
440
|
+
if (projectsMatch) {
|
|
441
|
+
const projectCount = (projectsMatch[1].match(/{/g) || []).length;
|
|
442
|
+
result.projects = projectCount;
|
|
443
|
+
}
|
|
444
|
+
// Extrair globalSetup
|
|
445
|
+
const globalSetupMatch = cleanContent.match(/globalSetup:\s*['"`]([^'"`]+)['"`]/);
|
|
446
|
+
if (globalSetupMatch) {
|
|
447
|
+
result.globalSetup = globalSetupMatch[1];
|
|
448
|
+
}
|
|
449
|
+
// Extrair globalTeardown
|
|
450
|
+
const globalTeardownMatch = cleanContent.match(/globalTeardown:\s*['"`]([^'"`]+)['"`]/);
|
|
451
|
+
if (globalTeardownMatch) {
|
|
452
|
+
result.globalTeardown = globalTeardownMatch[1];
|
|
453
|
+
}
|
|
454
|
+
// Extrair baseURL da seção use
|
|
455
|
+
const baseURLMatch = cleanContent.match(/use:\s*{[^}]*baseURL:\s*(?:process\.env\.[\w_]+\s*\|\|\s*)?['"`]([^'"`]+)['"`]/);
|
|
456
|
+
if (baseURLMatch) {
|
|
457
|
+
result.baseURL = baseURLMatch[1];
|
|
458
|
+
}
|
|
459
|
+
// Extrair trace
|
|
460
|
+
const traceMatch = cleanContent.match(/trace:\s*['"`]([^'"`]+)['"`]/);
|
|
461
|
+
if (traceMatch) {
|
|
462
|
+
result.trace = traceMatch[1];
|
|
463
|
+
}
|
|
464
|
+
// Extrair fullyParallel
|
|
465
|
+
const fullyParallelMatch = cleanContent.match(/fullyParallel:\s*(true|false)/);
|
|
466
|
+
if (fullyParallelMatch) {
|
|
467
|
+
result.fullyParallel = fullyParallelMatch[1] === 'true';
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* NOVO: Gera relatório de configuração do projeto
|
|
473
|
+
*/
|
|
474
|
+
static generateProjectReport() {
|
|
475
|
+
const projectType = process.env.PROJECT_TYPE;
|
|
476
|
+
const environment = process.env.NODE_ENV || process.env.ENV;
|
|
477
|
+
const configuredFeatures = [];
|
|
478
|
+
const missingFeatures = [];
|
|
479
|
+
// Verificar recursos configurados
|
|
480
|
+
if (process.env.BASE_URL)
|
|
481
|
+
configuredFeatures.push('Frontend Base URL');
|
|
482
|
+
if (Object.keys(process.env).some((key) => key.startsWith('BASE_URL_')))
|
|
483
|
+
configuredFeatures.push('API URLs');
|
|
484
|
+
if (process.env.USE_MOBILE === 'true')
|
|
485
|
+
configuredFeatures.push('Mobile Testing');
|
|
486
|
+
if (process.env.SSH_HOST)
|
|
487
|
+
configuredFeatures.push('SSH Testing');
|
|
488
|
+
if (process.env.DB_HOST)
|
|
489
|
+
configuredFeatures.push('Database Testing');
|
|
490
|
+
// Verificar recursos em falta baseado no tipo de projeto
|
|
491
|
+
if (projectType === 'Frontend' && !process.env.BASE_URL)
|
|
492
|
+
missingFeatures.push('Frontend Base URL');
|
|
493
|
+
if (projectType === 'API' &&
|
|
494
|
+
!Object.keys(process.env).some((key) => key.startsWith('BASE_URL_')))
|
|
495
|
+
missingFeatures.push('API URLs');
|
|
496
|
+
if (projectType === 'Mobile' && process.env.USE_MOBILE !== 'true')
|
|
497
|
+
missingFeatures.push('Mobile Configuration');
|
|
498
|
+
if (projectType === 'SSH' && !process.env.SSH_HOST)
|
|
499
|
+
missingFeatures.push('SSH Configuration');
|
|
500
|
+
if (projectType === 'Banco' && !process.env.DB_HOST)
|
|
501
|
+
missingFeatures.push('Database Configuration');
|
|
502
|
+
return {
|
|
503
|
+
projectName: ConfigLogger.projectName,
|
|
504
|
+
projectType,
|
|
505
|
+
environment,
|
|
506
|
+
configuredFeatures,
|
|
507
|
+
missingFeatures,
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* NOVO: Log do relatório de projeto
|
|
512
|
+
*/
|
|
513
|
+
static logProjectReport() {
|
|
514
|
+
const report = ConfigLogger.generateProjectReport();
|
|
515
|
+
ConfigLogger.info('=== Relatório do Projeto ===');
|
|
516
|
+
ConfigLogger.info(`Nome: ${report.projectName}`);
|
|
517
|
+
if (report.projectType)
|
|
518
|
+
ConfigLogger.info(`Tipo: ${report.projectType}`);
|
|
519
|
+
if (report.environment)
|
|
520
|
+
ConfigLogger.info(`Ambiente: ${report.environment}`);
|
|
521
|
+
if (report.configuredFeatures.length > 0) {
|
|
522
|
+
ConfigLogger.info(`Recursos configurados: ${report.configuredFeatures.join(', ')}`);
|
|
523
|
+
}
|
|
524
|
+
if (report.missingFeatures.length > 0) {
|
|
525
|
+
ConfigLogger.warning(`Recursos em falta: ${report.missingFeatures.join(', ')}`);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
ConfigLogger.success('Todos os recursos necessários estão configurados');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
// ✨ NOVOS MÉTODOS PARA SEPARAÇÃO VISUAL DE MÉTODOS
|
|
532
|
+
/**
|
|
533
|
+
* 🚀 Inicia execução de um método com separador visual
|
|
534
|
+
*/
|
|
535
|
+
static methodStart(methodName, className, params) {
|
|
536
|
+
const timestamp = new Date().toLocaleTimeString('pt-BR');
|
|
537
|
+
const fullMethodName = className ? `${className}.${methodName}` : methodName;
|
|
538
|
+
const paramStr = params && params.length > 0
|
|
539
|
+
? params
|
|
540
|
+
.map((p) => typeof p === 'string' && p.length > 20
|
|
541
|
+
? `${p.substring(0, 17)}...`
|
|
542
|
+
: String(p))
|
|
543
|
+
.join(', ')
|
|
544
|
+
: 'nenhum';
|
|
545
|
+
console.log();
|
|
546
|
+
console.log('┌─────────────────────────────────────────────────────────────────┐');
|
|
547
|
+
console.log(`│ 🚀 EXECUTANDO: ${fullMethodName.padEnd(42)} │`);
|
|
548
|
+
console.log(`│ ⏰ ${timestamp} | 📊 Parâmetros: ${paramStr.padEnd(28)} │`);
|
|
549
|
+
console.log('└─────────────────────────────────────────────────────────────────┘');
|
|
550
|
+
if (ConfigLogger.logToFile) {
|
|
551
|
+
ConfigLogger.appendToLogFile(`METHOD_START: ${fullMethodName} | Params: ${paramStr} | Time: ${timestamp}`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* ✅ Finaliza execução de um método
|
|
556
|
+
*/
|
|
557
|
+
static methodEnd(methodName, className, success = true, duration) {
|
|
558
|
+
const fullMethodName = className ? `${className}.${methodName}` : methodName;
|
|
559
|
+
const status = success ? '✅ SUCESSO' : '❌ ERRO';
|
|
560
|
+
const durationStr = duration ? ` em ${duration}ms` : '';
|
|
561
|
+
console.log(`${status}: ${fullMethodName}${durationStr}`);
|
|
562
|
+
console.log('─'.repeat(65));
|
|
563
|
+
if (ConfigLogger.logToFile) {
|
|
564
|
+
ConfigLogger.appendToLogFile(`METHOD_END: ${fullMethodName} | Status: ${success ? 'SUCCESS' : 'ERROR'}${durationStr}`);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* 📋 Log simples de método com separador pequeno
|
|
569
|
+
*/
|
|
570
|
+
static methodLog(methodName, className) {
|
|
571
|
+
const fullMethodName = className ? `${className}.${methodName}` : methodName;
|
|
572
|
+
const timestamp = new Date().toLocaleTimeString('pt-BR');
|
|
573
|
+
console.log();
|
|
574
|
+
console.log(`🔧 [${timestamp}] Executando: ${fullMethodName}`);
|
|
575
|
+
console.log('─'.repeat(40));
|
|
576
|
+
if (ConfigLogger.logToFile) {
|
|
577
|
+
ConfigLogger.appendToLogFile(`METHOD_LOG: ${fullMethodName} | Time: ${timestamp}`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* 🎯 Log de separação entre grupos de métodos
|
|
582
|
+
*/
|
|
583
|
+
static sectionSeparator(sectionName) {
|
|
584
|
+
console.log();
|
|
585
|
+
console.log('═'.repeat(65));
|
|
586
|
+
console.log(`🎯 ${sectionName.toUpperCase()}`);
|
|
587
|
+
console.log('═'.repeat(65));
|
|
588
|
+
if (ConfigLogger.logToFile) {
|
|
589
|
+
ConfigLogger.appendToLogFile(`SECTION: ${sectionName}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* 📖 Wrapper para executar método com logs automáticos
|
|
594
|
+
*/
|
|
595
|
+
static async executeWithLogs(methodName, className, method, params) {
|
|
596
|
+
const startTime = Date.now();
|
|
597
|
+
ConfigLogger.methodStart(methodName, className, params);
|
|
598
|
+
try {
|
|
599
|
+
const result = await method();
|
|
600
|
+
const duration = Date.now() - startTime;
|
|
601
|
+
ConfigLogger.methodEnd(methodName, className, true, duration);
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
catch (error) {
|
|
605
|
+
const duration = Date.now() - startTime;
|
|
606
|
+
ConfigLogger.methodEnd(methodName, className, false, duration);
|
|
607
|
+
ConfigLogger.error(`Erro em ${className}.${methodName}`, error);
|
|
608
|
+
throw error;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
export default class CustomReporter implements Reporter {
|
|
3
|
+
private testCount;
|
|
4
|
+
private completedTests;
|
|
5
|
+
private projectRoot;
|
|
6
|
+
private ctsByCN;
|
|
7
|
+
private statementTracker?;
|
|
8
|
+
onBegin(config: FullConfig, suite: Suite): void;
|
|
9
|
+
private countAllTests;
|
|
10
|
+
private mapCNsAndCTs;
|
|
11
|
+
private detectProjectType;
|
|
12
|
+
private getStatementTracker;
|
|
13
|
+
onTestBegin(test: TestCase): void;
|
|
14
|
+
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
15
|
+
private mapToCoverageType;
|
|
16
|
+
onEnd(_result: FullResult): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* 📡 Copia os network logs de test-results/network-logs/ para playwright-report/evidence/network-logs/
|
|
19
|
+
* Isso acontece APÓS a geração do relatório HTML pelo Playwright
|
|
20
|
+
*/
|
|
21
|
+
private copyNetworkLogsToReport;
|
|
22
|
+
}
|