@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,138 @@
|
|
|
1
|
+
import type { TestInfo } from '@playwright/test';
|
|
2
|
+
import { type APIRequestContext, request as playwrightRequest } from '@playwright/test';
|
|
3
|
+
import type { IPage } from '../interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Contexto compartilhado para informações de teste
|
|
6
|
+
* SIMPLIFICADO: Removida lógica de conexão mobile para MobileConnection
|
|
7
|
+
*/
|
|
8
|
+
export declare class TestContext {
|
|
9
|
+
private static _testInfo;
|
|
10
|
+
private static _page;
|
|
11
|
+
private static _apiContext;
|
|
12
|
+
private static _sessionId;
|
|
13
|
+
/**
|
|
14
|
+
* Tipo de teste configurado por TestAnnotations (API, Frontend, Mixed, SSH, Banco, Mobile).
|
|
15
|
+
* Definido pelos setters TestAnnotations.Api/Frontend/Mixed/SSH/Banco/Mobile.
|
|
16
|
+
* Usado pelo fixture autoInjectPage para saber se deve criar browser e como anexar logs.
|
|
17
|
+
*/
|
|
18
|
+
private static _testType;
|
|
19
|
+
static setTestType(type: 'API' | 'Frontend' | 'Mixed' | 'SSH' | 'Banco' | 'Mobile'): void;
|
|
20
|
+
static getTestType(): 'API' | 'Frontend' | 'Mixed' | 'SSH' | 'Banco' | 'Mobile' | null;
|
|
21
|
+
/**
|
|
22
|
+
* Retorna true se o tipo de teste NÃO requer browser (API, SSH, Banco).
|
|
23
|
+
*/
|
|
24
|
+
static isNonBrowserTest(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Reseta o tipo de teste (chamado no cleanup do fixture).
|
|
27
|
+
*/
|
|
28
|
+
static resetTestType(): void;
|
|
29
|
+
private static _pageFactory;
|
|
30
|
+
private static _pagePromise;
|
|
31
|
+
/**
|
|
32
|
+
* Armazena factory para criação lazy de browser+page.
|
|
33
|
+
* Chamado pelo fixture autoInjectPage antes do body do teste.
|
|
34
|
+
*/
|
|
35
|
+
static setPageFactory(factory: (() => Promise<any>) | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* Dispara criação assíncrona de browser+page (fire-and-forget).
|
|
38
|
+
* Chamado sync por TestAnnotations.Frontend/Mixed setters.
|
|
39
|
+
*/
|
|
40
|
+
static requestBrowserCreation(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Aguarda criação do page se foi solicitada via requestBrowserCreation().
|
|
43
|
+
* Retorna o page se disponível, undefined caso contrário.
|
|
44
|
+
*/
|
|
45
|
+
static ensurePage(): Promise<IPage | undefined>;
|
|
46
|
+
static setTestInfo(testInfo: TestInfo): void;
|
|
47
|
+
/**
|
|
48
|
+
* Obtém o sessionId atual ou cria um novo se não existir
|
|
49
|
+
*/
|
|
50
|
+
static getOrCreateSessionId(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Define explicitamente o sessionId a ser usado nas chamadas ao Hub
|
|
53
|
+
*/
|
|
54
|
+
static setSessionId(id: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Apenas lê o sessionId se presente (não cria)
|
|
57
|
+
*/
|
|
58
|
+
static getSessionId(): string | null;
|
|
59
|
+
static get testInfo(): TestInfo | null;
|
|
60
|
+
static getSafeTestInfo(): TestInfo | null;
|
|
61
|
+
static setPage(page: IPage): void;
|
|
62
|
+
static getPage(): IPage;
|
|
63
|
+
static get page(): IPage;
|
|
64
|
+
/**
|
|
65
|
+
* ✅ NOVO: Verifica se a página está inicializada sem lançar erro
|
|
66
|
+
*/
|
|
67
|
+
static isPageInitialized(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* ✅ NOVO: Obtém timeout do projeto (usado por todos os módulos)
|
|
70
|
+
* Lê do playwright.config.ts do consumidor, com fallbacks para variáveis de ambiente
|
|
71
|
+
* @returns Timeout em ms (padrão: 600000ms = 10 minutos)
|
|
72
|
+
*/
|
|
73
|
+
static getProjectTimeout(): number;
|
|
74
|
+
static initApiContext(options?: Parameters<typeof playwrightRequest.newContext>[0]): Promise<void>;
|
|
75
|
+
static get apiContext(): APIRequestContext;
|
|
76
|
+
static getOrCreateApiContext(): Promise<APIRequestContext>;
|
|
77
|
+
static get appiumDriver(): any;
|
|
78
|
+
static createMobileSession(capabilities: {
|
|
79
|
+
deviceId: string;
|
|
80
|
+
platformName: 'Android' | 'iOS';
|
|
81
|
+
appPackage: string;
|
|
82
|
+
appActivity?: string;
|
|
83
|
+
bundleId?: string;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
static resetAppiumDriver(): Promise<void>;
|
|
86
|
+
static captureScreenshot(nome?: string): Promise<Buffer | null>;
|
|
87
|
+
static clear(): void;
|
|
88
|
+
static finalizeAll(): Promise<void>;
|
|
89
|
+
static forceCleanup(): void;
|
|
90
|
+
/**
|
|
91
|
+
* 🆕 CRÍTICO: Garantir disponibilidade global em projetos consumidores
|
|
92
|
+
* Este método força a exportação do TestContext no globalThis
|
|
93
|
+
* para que funcione em qualquer projeto, mesmo sem import direto
|
|
94
|
+
*/
|
|
95
|
+
static ensureGlobalAvailability(): void;
|
|
96
|
+
/**
|
|
97
|
+
* 💾 Salva o estado de autenticação atual (cookies + localStorage + sessionStorage)
|
|
98
|
+
* @param filePath Caminho opcional para salvar (padrão: ./test-results/auth/auth-state.json)
|
|
99
|
+
* @example
|
|
100
|
+
* // Após fazer login
|
|
101
|
+
* await TestContext.saveAuthState('./auth/admin-user.json')
|
|
102
|
+
*/
|
|
103
|
+
static saveAuthState(filePath?: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* 🔄 Restaura o estado de autenticação salvo
|
|
106
|
+
* @param filePath Caminho do arquivo de estado
|
|
107
|
+
* @example
|
|
108
|
+
* // Antes de rodar testes
|
|
109
|
+
* await TestContext.restoreAuthState('./auth/admin-user.json')
|
|
110
|
+
*/
|
|
111
|
+
static restoreAuthState(filePath?: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* 🧹 Limpa todo o estado de autenticação
|
|
114
|
+
* @example
|
|
115
|
+
* // Logout completo
|
|
116
|
+
* await TestContext.clearAuthState()
|
|
117
|
+
*/
|
|
118
|
+
static clearAuthState(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* 📄 Verifica se existe um arquivo de estado salvo
|
|
121
|
+
* @param filePath Caminho do arquivo
|
|
122
|
+
*/
|
|
123
|
+
static authStateExists(filePath?: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* 🔍 Lê o estado salvo sem aplicar
|
|
126
|
+
* @param filePath Caminho do arquivo
|
|
127
|
+
*/
|
|
128
|
+
static readAuthState(filePath?: string): import("./AuthStateManager.js").AuthState | null;
|
|
129
|
+
/**
|
|
130
|
+
* 🗑️ Remove um arquivo de estado
|
|
131
|
+
* @param filePath Caminho do arquivo
|
|
132
|
+
*/
|
|
133
|
+
static deleteAuthState(filePath?: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 📋 Lista todos os estados salvos
|
|
136
|
+
*/
|
|
137
|
+
static listAuthStates(): string[];
|
|
138
|
+
}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { request as playwrightRequest, } from '@playwright/test';
|
|
2
|
+
import { randomUUID } from 'crypto';
|
|
3
|
+
import { MobileConnection } from '../appium/MobileConnection.js';
|
|
4
|
+
import { AuthStateManager } from './AuthStateManager.js';
|
|
5
|
+
import { Logger } from '../utils/Logger.js';
|
|
6
|
+
// Interceptação agora é automática via StatementTracker
|
|
7
|
+
// import '../hubdocs/AutoStatementInterceptor.js'
|
|
8
|
+
// import '../hubdocs/DirectStatementInterceptor.js'
|
|
9
|
+
/**
|
|
10
|
+
* Contexto compartilhado para informações de teste
|
|
11
|
+
* SIMPLIFICADO: Removida lógica de conexão mobile para MobileConnection
|
|
12
|
+
*/
|
|
13
|
+
export class TestContext {
|
|
14
|
+
static _testInfo = null;
|
|
15
|
+
static _page = null;
|
|
16
|
+
static _apiContext = null;
|
|
17
|
+
static _sessionId = null;
|
|
18
|
+
/**
|
|
19
|
+
* Tipo de teste configurado por TestAnnotations (API, Frontend, Mixed, SSH, Banco, Mobile).
|
|
20
|
+
* Definido pelos setters TestAnnotations.Api/Frontend/Mixed/SSH/Banco/Mobile.
|
|
21
|
+
* Usado pelo fixture autoInjectPage para saber se deve criar browser e como anexar logs.
|
|
22
|
+
*/
|
|
23
|
+
static _testType = null;
|
|
24
|
+
static setTestType(type) {
|
|
25
|
+
TestContext._testType = type;
|
|
26
|
+
}
|
|
27
|
+
static getTestType() {
|
|
28
|
+
return TestContext._testType;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retorna true se o tipo de teste NÃO requer browser (API, SSH, Banco).
|
|
32
|
+
*/
|
|
33
|
+
static isNonBrowserTest() {
|
|
34
|
+
return TestContext._testType === 'API' || TestContext._testType === 'SSH' || TestContext._testType === 'Banco';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reseta o tipo de teste (chamado no cleanup do fixture).
|
|
38
|
+
*/
|
|
39
|
+
static resetTestType() {
|
|
40
|
+
TestContext._testType = null;
|
|
41
|
+
}
|
|
42
|
+
// Lazy browser/page factory — set by fixtures.ts, triggered by TestAnnotations.Frontend/Mixed
|
|
43
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic factory
|
|
44
|
+
static _pageFactory = null;
|
|
45
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic promise
|
|
46
|
+
static _pagePromise = null;
|
|
47
|
+
/**
|
|
48
|
+
* Armazena factory para criação lazy de browser+page.
|
|
49
|
+
* Chamado pelo fixture autoInjectPage antes do body do teste.
|
|
50
|
+
*/
|
|
51
|
+
// biome-ignore lint/suspicious/noExplicitAny: generic factory
|
|
52
|
+
static setPageFactory(factory) {
|
|
53
|
+
TestContext._pageFactory = factory;
|
|
54
|
+
TestContext._pagePromise = null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Dispara criação assíncrona de browser+page (fire-and-forget).
|
|
58
|
+
* Chamado sync por TestAnnotations.Frontend/Mixed setters.
|
|
59
|
+
*/
|
|
60
|
+
static requestBrowserCreation() {
|
|
61
|
+
if (TestContext._pageFactory && !TestContext._pagePromise && !TestContext._page) {
|
|
62
|
+
TestContext._pagePromise = TestContext._pageFactory();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Aguarda criação do page se foi solicitada via requestBrowserCreation().
|
|
67
|
+
* Retorna o page se disponível, undefined caso contrário.
|
|
68
|
+
*/
|
|
69
|
+
static async ensurePage() {
|
|
70
|
+
if (TestContext._page)
|
|
71
|
+
return TestContext._page;
|
|
72
|
+
if (TestContext._pagePromise) {
|
|
73
|
+
await TestContext._pagePromise;
|
|
74
|
+
return TestContext._page ?? undefined;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
static setTestInfo(testInfo) {
|
|
79
|
+
TestContext._testInfo = testInfo;
|
|
80
|
+
// ❌ REMOVIDO: setTestName() agora é chamado em TestAnnotations.Api/SSH/Banco/etc
|
|
81
|
+
// Não chamar aqui para evitar sobrescrever o nome correto do CN
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Obtém o sessionId atual ou cria um novo se não existir
|
|
85
|
+
*/
|
|
86
|
+
static getOrCreateSessionId() {
|
|
87
|
+
if (TestContext._sessionId)
|
|
88
|
+
return TestContext._sessionId;
|
|
89
|
+
try {
|
|
90
|
+
TestContext._sessionId = (randomUUID && randomUUID()) || `sid-${Date.now()}`;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
TestContext._sessionId = `sid-${Date.now()}`;
|
|
94
|
+
}
|
|
95
|
+
return TestContext._sessionId;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Define explicitamente o sessionId a ser usado nas chamadas ao Hub
|
|
99
|
+
*/
|
|
100
|
+
static setSessionId(id) {
|
|
101
|
+
TestContext._sessionId = id;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Apenas lê o sessionId se presente (não cria)
|
|
105
|
+
*/
|
|
106
|
+
static getSessionId() {
|
|
107
|
+
return TestContext._sessionId;
|
|
108
|
+
}
|
|
109
|
+
static get testInfo() {
|
|
110
|
+
return TestContext._testInfo;
|
|
111
|
+
}
|
|
112
|
+
static getSafeTestInfo() {
|
|
113
|
+
return TestContext._testInfo;
|
|
114
|
+
}
|
|
115
|
+
// ✅ ADICIONADO: Suporte a Page
|
|
116
|
+
static setPage(page) {
|
|
117
|
+
TestContext._page = page;
|
|
118
|
+
}
|
|
119
|
+
static getPage() {
|
|
120
|
+
if (!TestContext._page) {
|
|
121
|
+
throw new Error('TestContext.page não foi inicializado');
|
|
122
|
+
}
|
|
123
|
+
return TestContext._page;
|
|
124
|
+
}
|
|
125
|
+
static get page() {
|
|
126
|
+
if (!TestContext._page) {
|
|
127
|
+
throw new Error('TestContext.page não foi inicializado');
|
|
128
|
+
}
|
|
129
|
+
return TestContext._page;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* ✅ NOVO: Verifica se a página está inicializada sem lançar erro
|
|
133
|
+
*/
|
|
134
|
+
static isPageInitialized() {
|
|
135
|
+
return TestContext._page !== null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* ✅ NOVO: Obtém timeout do projeto (usado por todos os módulos)
|
|
139
|
+
* Lê do playwright.config.ts do consumidor, com fallbacks para variáveis de ambiente
|
|
140
|
+
* @returns Timeout em ms (padrão: 600000ms = 10 minutos)
|
|
141
|
+
*/
|
|
142
|
+
static getProjectTimeout() {
|
|
143
|
+
const DEFAULT_TIMEOUT = 600_000; // 10 minutos
|
|
144
|
+
try {
|
|
145
|
+
// 1. Tentar pegar do TestInfo (playwright.config.ts)
|
|
146
|
+
const testInfo = TestContext.getSafeTestInfo();
|
|
147
|
+
if (testInfo?.timeout) {
|
|
148
|
+
return testInfo.timeout;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Ignorar erro silenciosamente
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
// 2. Fallback: variável de ambiente
|
|
156
|
+
const envTimeout = process.env.PLAYWRIGHT_TIMEOUT || process.env.TIMEOUT;
|
|
157
|
+
if (envTimeout) {
|
|
158
|
+
const timeout = Number.parseInt(envTimeout, 10);
|
|
159
|
+
if (!Number.isNaN(timeout)) {
|
|
160
|
+
return timeout;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Ignorar erro silenciosamente
|
|
166
|
+
}
|
|
167
|
+
// 3. Padrão: 10 minutos
|
|
168
|
+
return DEFAULT_TIMEOUT;
|
|
169
|
+
}
|
|
170
|
+
// ✅ ADICIONADO: Suporte a API Context
|
|
171
|
+
static async initApiContext(options) {
|
|
172
|
+
if (!TestContext._apiContext) {
|
|
173
|
+
TestContext._apiContext = await playwrightRequest.newContext({
|
|
174
|
+
ignoreHTTPSErrors: true,
|
|
175
|
+
...options,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
static get apiContext() {
|
|
180
|
+
if (!TestContext._apiContext) {
|
|
181
|
+
throw new Error('TestContext.apiContext não foi inicializado. Chame TestContext.initApiContext() primeiro.');
|
|
182
|
+
}
|
|
183
|
+
return TestContext._apiContext;
|
|
184
|
+
}
|
|
185
|
+
static async getOrCreateApiContext() {
|
|
186
|
+
if (!TestContext._apiContext) {
|
|
187
|
+
await TestContext.initApiContext();
|
|
188
|
+
}
|
|
189
|
+
return TestContext._apiContext;
|
|
190
|
+
}
|
|
191
|
+
// ✅ SIMPLIFICADO: Delegar para MobileConnection
|
|
192
|
+
static get appiumDriver() {
|
|
193
|
+
try {
|
|
194
|
+
return MobileConnection.getDriver();
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ✅ SIMPLIFICADO: Usar MobileConnection
|
|
201
|
+
static async createMobileSession(capabilities) {
|
|
202
|
+
const fullCapabilities = {
|
|
203
|
+
...capabilities,
|
|
204
|
+
deviceName: capabilities.deviceId, // deviceName é obrigatório
|
|
205
|
+
};
|
|
206
|
+
await MobileConnection.createSession(fullCapabilities);
|
|
207
|
+
}
|
|
208
|
+
// ✅ SIMPLIFICADO: Usar MobileConnection
|
|
209
|
+
static async resetAppiumDriver() {
|
|
210
|
+
await MobileConnection.closeSession();
|
|
211
|
+
}
|
|
212
|
+
// ✅ SIMPLIFICADO: Captura de screenshot delegada
|
|
213
|
+
static async captureScreenshot(nome = 'screenshot') {
|
|
214
|
+
try {
|
|
215
|
+
// Frontend screenshot
|
|
216
|
+
if (TestContext._page &&
|
|
217
|
+
typeof TestContext._page.screenshot === 'function') {
|
|
218
|
+
return await TestContext._page.screenshot({
|
|
219
|
+
fullPage: true,
|
|
220
|
+
type: 'png',
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// Mobile screenshot
|
|
224
|
+
return await MobileConnection.captureScreenshotBuffer();
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
static clear() {
|
|
231
|
+
TestContext._testInfo = null;
|
|
232
|
+
TestContext._page = null;
|
|
233
|
+
TestContext._apiContext = null;
|
|
234
|
+
TestContext._pageFactory = null;
|
|
235
|
+
TestContext._pagePromise = null;
|
|
236
|
+
// Mobile connection é gerenciada pela MobileConnection
|
|
237
|
+
}
|
|
238
|
+
static async finalizeAll() {
|
|
239
|
+
if (TestContext._apiContext) {
|
|
240
|
+
await TestContext._apiContext.dispose();
|
|
241
|
+
TestContext._apiContext = null;
|
|
242
|
+
}
|
|
243
|
+
await MobileConnection.closeSession();
|
|
244
|
+
TestContext.clear();
|
|
245
|
+
}
|
|
246
|
+
static forceCleanup() {
|
|
247
|
+
try {
|
|
248
|
+
// Limpeza geral
|
|
249
|
+
TestContext._testInfo = null;
|
|
250
|
+
TestContext._page = null;
|
|
251
|
+
TestContext._pageFactory = null;
|
|
252
|
+
TestContext._pagePromise = null;
|
|
253
|
+
// Limpeza API context
|
|
254
|
+
if (TestContext._apiContext) {
|
|
255
|
+
TestContext._apiContext.dispose().catch(() => { }); // Silenciosamente ignorar erros
|
|
256
|
+
TestContext._apiContext = null;
|
|
257
|
+
}
|
|
258
|
+
// Limpeza mobile delegada
|
|
259
|
+
MobileConnection.forceCleanup();
|
|
260
|
+
Logger.info('🔧 Limpeza forçada do TestContext aplicada');
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
// Silenciosamente ignorar erros na limpeza forçada
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 🆕 CRÍTICO: Garantir disponibilidade global em projetos consumidores
|
|
268
|
+
* Este método força a exportação do TestContext no globalThis
|
|
269
|
+
* para que funcione em qualquer projeto, mesmo sem import direto
|
|
270
|
+
*/
|
|
271
|
+
static ensureGlobalAvailability() {
|
|
272
|
+
try {
|
|
273
|
+
// Garantir que TestContext está disponível globalmente
|
|
274
|
+
if (!globalThis.__TEST_CONTEXT__) {
|
|
275
|
+
;
|
|
276
|
+
globalThis.__TEST_CONTEXT__ = TestContext;
|
|
277
|
+
Logger.info('🌐 [TestContext] Exportado para globalThis.__TEST_CONTEXT__');
|
|
278
|
+
}
|
|
279
|
+
// Fallback adicional para compatibilidade browser
|
|
280
|
+
if (typeof globalThis.window !== 'undefined' &&
|
|
281
|
+
!globalThis.window?.__TEST_CONTEXT__) {
|
|
282
|
+
;
|
|
283
|
+
globalThis.window.__TEST_CONTEXT__ = TestContext;
|
|
284
|
+
Logger.info('🌐 [TestContext] Exportado para window.__TEST_CONTEXT__');
|
|
285
|
+
}
|
|
286
|
+
// Para Node.js
|
|
287
|
+
if (typeof global !== 'undefined' &&
|
|
288
|
+
!globalThis.global?.__TEST_CONTEXT__) {
|
|
289
|
+
;
|
|
290
|
+
globalThis.global.__TEST_CONTEXT__ = TestContext;
|
|
291
|
+
Logger.info('🌐 [TestContext] Exportado para global.__TEST_CONTEXT__');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
Logger.warning(`⚠️ [TestContext] Erro ao garantir disponibilidade global: ${error}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// ============================================
|
|
299
|
+
// 🔐 MÉTODOS DE AUTENTICAÇÃO E STORAGE STATE
|
|
300
|
+
// ============================================
|
|
301
|
+
/**
|
|
302
|
+
* 💾 Salva o estado de autenticação atual (cookies + localStorage + sessionStorage)
|
|
303
|
+
* @param filePath Caminho opcional para salvar (padrão: ./test-results/auth/auth-state.json)
|
|
304
|
+
* @example
|
|
305
|
+
* // Após fazer login
|
|
306
|
+
* await TestContext.saveAuthState('./auth/admin-user.json')
|
|
307
|
+
*/
|
|
308
|
+
static async saveAuthState(filePath) {
|
|
309
|
+
const page = TestContext.getPage();
|
|
310
|
+
return await AuthStateManager.saveState(page, filePath);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* 🔄 Restaura o estado de autenticação salvo
|
|
314
|
+
* @param filePath Caminho do arquivo de estado
|
|
315
|
+
* @example
|
|
316
|
+
* // Antes de rodar testes
|
|
317
|
+
* await TestContext.restoreAuthState('./auth/admin-user.json')
|
|
318
|
+
*/
|
|
319
|
+
static async restoreAuthState(filePath) {
|
|
320
|
+
const page = TestContext.getPage();
|
|
321
|
+
await AuthStateManager.restoreState(page, filePath);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* 🧹 Limpa todo o estado de autenticação
|
|
325
|
+
* @example
|
|
326
|
+
* // Logout completo
|
|
327
|
+
* await TestContext.clearAuthState()
|
|
328
|
+
*/
|
|
329
|
+
static async clearAuthState() {
|
|
330
|
+
const page = TestContext.getPage();
|
|
331
|
+
await AuthStateManager.clearState(page);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* 📄 Verifica se existe um arquivo de estado salvo
|
|
335
|
+
* @param filePath Caminho do arquivo
|
|
336
|
+
*/
|
|
337
|
+
static authStateExists(filePath) {
|
|
338
|
+
return AuthStateManager.stateExists(filePath);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* 🔍 Lê o estado salvo sem aplicar
|
|
342
|
+
* @param filePath Caminho do arquivo
|
|
343
|
+
*/
|
|
344
|
+
static readAuthState(filePath) {
|
|
345
|
+
return AuthStateManager.readState(filePath);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 🗑️ Remove um arquivo de estado
|
|
349
|
+
* @param filePath Caminho do arquivo
|
|
350
|
+
*/
|
|
351
|
+
static deleteAuthState(filePath) {
|
|
352
|
+
return AuthStateManager.deleteState(filePath);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* 📋 Lista todos os estados salvos
|
|
356
|
+
*/
|
|
357
|
+
static listAuthStates() {
|
|
358
|
+
return AuthStateManager.listStates();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// ✅ Exportar TestContext globalmente para ES Modules
|
|
362
|
+
;
|
|
363
|
+
globalThis.__TEST_CONTEXT__ = TestContext;
|
|
364
|
+
// 🆕 CRÍTICO: Garantir disponibilidade em diferentes contextos
|
|
365
|
+
TestContext.ensureGlobalAvailability();
|
|
366
|
+
// 🆕 Executar novamente após um delay para projetos que carregam depois
|
|
367
|
+
setTimeout(() => {
|
|
368
|
+
TestContext.ensureGlobalAvailability();
|
|
369
|
+
}, 100);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TestResult } from './UnifiedReportManager.js';
|
|
2
|
+
export declare class UnifiedHtmlGenerator {
|
|
3
|
+
static generate(testes: TestResult[], inicio: Date, fim: Date, isIndividual?: boolean, tituloCustomizado?: string, projectName?: string, environment?: string, autocoreVersion?: string): Promise<Buffer>;
|
|
4
|
+
private static calcularEstatisticasPorTipo;
|
|
5
|
+
private static getCoresDosTipos;
|
|
6
|
+
private static getIconePorTipo;
|
|
7
|
+
}
|