@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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline estruturada de ações — coleta eventos durante execução dos testes
|
|
3
|
+
* e gera relatórios ao final.
|
|
4
|
+
* @module actions/ActionTimeline
|
|
5
|
+
*/
|
|
6
|
+
import type { ActionEvent, ActionEventStatus, ActionEventType, TimelineSummary } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Singleton que coleta todos os eventos de ação durante um teste.
|
|
9
|
+
* Usado internamente pelo WebActions para registrar cada ação.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ActionTimeline {
|
|
12
|
+
private static events;
|
|
13
|
+
private static enabled;
|
|
14
|
+
/** Habilitar/desabilitar a timeline (default: true). */
|
|
15
|
+
static setEnabled(value: boolean): void;
|
|
16
|
+
/** Limpar todos os eventos (chamar no início de cada teste). */
|
|
17
|
+
static reset(): void;
|
|
18
|
+
/** Registrar um evento na timeline. */
|
|
19
|
+
static record(type: ActionEventType, action: string, status: ActionEventStatus, duration: number, details?: Partial<Pick<ActionEvent, 'selector' | 'selectorType' | 'description' | 'error' | 'value' | 'metadata'>>): void;
|
|
20
|
+
/** Obter todos os eventos registrados. */
|
|
21
|
+
static getEvents(): ReadonlyArray<ActionEvent>;
|
|
22
|
+
/** Obter os últimos N eventos. */
|
|
23
|
+
static getLastEvents(n: number): ReadonlyArray<ActionEvent>;
|
|
24
|
+
/** Obter eventos de erro/falha. */
|
|
25
|
+
static getFailures(): ReadonlyArray<ActionEvent>;
|
|
26
|
+
/** Gerar resumo da timeline. */
|
|
27
|
+
static getSummary(): TimelineSummary;
|
|
28
|
+
/**
|
|
29
|
+
* Exportar timeline como JSON (para anexar ao relatório de teste).
|
|
30
|
+
*/
|
|
31
|
+
static toJSON(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Exportar timeline como tabela legível para logs.
|
|
34
|
+
*/
|
|
35
|
+
static toTable(): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton que coleta todos os eventos de ação durante um teste.
|
|
3
|
+
* Usado internamente pelo WebActions para registrar cada ação.
|
|
4
|
+
*/
|
|
5
|
+
export class ActionTimeline {
|
|
6
|
+
static events = [];
|
|
7
|
+
static enabled = true;
|
|
8
|
+
/** Habilitar/desabilitar a timeline (default: true). */
|
|
9
|
+
static setEnabled(value) {
|
|
10
|
+
ActionTimeline.enabled = value;
|
|
11
|
+
}
|
|
12
|
+
/** Limpar todos os eventos (chamar no início de cada teste). */
|
|
13
|
+
static reset() {
|
|
14
|
+
ActionTimeline.events = [];
|
|
15
|
+
}
|
|
16
|
+
/** Registrar um evento na timeline. */
|
|
17
|
+
static record(type, action, status, duration, details) {
|
|
18
|
+
if (!ActionTimeline.enabled)
|
|
19
|
+
return;
|
|
20
|
+
ActionTimeline.events.push({
|
|
21
|
+
timestamp: Date.now(),
|
|
22
|
+
type,
|
|
23
|
+
action,
|
|
24
|
+
status,
|
|
25
|
+
duration,
|
|
26
|
+
...details,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Obter todos os eventos registrados. */
|
|
30
|
+
static getEvents() {
|
|
31
|
+
return ActionTimeline.events;
|
|
32
|
+
}
|
|
33
|
+
/** Obter os últimos N eventos. */
|
|
34
|
+
static getLastEvents(n) {
|
|
35
|
+
return ActionTimeline.events.slice(-n);
|
|
36
|
+
}
|
|
37
|
+
/** Obter eventos de erro/falha. */
|
|
38
|
+
static getFailures() {
|
|
39
|
+
return ActionTimeline.events.filter(e => e.status === 'failure');
|
|
40
|
+
}
|
|
41
|
+
/** Gerar resumo da timeline. */
|
|
42
|
+
static getSummary() {
|
|
43
|
+
const events = ActionTimeline.events;
|
|
44
|
+
const byAction = {};
|
|
45
|
+
let slowest = null;
|
|
46
|
+
for (const e of events) {
|
|
47
|
+
if (!byAction[e.action]) {
|
|
48
|
+
byAction[e.action] = { count: 0, totalDuration: 0, failures: 0 };
|
|
49
|
+
}
|
|
50
|
+
byAction[e.action].count++;
|
|
51
|
+
byAction[e.action].totalDuration += e.duration;
|
|
52
|
+
if (e.status === 'failure')
|
|
53
|
+
byAction[e.action].failures++;
|
|
54
|
+
if (!slowest || e.duration > slowest.duration)
|
|
55
|
+
slowest = e;
|
|
56
|
+
}
|
|
57
|
+
const first = events[0]?.timestamp ?? 0;
|
|
58
|
+
const last = events.at(-1)?.timestamp ?? 0;
|
|
59
|
+
return {
|
|
60
|
+
totalEvents: events.length,
|
|
61
|
+
successes: events.filter(e => e.status === 'success').length,
|
|
62
|
+
failures: events.filter(e => e.status === 'failure').length,
|
|
63
|
+
retries: events.filter(e => e.status === 'retry').length,
|
|
64
|
+
totalDuration: last - first,
|
|
65
|
+
slowestAction: slowest,
|
|
66
|
+
byAction,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Exportar timeline como JSON (para anexar ao relatório de teste).
|
|
71
|
+
*/
|
|
72
|
+
static toJSON() {
|
|
73
|
+
return JSON.stringify({
|
|
74
|
+
events: ActionTimeline.events,
|
|
75
|
+
summary: ActionTimeline.getSummary(),
|
|
76
|
+
}, null, 2);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Exportar timeline como tabela legível para logs.
|
|
80
|
+
*/
|
|
81
|
+
static toTable() {
|
|
82
|
+
if (ActionTimeline.events.length === 0)
|
|
83
|
+
return '(nenhum evento registrado)';
|
|
84
|
+
const lines = ['# | Ação | Dur(ms) | Status | Seletor'];
|
|
85
|
+
const sep = '---|---------------------|---------|---------|--------';
|
|
86
|
+
lines.push(sep);
|
|
87
|
+
for (let i = 0; i < ActionTimeline.events.length; i++) {
|
|
88
|
+
const e = ActionTimeline.events[i];
|
|
89
|
+
const idx = String(i + 1).padStart(2);
|
|
90
|
+
const action = e.action.padEnd(19).slice(0, 19);
|
|
91
|
+
const dur = String(e.duration).padStart(7);
|
|
92
|
+
const status = e.status.padEnd(7).slice(0, 7);
|
|
93
|
+
const sel = (e.selector || '-').slice(0, 40);
|
|
94
|
+
lines.push(`${idx} | ${action} | ${dur} | ${status} | ${sel}`);
|
|
95
|
+
}
|
|
96
|
+
const summary = ActionTimeline.getSummary();
|
|
97
|
+
lines.push(sep);
|
|
98
|
+
lines.push(`Total: ${summary.totalEvents} eventos | ${summary.successes} ok | ${summary.failures} falhas | ${summary.totalDuration}ms`);
|
|
99
|
+
return lines.join('\n');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fila de recuperação assíncrona e não-bloqueante.
|
|
3
|
+
* As ações principais (click, fill, etc.) enfileiram falhas
|
|
4
|
+
* e o processamento ocorre em background, sem bloquear o fluxo.
|
|
5
|
+
* @module actions/RecoveryQueue
|
|
6
|
+
*/
|
|
7
|
+
/** Item na fila de recuperação. */
|
|
8
|
+
export interface RecoveryQueueItem {
|
|
9
|
+
/** ID único do item. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Timestamp de quando foi enfileirado. */
|
|
12
|
+
enqueuedAt: number;
|
|
13
|
+
/** Nome da ação que falhou (click, fill, etc.). */
|
|
14
|
+
action: string;
|
|
15
|
+
/** Seletor do elemento. */
|
|
16
|
+
selector: string;
|
|
17
|
+
/** Mensagem de erro. */
|
|
18
|
+
error: string;
|
|
19
|
+
/** Metadados do contexto (testName, methodName, etc.). */
|
|
20
|
+
context: Record<string, unknown>;
|
|
21
|
+
/** Status de processamento. */
|
|
22
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
23
|
+
/** Resultado do processamento (se disponível). */
|
|
24
|
+
result?: unknown;
|
|
25
|
+
}
|
|
26
|
+
type RecoveryHandler = (item: RecoveryQueueItem) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Fila de recuperação assíncrona.
|
|
29
|
+
*
|
|
30
|
+
* Falhas de ações são enfileiradas e processadas em background,
|
|
31
|
+
* sem bloquear a execução do teste principal.
|
|
32
|
+
*
|
|
33
|
+
* O processamento pode ser:
|
|
34
|
+
* - Automático (via handler registrado)
|
|
35
|
+
* - Manual (drenando a fila ao final do teste)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Registrar handler
|
|
40
|
+
* RecoveryQueue.onProcess(async (item) => {
|
|
41
|
+
* await analyzeFailure({ selector: item.selector, ... })
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* // Enfileirar falha (não bloqueia)
|
|
45
|
+
* RecoveryQueue.enqueue('click', '//button', 'Element not found', { test: 'CT001' })
|
|
46
|
+
*
|
|
47
|
+
* // Ao final do teste, drenar fila
|
|
48
|
+
* await RecoveryQueue.drain()
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class RecoveryQueue {
|
|
52
|
+
private static queue;
|
|
53
|
+
private static handler;
|
|
54
|
+
private static processing;
|
|
55
|
+
private static maxItems;
|
|
56
|
+
private static counter;
|
|
57
|
+
/** Registrar handler para processar itens da fila. */
|
|
58
|
+
static onProcess(handler: RecoveryHandler): void;
|
|
59
|
+
/** Enfileirar uma falha para processamento assíncrono. */
|
|
60
|
+
static enqueue(action: string, selector: string, error: string, context?: Record<string, unknown>): void;
|
|
61
|
+
/** Processar próximo item da fila. */
|
|
62
|
+
private static processNext;
|
|
63
|
+
/**
|
|
64
|
+
* Drenar a fila — processar todos os itens pendentes.
|
|
65
|
+
* Útil para chamar ao final do teste.
|
|
66
|
+
*/
|
|
67
|
+
static drain(): Promise<void>;
|
|
68
|
+
/** Obter itens da fila. */
|
|
69
|
+
static getItems(): ReadonlyArray<RecoveryQueueItem>;
|
|
70
|
+
/** Obter itens pendentes. */
|
|
71
|
+
static getPending(): ReadonlyArray<RecoveryQueueItem>;
|
|
72
|
+
/** Limpar a fila. */
|
|
73
|
+
static clear(): void;
|
|
74
|
+
/** Estatísticas da fila. */
|
|
75
|
+
static stats(): {
|
|
76
|
+
total: number;
|
|
77
|
+
pending: number;
|
|
78
|
+
completed: number;
|
|
79
|
+
failed: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fila de recuperação assíncrona e não-bloqueante.
|
|
3
|
+
* As ações principais (click, fill, etc.) enfileiram falhas
|
|
4
|
+
* e o processamento ocorre em background, sem bloquear o fluxo.
|
|
5
|
+
* @module actions/RecoveryQueue
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Fila de recuperação assíncrona.
|
|
9
|
+
*
|
|
10
|
+
* Falhas de ações são enfileiradas e processadas em background,
|
|
11
|
+
* sem bloquear a execução do teste principal.
|
|
12
|
+
*
|
|
13
|
+
* O processamento pode ser:
|
|
14
|
+
* - Automático (via handler registrado)
|
|
15
|
+
* - Manual (drenando a fila ao final do teste)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Registrar handler
|
|
20
|
+
* RecoveryQueue.onProcess(async (item) => {
|
|
21
|
+
* await analyzeFailure({ selector: item.selector, ... })
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Enfileirar falha (não bloqueia)
|
|
25
|
+
* RecoveryQueue.enqueue('click', '//button', 'Element not found', { test: 'CT001' })
|
|
26
|
+
*
|
|
27
|
+
* // Ao final do teste, drenar fila
|
|
28
|
+
* await RecoveryQueue.drain()
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class RecoveryQueue {
|
|
32
|
+
static queue = [];
|
|
33
|
+
static handler = null;
|
|
34
|
+
static processing = false;
|
|
35
|
+
static maxItems = 50;
|
|
36
|
+
static counter = 0;
|
|
37
|
+
/** Registrar handler para processar itens da fila. */
|
|
38
|
+
static onProcess(handler) {
|
|
39
|
+
RecoveryQueue.handler = handler;
|
|
40
|
+
}
|
|
41
|
+
/** Enfileirar uma falha para processamento assíncrono. */
|
|
42
|
+
static enqueue(action, selector, error, context = {}) {
|
|
43
|
+
// Limitar tamanho da fila
|
|
44
|
+
if (RecoveryQueue.queue.length >= RecoveryQueue.maxItems) {
|
|
45
|
+
RecoveryQueue.queue.shift(); // Remover mais antigo
|
|
46
|
+
}
|
|
47
|
+
const item = {
|
|
48
|
+
id: `rq-${++RecoveryQueue.counter}-${Date.now()}`,
|
|
49
|
+
enqueuedAt: Date.now(),
|
|
50
|
+
action,
|
|
51
|
+
selector,
|
|
52
|
+
error,
|
|
53
|
+
context,
|
|
54
|
+
status: 'pending',
|
|
55
|
+
};
|
|
56
|
+
RecoveryQueue.queue.push(item);
|
|
57
|
+
// Tentar processar em background (fire-and-forget)
|
|
58
|
+
if (RecoveryQueue.handler && !RecoveryQueue.processing) {
|
|
59
|
+
RecoveryQueue.processNext().catch(() => { });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Processar próximo item da fila. */
|
|
63
|
+
static async processNext() {
|
|
64
|
+
if (RecoveryQueue.processing || !RecoveryQueue.handler)
|
|
65
|
+
return;
|
|
66
|
+
const item = RecoveryQueue.queue.find(i => i.status === 'pending');
|
|
67
|
+
if (!item)
|
|
68
|
+
return;
|
|
69
|
+
RecoveryQueue.processing = true;
|
|
70
|
+
item.status = 'processing';
|
|
71
|
+
try {
|
|
72
|
+
await RecoveryQueue.handler(item);
|
|
73
|
+
item.status = 'completed';
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
item.status = 'failed';
|
|
77
|
+
item.result = err instanceof Error ? err.message : String(err);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
RecoveryQueue.processing = false;
|
|
81
|
+
}
|
|
82
|
+
// Continuar com o próximo
|
|
83
|
+
const hasPending = RecoveryQueue.queue.some(i => i.status === 'pending');
|
|
84
|
+
if (hasPending) {
|
|
85
|
+
RecoveryQueue.processNext().catch(() => { });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Drenar a fila — processar todos os itens pendentes.
|
|
90
|
+
* Útil para chamar ao final do teste.
|
|
91
|
+
*/
|
|
92
|
+
static async drain() {
|
|
93
|
+
if (!RecoveryQueue.handler)
|
|
94
|
+
return;
|
|
95
|
+
for (const item of RecoveryQueue.queue) {
|
|
96
|
+
if (item.status !== 'pending')
|
|
97
|
+
continue;
|
|
98
|
+
item.status = 'processing';
|
|
99
|
+
try {
|
|
100
|
+
await RecoveryQueue.handler(item);
|
|
101
|
+
item.status = 'completed';
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
item.status = 'failed';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Obter itens da fila. */
|
|
109
|
+
static getItems() {
|
|
110
|
+
return RecoveryQueue.queue;
|
|
111
|
+
}
|
|
112
|
+
/** Obter itens pendentes. */
|
|
113
|
+
static getPending() {
|
|
114
|
+
return RecoveryQueue.queue.filter(i => i.status === 'pending');
|
|
115
|
+
}
|
|
116
|
+
/** Limpar a fila. */
|
|
117
|
+
static clear() {
|
|
118
|
+
RecoveryQueue.queue = [];
|
|
119
|
+
RecoveryQueue.counter = 0;
|
|
120
|
+
}
|
|
121
|
+
/** Estatísticas da fila. */
|
|
122
|
+
static stats() {
|
|
123
|
+
return {
|
|
124
|
+
total: RecoveryQueue.queue.length,
|
|
125
|
+
pending: RecoveryQueue.queue.filter(i => i.status === 'pending').length,
|
|
126
|
+
completed: RecoveryQueue.queue.filter(i => i.status === 'completed').length,
|
|
127
|
+
failed: RecoveryQueue.queue.filter(i => i.status === 'failed').length,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache de seletores com TTL — evita queries DOM repetitivas.
|
|
3
|
+
* @module actions/SelectorCache
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Cache de seletores com TTL curto para reduzir queries DOM repetitivas.
|
|
7
|
+
*
|
|
8
|
+
* Quando um seletor (ou suas variantes) é resolvido com sucesso,
|
|
9
|
+
* o resultado é cacheado. Chamadas subsequentes dentro do TTL
|
|
10
|
+
* retornam o valor cacheado sem re-processar variantes.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // No primeiro uso, gera candidatos e busca no DOM
|
|
15
|
+
* const sel = SelectorCache.getOrResolve(xpath, candidatesFn)
|
|
16
|
+
*
|
|
17
|
+
* // No segundo uso (dentro do TTL), retorna do cache
|
|
18
|
+
* const sel2 = SelectorCache.getOrResolve(xpath, candidatesFn)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class SelectorCache {
|
|
22
|
+
private static cache;
|
|
23
|
+
/** TTL padrão em ms (default: 500ms — curto para não ficar stale). */
|
|
24
|
+
private static ttlMs;
|
|
25
|
+
/** Máximo de entradas no cache para evitar memory leak. */
|
|
26
|
+
private static maxEntries;
|
|
27
|
+
/**
|
|
28
|
+
* Busca seletor no cache. Retorna null se não encontrado ou expirado.
|
|
29
|
+
*/
|
|
30
|
+
static get(originalSelector: string): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Armazena resultado resolvido no cache.
|
|
33
|
+
*/
|
|
34
|
+
static set(originalSelector: string, resolvedSelector: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Busca no cache ou resolve via callback.
|
|
37
|
+
* Se o cache tem resultado válido, retorna direto.
|
|
38
|
+
* Caso contrário, chama resolveFn e armazena o resultado.
|
|
39
|
+
*/
|
|
40
|
+
static getOrResolve(originalSelector: string, resolveFn: () => Promise<string | null>): Promise<string | null>;
|
|
41
|
+
/** Limpar todo o cache (chamar entre testes ou navegações). */
|
|
42
|
+
static clear(): void;
|
|
43
|
+
/** Remover entradas expiradas manualmente. */
|
|
44
|
+
static prune(): void;
|
|
45
|
+
/** Estatísticas do cache. */
|
|
46
|
+
static stats(): {
|
|
47
|
+
size: number;
|
|
48
|
+
ttlMs: number;
|
|
49
|
+
maxEntries: number;
|
|
50
|
+
};
|
|
51
|
+
/** Configurar TTL. */
|
|
52
|
+
static setTTL(ms: number): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache de seletores com TTL — evita queries DOM repetitivas.
|
|
3
|
+
* @module actions/SelectorCache
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Cache de seletores com TTL curto para reduzir queries DOM repetitivas.
|
|
7
|
+
*
|
|
8
|
+
* Quando um seletor (ou suas variantes) é resolvido com sucesso,
|
|
9
|
+
* o resultado é cacheado. Chamadas subsequentes dentro do TTL
|
|
10
|
+
* retornam o valor cacheado sem re-processar variantes.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // No primeiro uso, gera candidatos e busca no DOM
|
|
15
|
+
* const sel = SelectorCache.getOrResolve(xpath, candidatesFn)
|
|
16
|
+
*
|
|
17
|
+
* // No segundo uso (dentro do TTL), retorna do cache
|
|
18
|
+
* const sel2 = SelectorCache.getOrResolve(xpath, candidatesFn)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class SelectorCache {
|
|
22
|
+
static cache = new Map();
|
|
23
|
+
/** TTL padrão em ms (default: 500ms — curto para não ficar stale). */
|
|
24
|
+
static ttlMs = Number(process.env.AUTOCORE_SELECTOR_CACHE_TTL_MS || '500');
|
|
25
|
+
/** Máximo de entradas no cache para evitar memory leak. */
|
|
26
|
+
static maxEntries = 200;
|
|
27
|
+
/**
|
|
28
|
+
* Busca seletor no cache. Retorna null se não encontrado ou expirado.
|
|
29
|
+
*/
|
|
30
|
+
static get(originalSelector) {
|
|
31
|
+
const entry = SelectorCache.cache.get(originalSelector);
|
|
32
|
+
if (!entry)
|
|
33
|
+
return null;
|
|
34
|
+
if (Date.now() - entry.cachedAt > SelectorCache.ttlMs) {
|
|
35
|
+
SelectorCache.cache.delete(originalSelector);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return entry.resolvedSelector;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Armazena resultado resolvido no cache.
|
|
42
|
+
*/
|
|
43
|
+
static set(originalSelector, resolvedSelector) {
|
|
44
|
+
// Evitar crescimento infinito
|
|
45
|
+
if (SelectorCache.cache.size >= SelectorCache.maxEntries) {
|
|
46
|
+
// Remover entradas mais antigas (FIFO)
|
|
47
|
+
const firstKey = SelectorCache.cache.keys().next().value;
|
|
48
|
+
if (firstKey)
|
|
49
|
+
SelectorCache.cache.delete(firstKey);
|
|
50
|
+
}
|
|
51
|
+
SelectorCache.cache.set(originalSelector, {
|
|
52
|
+
resolvedSelector,
|
|
53
|
+
cachedAt: Date.now(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Busca no cache ou resolve via callback.
|
|
58
|
+
* Se o cache tem resultado válido, retorna direto.
|
|
59
|
+
* Caso contrário, chama resolveFn e armazena o resultado.
|
|
60
|
+
*/
|
|
61
|
+
static async getOrResolve(originalSelector, resolveFn) {
|
|
62
|
+
const cached = SelectorCache.get(originalSelector);
|
|
63
|
+
if (cached)
|
|
64
|
+
return cached;
|
|
65
|
+
const resolved = await resolveFn();
|
|
66
|
+
if (resolved) {
|
|
67
|
+
SelectorCache.set(originalSelector, resolved);
|
|
68
|
+
}
|
|
69
|
+
return resolved;
|
|
70
|
+
}
|
|
71
|
+
/** Limpar todo o cache (chamar entre testes ou navegações). */
|
|
72
|
+
static clear() {
|
|
73
|
+
SelectorCache.cache.clear();
|
|
74
|
+
}
|
|
75
|
+
/** Remover entradas expiradas manualmente. */
|
|
76
|
+
static prune() {
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
for (const [key, entry] of SelectorCache.cache) {
|
|
79
|
+
if (now - entry.cachedAt > SelectorCache.ttlMs) {
|
|
80
|
+
SelectorCache.cache.delete(key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Estatísticas do cache. */
|
|
85
|
+
static stats() {
|
|
86
|
+
return {
|
|
87
|
+
size: SelectorCache.cache.size,
|
|
88
|
+
ttlMs: SelectorCache.ttlMs,
|
|
89
|
+
maxEntries: SelectorCache.maxEntries,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Configurar TTL. */
|
|
93
|
+
static setTTL(ms) {
|
|
94
|
+
SelectorCache.ttlMs = ms;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Módulos auxiliares para o WebActions — tipos, cache, timeline e fila de recovery.
|
|
3
|
+
*
|
|
4
|
+
* WebActions continua como fachada principal. Estes módulos são usados
|
|
5
|
+
* internamente e também podem ser importados diretamente quando necessário.
|
|
6
|
+
*
|
|
7
|
+
* @module actions
|
|
8
|
+
*/
|
|
9
|
+
export type { ClickOptions, FillOptions, SelectOptions, HoverOptions, ScreenshotOptions, ScrollOptions, KeyboardOptions, NavigationOptions, WaitOptions, ActionEvent, ActionEventType, ActionEventStatus, TimelineSummary, } from './types.js';
|
|
10
|
+
export { ActionTimeline } from './ActionTimeline.js';
|
|
11
|
+
export { SelectorCache } from './SelectorCache.js';
|
|
12
|
+
export { RecoveryQueue } from './RecoveryQueue.js';
|
|
13
|
+
export type { RecoveryQueueItem } from './RecoveryQueue.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Módulos auxiliares para o WebActions — tipos, cache, timeline e fila de recovery.
|
|
3
|
+
*
|
|
4
|
+
* WebActions continua como fachada principal. Estes módulos são usados
|
|
5
|
+
* internamente e também podem ser importados diretamente quando necessário.
|
|
6
|
+
*
|
|
7
|
+
* @module actions
|
|
8
|
+
*/
|
|
9
|
+
// Timeline de ações (Item 7)
|
|
10
|
+
export { ActionTimeline } from './ActionTimeline.js';
|
|
11
|
+
// Cache de seletores (Item 5)
|
|
12
|
+
export { SelectorCache } from './SelectorCache.js';
|
|
13
|
+
// Fila de recovery assíncrona (Item 6)
|
|
14
|
+
export { RecoveryQueue } from './RecoveryQueue.js';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos compartilhados para os módulos de ações do WebActions.
|
|
3
|
+
* @module actions/types
|
|
4
|
+
*/
|
|
5
|
+
/** Opções para ações de click. */
|
|
6
|
+
export interface ClickOptions {
|
|
7
|
+
/** Timeout em ms (default: project timeout). */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** Forçar click mesmo se o elemento estiver coberto. */
|
|
10
|
+
force?: boolean;
|
|
11
|
+
/** Botão do mouse. */
|
|
12
|
+
button?: 'left' | 'middle' | 'right';
|
|
13
|
+
/** Posição relativa ao canto superior-esquerdo do elemento. */
|
|
14
|
+
position?: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
/** Número de cliques (1=single, 2=double). */
|
|
19
|
+
clickCount?: number;
|
|
20
|
+
/** Delay entre mousedown e mouseup em ms. */
|
|
21
|
+
delay?: number;
|
|
22
|
+
/** Modificadores de tecla pressionados durante o click. */
|
|
23
|
+
modifiers?: Array<'Alt' | 'Control' | 'Meta' | 'Shift'>;
|
|
24
|
+
/** Se deve aguardar navegação após o click. */
|
|
25
|
+
noWaitAfter?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Opções para ações de fill/type. */
|
|
28
|
+
export interface FillOptions {
|
|
29
|
+
/** Timeout em ms. */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/** Se deve aguardar navegação após preencher. */
|
|
32
|
+
noWaitAfter?: boolean;
|
|
33
|
+
/** Se deve forçar a limpeza antes de preencher. */
|
|
34
|
+
force?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Opções para ações de select. */
|
|
37
|
+
export interface SelectOptions {
|
|
38
|
+
/** Timeout em ms. */
|
|
39
|
+
timeout?: number;
|
|
40
|
+
/** Se deve forçar a seleção. */
|
|
41
|
+
force?: boolean;
|
|
42
|
+
/** Se deve aguardar navegação. */
|
|
43
|
+
noWaitAfter?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Opções para ações de hover. */
|
|
46
|
+
export interface HoverOptions {
|
|
47
|
+
/** Timeout em ms. */
|
|
48
|
+
timeout?: number;
|
|
49
|
+
/** Posição relativa ao elemento. */
|
|
50
|
+
position?: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
};
|
|
54
|
+
/** Forçar hover mesmo se coberto. */
|
|
55
|
+
force?: boolean;
|
|
56
|
+
/** Modificadores de tecla. */
|
|
57
|
+
modifiers?: Array<'Alt' | 'Control' | 'Meta' | 'Shift'>;
|
|
58
|
+
}
|
|
59
|
+
/** Opções para ações de screenshot. */
|
|
60
|
+
export interface ScreenshotOptions {
|
|
61
|
+
/** Caminho para salvar o arquivo. */
|
|
62
|
+
path?: string;
|
|
63
|
+
/** Tipo de imagem. */
|
|
64
|
+
type?: 'png' | 'jpeg';
|
|
65
|
+
/** Qualidade (0-100, apenas jpeg). */
|
|
66
|
+
quality?: number;
|
|
67
|
+
/** Capturar página inteira vs viewport. */
|
|
68
|
+
fullPage?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** Opções para ações de scroll. */
|
|
71
|
+
export interface ScrollOptions {
|
|
72
|
+
/** Timeout em ms. */
|
|
73
|
+
timeout?: number;
|
|
74
|
+
/** Comportamento de scroll. */
|
|
75
|
+
behavior?: 'auto' | 'smooth';
|
|
76
|
+
}
|
|
77
|
+
/** Opções para ações de keyboard. */
|
|
78
|
+
export interface KeyboardOptions {
|
|
79
|
+
/** Timeout em ms. */
|
|
80
|
+
timeout?: number;
|
|
81
|
+
/** Delay entre keydown e keyup em ms. */
|
|
82
|
+
delay?: number;
|
|
83
|
+
}
|
|
84
|
+
/** Opções para ações de navegação. */
|
|
85
|
+
export interface NavigationOptions {
|
|
86
|
+
/** Timeout em ms. */
|
|
87
|
+
timeout?: number;
|
|
88
|
+
/** Condição para considerar a navegação completa. */
|
|
89
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
|
90
|
+
}
|
|
91
|
+
/** Opções para ações de wait. */
|
|
92
|
+
export interface WaitOptions {
|
|
93
|
+
/** Timeout em ms. */
|
|
94
|
+
timeout?: number;
|
|
95
|
+
/** Estado esperado do elemento. */
|
|
96
|
+
state?: 'attached' | 'detached' | 'visible' | 'hidden';
|
|
97
|
+
}
|
|
98
|
+
/** Tipo de evento na timeline. */
|
|
99
|
+
export type ActionEventType = 'action' | 'wait' | 'assertion' | 'navigation' | 'error' | 'recovery';
|
|
100
|
+
/** Status do evento. */
|
|
101
|
+
export type ActionEventStatus = 'success' | 'failure' | 'retry' | 'skipped';
|
|
102
|
+
/** Evento individual na timeline de ações. */
|
|
103
|
+
export interface ActionEvent {
|
|
104
|
+
/** Timestamp de início (Date.now()). */
|
|
105
|
+
timestamp: number;
|
|
106
|
+
/** Tipo do evento. */
|
|
107
|
+
type: ActionEventType;
|
|
108
|
+
/** Nome da ação (click, fill, waitForVisible, etc.). */
|
|
109
|
+
action: string;
|
|
110
|
+
/** Duração em ms. */
|
|
111
|
+
duration: number;
|
|
112
|
+
/** Seletor do elemento (se aplicável). */
|
|
113
|
+
selector?: string;
|
|
114
|
+
/** Tipo do seletor (XPath, CSS, Locator). */
|
|
115
|
+
selectorType?: string;
|
|
116
|
+
/** Status do evento. */
|
|
117
|
+
status: ActionEventStatus;
|
|
118
|
+
/** Descrição da ação (do parâmetro descricao). */
|
|
119
|
+
description?: string;
|
|
120
|
+
/** Mensagem de erro (se houver). */
|
|
121
|
+
error?: string;
|
|
122
|
+
/** Valor envolvido na ação (texto preenchido, opção selecionada). */
|
|
123
|
+
value?: string;
|
|
124
|
+
/** Metadados extras. */
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
}
|
|
127
|
+
/** Resumo da timeline. */
|
|
128
|
+
export interface TimelineSummary {
|
|
129
|
+
/** Total de eventos. */
|
|
130
|
+
totalEvents: number;
|
|
131
|
+
/** Total de sucesso. */
|
|
132
|
+
successes: number;
|
|
133
|
+
/** Total de falhas. */
|
|
134
|
+
failures: number;
|
|
135
|
+
/** Total de retries. */
|
|
136
|
+
retries: number;
|
|
137
|
+
/** Duração total (primeiro ao último evento). */
|
|
138
|
+
totalDuration: number;
|
|
139
|
+
/** Evento mais lento. */
|
|
140
|
+
slowestAction: ActionEvent | null;
|
|
141
|
+
/** Breakdown por tipo de ação. */
|
|
142
|
+
byAction: Record<string, {
|
|
143
|
+
count: number;
|
|
144
|
+
totalDuration: number;
|
|
145
|
+
failures: number;
|
|
146
|
+
}>;
|
|
147
|
+
}
|