@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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtifactsCompressor: Compacta e converte relatórios para Base64
|
|
3
|
+
* Usado para enviar playwright-report e test-results para o Hub
|
|
4
|
+
*/
|
|
5
|
+
export interface ArtifactsPayload {
|
|
6
|
+
htmlReport?: string;
|
|
7
|
+
testResults?: string;
|
|
8
|
+
traces?: string[];
|
|
9
|
+
screenshots?: string[];
|
|
10
|
+
size: {
|
|
11
|
+
htmlReportBytes: number;
|
|
12
|
+
testResultsBytes: number;
|
|
13
|
+
totalBytes: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare class ArtifactsCompressor {
|
|
17
|
+
private workingDir;
|
|
18
|
+
constructor(workingDir?: string);
|
|
19
|
+
/**
|
|
20
|
+
* 📦 Compacta e converte todos os artifacts para Base64
|
|
21
|
+
*/
|
|
22
|
+
compressAllArtifacts(): Promise<ArtifactsPayload>;
|
|
23
|
+
/**
|
|
24
|
+
* 🗜️ Compacta um diretório em ZIP
|
|
25
|
+
*/
|
|
26
|
+
private zipDirectory;
|
|
27
|
+
/**
|
|
28
|
+
* 📄 Converte arquivo para Base64
|
|
29
|
+
*/
|
|
30
|
+
private fileToBase64;
|
|
31
|
+
/**
|
|
32
|
+
* 🔍 Coleta traces do test-results/
|
|
33
|
+
*/
|
|
34
|
+
private collectTraces;
|
|
35
|
+
/**
|
|
36
|
+
* 📸 Coleta screenshots
|
|
37
|
+
*/
|
|
38
|
+
private collectScreenshots;
|
|
39
|
+
/**
|
|
40
|
+
* 📏 Formata bytes para leitura humana
|
|
41
|
+
*/
|
|
42
|
+
private formatBytes;
|
|
43
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtifactsCompressor: Compacta e converte relatórios para Base64
|
|
3
|
+
* Usado para enviar playwright-report e test-results para o Hub
|
|
4
|
+
*/
|
|
5
|
+
import { exec } from 'node:child_process';
|
|
6
|
+
import * as fs from 'node:fs';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { Logger } from './Logger.js';
|
|
10
|
+
const execAsync = promisify(exec);
|
|
11
|
+
export class ArtifactsCompressor {
|
|
12
|
+
workingDir;
|
|
13
|
+
constructor(workingDir = process.cwd()) {
|
|
14
|
+
this.workingDir = workingDir;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 📦 Compacta e converte todos os artifacts para Base64
|
|
18
|
+
*/
|
|
19
|
+
async compressAllArtifacts() {
|
|
20
|
+
const payload = {
|
|
21
|
+
size: {
|
|
22
|
+
htmlReportBytes: 0,
|
|
23
|
+
testResultsBytes: 0,
|
|
24
|
+
totalBytes: 0,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
// 1. Compactar playwright-report/
|
|
28
|
+
const htmlReportPath = path.join(this.workingDir, 'playwright-report');
|
|
29
|
+
if (fs.existsSync(htmlReportPath)) {
|
|
30
|
+
const zipPath = await this.zipDirectory(htmlReportPath, 'playwright-report.zip');
|
|
31
|
+
const base64 = await this.fileToBase64(zipPath);
|
|
32
|
+
payload.htmlReport = base64;
|
|
33
|
+
payload.size.htmlReportBytes = Buffer.byteLength(base64, 'base64');
|
|
34
|
+
// Limpar ZIP temporário
|
|
35
|
+
fs.unlinkSync(zipPath);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
Logger.info(' ⚠️ playwright-report/ não encontrado');
|
|
39
|
+
}
|
|
40
|
+
// 2. Compactar test-results/
|
|
41
|
+
const testResultsPath = path.join(this.workingDir, 'test-results');
|
|
42
|
+
if (fs.existsSync(testResultsPath)) {
|
|
43
|
+
const zipPath = await this.zipDirectory(testResultsPath, 'test-results.zip');
|
|
44
|
+
const base64 = await this.fileToBase64(zipPath);
|
|
45
|
+
payload.testResults = base64;
|
|
46
|
+
payload.size.testResultsBytes = Buffer.byteLength(base64, 'base64');
|
|
47
|
+
// Limpar ZIP temporário
|
|
48
|
+
fs.unlinkSync(zipPath);
|
|
49
|
+
Logger.info(` ✅ test-results.zip: ${this.formatBytes(payload.size.testResultsBytes)}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
Logger.info(' ⚠️ test-results/ não encontrado');
|
|
53
|
+
}
|
|
54
|
+
// 3. Coletar traces individuais (já estão em ZIP)
|
|
55
|
+
payload.traces = await this.collectTraces();
|
|
56
|
+
if (payload.traces.length > 0) {
|
|
57
|
+
Logger.info(` ✅ ${payload.traces.length} trace(s) coletado(s)`);
|
|
58
|
+
}
|
|
59
|
+
// 4. Coletar screenshots
|
|
60
|
+
payload.screenshots = await this.collectScreenshots();
|
|
61
|
+
if (payload.screenshots.length > 0) {
|
|
62
|
+
Logger.info(` ✅ ${payload.screenshots.length} screenshot(s) coletado(s)`);
|
|
63
|
+
}
|
|
64
|
+
// Calcular tamanho total
|
|
65
|
+
payload.size.totalBytes =
|
|
66
|
+
payload.size.htmlReportBytes + payload.size.testResultsBytes;
|
|
67
|
+
Logger.info(`\n📊 Tamanho total dos artifacts: ${this.formatBytes(payload.size.totalBytes)}`);
|
|
68
|
+
return payload;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 🗜️ Compacta um diretório em ZIP
|
|
72
|
+
*/
|
|
73
|
+
async zipDirectory(sourceDir, outputName) {
|
|
74
|
+
const outputPath = path.join(this.workingDir, outputName);
|
|
75
|
+
// Detectar OS e usar comando apropriado
|
|
76
|
+
const isWindows = process.platform === 'win32';
|
|
77
|
+
try {
|
|
78
|
+
if (isWindows) {
|
|
79
|
+
// Windows: usar PowerShell Compress-Archive
|
|
80
|
+
const psCommand = `Compress-Archive -Path "${sourceDir}\\*" -DestinationPath "${outputPath}" -Force`;
|
|
81
|
+
await execAsync(psCommand, { shell: 'powershell.exe' });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Linux/Mac: usar zip
|
|
85
|
+
await execAsync(`cd "${path.dirname(sourceDir)}" && zip -r "${outputPath}" "${path.basename(sourceDir)}"`);
|
|
86
|
+
}
|
|
87
|
+
return outputPath;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
91
|
+
Logger.error(`❌ Erro ao compactar ${sourceDir}: ${msg}`);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 📄 Converte arquivo para Base64
|
|
97
|
+
*/
|
|
98
|
+
async fileToBase64(filePath) {
|
|
99
|
+
try {
|
|
100
|
+
const fileBuffer = fs.readFileSync(filePath);
|
|
101
|
+
return fileBuffer.toString('base64');
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
105
|
+
Logger.error(`❌ Erro ao converter ${filePath} para Base64: ${msg}`);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 🔍 Coleta traces do test-results/
|
|
111
|
+
*/
|
|
112
|
+
async collectTraces() {
|
|
113
|
+
const traces = [];
|
|
114
|
+
const testResultsPath = path.join(this.workingDir, 'test-results');
|
|
115
|
+
if (!fs.existsSync(testResultsPath)) {
|
|
116
|
+
return traces;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const dirs = fs.readdirSync(testResultsPath, { withFileTypes: true });
|
|
120
|
+
for (const dir of dirs) {
|
|
121
|
+
if (dir.isDirectory()) {
|
|
122
|
+
const tracePath = path.join(testResultsPath, dir.name, 'trace.zip');
|
|
123
|
+
if (fs.existsSync(tracePath)) {
|
|
124
|
+
// Converter trace para Base64
|
|
125
|
+
const base64 = await this.fileToBase64(tracePath);
|
|
126
|
+
traces.push(base64);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
133
|
+
Logger.warning(`⚠️ Erro ao coletar traces: ${msg}`);
|
|
134
|
+
}
|
|
135
|
+
return traces;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 📸 Coleta screenshots
|
|
139
|
+
*/
|
|
140
|
+
async collectScreenshots() {
|
|
141
|
+
const screenshots = [];
|
|
142
|
+
const testResultsPath = path.join(this.workingDir, 'test-results');
|
|
143
|
+
if (!fs.existsSync(testResultsPath)) {
|
|
144
|
+
return screenshots;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const dirs = fs.readdirSync(testResultsPath, { withFileTypes: true });
|
|
148
|
+
for (const dir of dirs) {
|
|
149
|
+
if (dir.isDirectory()) {
|
|
150
|
+
const dirPath = path.join(testResultsPath, dir.name);
|
|
151
|
+
const files = fs.readdirSync(dirPath);
|
|
152
|
+
for (const file of files) {
|
|
153
|
+
if (file.endsWith('.png') ||
|
|
154
|
+
file.endsWith('.jpg') ||
|
|
155
|
+
file.endsWith('.jpeg')) {
|
|
156
|
+
const screenshotPath = path.join(dirPath, file);
|
|
157
|
+
const base64 = await this.fileToBase64(screenshotPath);
|
|
158
|
+
screenshots.push(base64);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
166
|
+
Logger.warning(`⚠️ Erro ao coletar screenshots: ${msg}`);
|
|
167
|
+
}
|
|
168
|
+
return screenshots;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 📏 Formata bytes para leitura humana
|
|
172
|
+
*/
|
|
173
|
+
formatBytes(bytes) {
|
|
174
|
+
if (bytes === 0)
|
|
175
|
+
return '0 Bytes';
|
|
176
|
+
const k = 1024;
|
|
177
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
178
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
179
|
+
return `${Math.round((bytes / k ** i) * 100) / 100} ${sizes[i]}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🎯 SOLUÇÃO FINAL: Sistema AutoLogs Completo
|
|
3
|
+
*
|
|
4
|
+
* Esta é a implementação definitiva que funcionará perfeitamente
|
|
5
|
+
* com a sintaxe original do usuário.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 🔥 AutoLogsFinal - Sistema definitivo e funcional
|
|
9
|
+
*/
|
|
10
|
+
export declare class AutoLogsFinal {
|
|
11
|
+
private static ativo;
|
|
12
|
+
private static originalNew;
|
|
13
|
+
/**
|
|
14
|
+
* 🚀 Ativar sistema de logs automáticos
|
|
15
|
+
*/
|
|
16
|
+
static ativar(): void;
|
|
17
|
+
/**
|
|
18
|
+
* 🌐 Interceptação total e eficaz
|
|
19
|
+
*/
|
|
20
|
+
private static interceptarTotalmenre;
|
|
21
|
+
/**
|
|
22
|
+
* 🎨 Interceptar protótipos diretamente
|
|
23
|
+
*/
|
|
24
|
+
private static interceptarPrototipos;
|
|
25
|
+
/**
|
|
26
|
+
* 🎨 Aplicar logs a uma instância
|
|
27
|
+
*/
|
|
28
|
+
static aplicarLogs<T extends object>(instance: T): T;
|
|
29
|
+
/**
|
|
30
|
+
* 🛑 Desativar sistema
|
|
31
|
+
*/
|
|
32
|
+
static desativar(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 📊 Status do sistema
|
|
35
|
+
*/
|
|
36
|
+
static status(): {
|
|
37
|
+
ativo: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 🌟 Função para usar em qualquer lugar
|
|
42
|
+
*/
|
|
43
|
+
export declare function aplicarAutoLogsEm<T extends object>(instance: T): T;
|
|
44
|
+
/**
|
|
45
|
+
* 🔥 Função principal para ativar
|
|
46
|
+
*/
|
|
47
|
+
export declare function ativarAutoLogsFinal(): void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🎯 SOLUÇÃO FINAL: Sistema AutoLogs Completo
|
|
3
|
+
*
|
|
4
|
+
* Esta é a implementação definitiva que funcionará perfeitamente
|
|
5
|
+
* com a sintaxe original do usuário.
|
|
6
|
+
*/
|
|
7
|
+
import { ConfigLogger } from './ConfigLogger.js';
|
|
8
|
+
/**
|
|
9
|
+
* 🔥 AutoLogsFinal - Sistema definitivo e funcional
|
|
10
|
+
*/
|
|
11
|
+
export class AutoLogsFinal {
|
|
12
|
+
static ativo = false;
|
|
13
|
+
static originalNew = null;
|
|
14
|
+
/**
|
|
15
|
+
* 🚀 Ativar sistema de logs automáticos
|
|
16
|
+
*/
|
|
17
|
+
static ativar() {
|
|
18
|
+
if (AutoLogsFinal.ativo)
|
|
19
|
+
return;
|
|
20
|
+
AutoLogsFinal.ativo = true;
|
|
21
|
+
ConfigLogger.success('🔥 AutoLogs FINAL ativado - Interceptação total');
|
|
22
|
+
// Interceptar TODAS as formas de criação de objetos
|
|
23
|
+
AutoLogsFinal.interceptarTotalmenre();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 🌐 Interceptação total e eficaz
|
|
27
|
+
*/
|
|
28
|
+
static interceptarTotalmenre() {
|
|
29
|
+
// 1. Interceptar Object.create
|
|
30
|
+
const originalCreate = Object.create;
|
|
31
|
+
Object.create = function (proto, propertiesObject) {
|
|
32
|
+
const obj = originalCreate.call(this, proto, propertiesObject);
|
|
33
|
+
if (proto &&
|
|
34
|
+
proto.constructor &&
|
|
35
|
+
proto.constructor.name &&
|
|
36
|
+
proto.constructor.name.startsWith('Statements')) {
|
|
37
|
+
return AutoLogsFinal.aplicarLogs(obj);
|
|
38
|
+
}
|
|
39
|
+
return obj;
|
|
40
|
+
};
|
|
41
|
+
// 2. Interceptar new via Proxy em Function.prototype
|
|
42
|
+
const originalCall = Function.prototype.call;
|
|
43
|
+
Function.prototype.call = function (thisArg, ...args) {
|
|
44
|
+
const result = originalCall.call(this, thisArg, ...args);
|
|
45
|
+
// Se é um constructor e retorna objeto
|
|
46
|
+
if (this.prototype &&
|
|
47
|
+
result &&
|
|
48
|
+
typeof result === 'object' &&
|
|
49
|
+
this.name &&
|
|
50
|
+
this.name.startsWith('Statements')) {
|
|
51
|
+
return AutoLogsFinal.aplicarLogs(result);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
// 3. Interceptar via defineProperty no prototype das classes
|
|
56
|
+
AutoLogsFinal.interceptarPrototipos();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 🎨 Interceptar protótipos diretamente
|
|
60
|
+
*/
|
|
61
|
+
static interceptarPrototipos() {
|
|
62
|
+
// Interceptar quando qualquer propriedade é definida
|
|
63
|
+
const originalDefineProperty = Object.defineProperty;
|
|
64
|
+
Object.defineProperty = function (obj, prop, descriptor) {
|
|
65
|
+
const result = originalDefineProperty.call(this, obj, prop, descriptor);
|
|
66
|
+
// Se está definindo constructor de uma classe Statements
|
|
67
|
+
if (prop === 'constructor' &&
|
|
68
|
+
descriptor.value &&
|
|
69
|
+
descriptor.value.name &&
|
|
70
|
+
descriptor.value.name.startsWith('Statements')) {
|
|
71
|
+
// Interceptar o constructor
|
|
72
|
+
const originalConstructor = descriptor.value;
|
|
73
|
+
descriptor.value = (...args) => {
|
|
74
|
+
const instance = new originalConstructor(...args);
|
|
75
|
+
return AutoLogsFinal.aplicarLogs(instance);
|
|
76
|
+
};
|
|
77
|
+
// Manter propriedades do constructor original
|
|
78
|
+
Object.setPrototypeOf(descriptor.value, originalConstructor);
|
|
79
|
+
descriptor.value.prototype = originalConstructor.prototype;
|
|
80
|
+
descriptor.value.name = originalConstructor.name;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 🎨 Aplicar logs a uma instância
|
|
87
|
+
*/
|
|
88
|
+
static aplicarLogs(instance) {
|
|
89
|
+
if (!AutoLogsFinal.ativo)
|
|
90
|
+
return instance;
|
|
91
|
+
const className = instance.constructor.name;
|
|
92
|
+
return new Proxy(instance, {
|
|
93
|
+
get(target, prop) {
|
|
94
|
+
const value = Reflect.get(target, prop);
|
|
95
|
+
if (typeof value === 'function' &&
|
|
96
|
+
typeof prop === 'string' &&
|
|
97
|
+
!prop.startsWith('_') &&
|
|
98
|
+
prop !== 'constructor') {
|
|
99
|
+
return async (...args) => {
|
|
100
|
+
const startTime = Date.now();
|
|
101
|
+
// Log de início
|
|
102
|
+
ConfigLogger.methodStart(prop, className, args);
|
|
103
|
+
try {
|
|
104
|
+
// Executar método original
|
|
105
|
+
const result = await value.apply(target, args);
|
|
106
|
+
// Log de sucesso
|
|
107
|
+
const duration = Date.now() - startTime;
|
|
108
|
+
ConfigLogger.methodEnd(prop, className, true, duration);
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// Log de erro
|
|
113
|
+
const duration = Date.now() - startTime;
|
|
114
|
+
ConfigLogger.methodEnd(prop, className, false, duration);
|
|
115
|
+
ConfigLogger.error(`Erro em ${className}.${prop}`, error);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 🛑 Desativar sistema
|
|
126
|
+
*/
|
|
127
|
+
static desativar() {
|
|
128
|
+
AutoLogsFinal.ativo = false;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 📊 Status do sistema
|
|
132
|
+
*/
|
|
133
|
+
static status() {
|
|
134
|
+
return { ativo: AutoLogsFinal.ativo };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 🌟 Função para usar em qualquer lugar
|
|
139
|
+
*/
|
|
140
|
+
export function aplicarAutoLogsEm(instance) {
|
|
141
|
+
return AutoLogsFinal.aplicarLogs(instance);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 🔥 Função principal para ativar
|
|
145
|
+
*/
|
|
146
|
+
export function ativarAutoLogsFinal() {
|
|
147
|
+
AutoLogsFinal.ativar();
|
|
148
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeGen Session Manager (v2.7.44 - items 15 & 16)
|
|
3
|
+
*
|
|
4
|
+
* Mantém uma única sessão Playwright MCP por execução de CT para que o
|
|
5
|
+
* codegen capture todo o fluxo real em vez de "sempre o mesmo código".
|
|
6
|
+
*
|
|
7
|
+
* Item 15 – Fluxo contínuo na mesma sessão:
|
|
8
|
+
* 1. start() → inicia sessão única
|
|
9
|
+
* 2. execute() → navega/click/fill na mesma sessão
|
|
10
|
+
* 3. codegenPreview() / codegenExport() → gera artefato
|
|
11
|
+
* 4. close() → encerra sessão
|
|
12
|
+
*
|
|
13
|
+
* Item 16 – Modo recorder (interação manual):
|
|
14
|
+
* 1. startRecording() → habilita captura de eventos no browser
|
|
15
|
+
* 2. (usuário interage manualmente na página)
|
|
16
|
+
* 3. stopRecording() → coleta eventos e converte em capturedElements
|
|
17
|
+
* 4. codegenExport() → gera código a partir dos eventos gravados
|
|
18
|
+
*/
|
|
19
|
+
/** Evento capturado pelo recorder (contrato mínimo — item 16) */
|
|
20
|
+
export interface RecordedEvent {
|
|
21
|
+
action: 'click' | 'fill' | 'select' | 'check' | 'uncheck' | 'press' | 'navigate';
|
|
22
|
+
selector?: string;
|
|
23
|
+
xpath?: string;
|
|
24
|
+
value?: string;
|
|
25
|
+
pageUrl?: string;
|
|
26
|
+
pageTitle?: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resultado de uma chamada à ferramenta MCP playwright_execute.
|
|
31
|
+
* O shape real depende do MCP; aqui declaramos os campos usados internamente.
|
|
32
|
+
*/
|
|
33
|
+
export interface PlaywrightExecuteResult {
|
|
34
|
+
success?: boolean;
|
|
35
|
+
error?: string;
|
|
36
|
+
capturedElements?: unknown[];
|
|
37
|
+
data?: unknown;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Opções de inicialização da sessão */
|
|
41
|
+
export interface CodeGenSessionOptions {
|
|
42
|
+
headless?: boolean;
|
|
43
|
+
ignoreSSL?: boolean;
|
|
44
|
+
autoLogin?: boolean;
|
|
45
|
+
systemName?: string;
|
|
46
|
+
environmentType?: string;
|
|
47
|
+
/** URL inicial para navegação (navegará automaticamente no start) */
|
|
48
|
+
startUrl?: string;
|
|
49
|
+
/** Se true, reinicia sessão mesmo que já exista (item 15/27.5) */
|
|
50
|
+
fromScratch?: boolean;
|
|
51
|
+
/** Alias de fromScratch (item 15/27.5) */
|
|
52
|
+
resetSession?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** Alvos suportados para geração de código */
|
|
55
|
+
export type CodegenTarget = 'framework' | 'playwright' | 'both';
|
|
56
|
+
/**
|
|
57
|
+
* Função que executa uma chamada MCP `playwright_execute`.
|
|
58
|
+
* Deve ser injetada via `CodeGenSession.setTransport()` antes do uso.
|
|
59
|
+
*/
|
|
60
|
+
export type McpTransport = (action: string, params?: Record<string, unknown>) => Promise<PlaywrightExecuteResult>;
|
|
61
|
+
export declare class CodeGenSession {
|
|
62
|
+
private active;
|
|
63
|
+
private recording;
|
|
64
|
+
private recordedEvents;
|
|
65
|
+
private options;
|
|
66
|
+
/** Injeta a função de transporte MCP (obrigatório antes de usar) */
|
|
67
|
+
static setTransport(fn: McpTransport): void;
|
|
68
|
+
private call;
|
|
69
|
+
/**
|
|
70
|
+
* Inicia (ou reutiliza) uma sessão Playwright MCP.
|
|
71
|
+
* Não reinicia browser/context/page — preserva `capturedElements`.
|
|
72
|
+
* Reinicia apenas com `fromScratch=true` ou `resetSession=true` (item 15/27.5).
|
|
73
|
+
*/
|
|
74
|
+
start(opts?: CodeGenSessionOptions): Promise<PlaywrightExecuteResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Executa uma ação na sessão ativa (navigate/click/fill/select/…).
|
|
77
|
+
*/
|
|
78
|
+
execute(action: string, params?: Record<string, unknown>): Promise<PlaywrightExecuteResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Gera preview do código capturado (inspeção).
|
|
81
|
+
*/
|
|
82
|
+
codegenPreview(): Promise<PlaywrightExecuteResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Exporta código capturado (Playwright puro ou framework).
|
|
85
|
+
*/
|
|
86
|
+
codegenExport(target?: CodegenTarget): Promise<PlaywrightExecuteResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Gera código com alvo específico (alias conveniente).
|
|
89
|
+
*/
|
|
90
|
+
codegen(target?: CodegenTarget): Promise<PlaywrightExecuteResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Encerra a sessão. Chamar somente APÓS etapa de codegen.
|
|
93
|
+
*/
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
/** Verifica se a sessão está ativa */
|
|
96
|
+
isActive(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Inicia gravação de eventos de interação manual.
|
|
99
|
+
* Injeta um listener de eventos na página ativa que captura
|
|
100
|
+
* click/fill/select/check/uncheck/press.
|
|
101
|
+
*/
|
|
102
|
+
startRecording(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Para a gravação e coleta os eventos capturados do browser.
|
|
105
|
+
* Faz flush para `capturedElements` internamente.
|
|
106
|
+
*/
|
|
107
|
+
stopRecording(): Promise<RecordedEvent[]>;
|
|
108
|
+
/** Registra manualmente um evento (para integração programática) */
|
|
109
|
+
addEvent(event: RecordedEvent): void;
|
|
110
|
+
/** Retorna todos os eventos gravados */
|
|
111
|
+
getRecordedEvents(): RecordedEvent[];
|
|
112
|
+
/** Limpa eventos gravados */
|
|
113
|
+
clearEvents(): void;
|
|
114
|
+
}
|