prompttest-mobile 1.5.1
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/CONTRIBUTING.md +80 -0
- package/LICENSE +42 -0
- package/LICENSES.md +81 -0
- package/README.md +526 -0
- package/SECURITY.md +56 -0
- package/TERMS.md +138 -0
- package/dist/bin/prompttest.d.ts +2 -0
- package/dist/bin/prompttest.js +1418 -0
- package/dist/bin/server.d.ts +1 -0
- package/dist/constants/commands.d.ts +125 -0
- package/dist/engine.bundle.js +1039 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +1039 -0
- package/dist/lib/adaptive-timing.d.ts +55 -0
- package/dist/lib/adb-provisioner.d.ts +55 -0
- package/dist/lib/adb.d.ts +448 -0
- package/dist/lib/ai/heuristic-resolver.d.ts +19 -0
- package/dist/lib/ai/index.d.ts +16 -0
- package/dist/lib/ai/llm-provider.d.ts +40 -0
- package/dist/lib/ai/types.d.ts +64 -0
- package/dist/lib/baseline.d.ts +159 -0
- package/dist/lib/benchmark.d.ts +100 -0
- package/dist/lib/checkpoint.d.ts +61 -0
- package/dist/lib/ci.d.ts +49 -0
- package/dist/lib/config-loader.d.ts +87 -0
- package/dist/lib/config.d.ts +136 -0
- package/dist/lib/crawler.d.ts +335 -0
- package/dist/lib/data-loader.d.ts +53 -0
- package/dist/lib/dfs-engine.d.ts +149 -0
- package/dist/lib/dictionary.d.ts +41 -0
- package/dist/lib/doctor.d.ts +45 -0
- package/dist/lib/driver-interface.d.ts +50 -0
- package/dist/lib/enterprise.d.ts +71 -0
- package/dist/lib/errors.d.ts +68 -0
- package/dist/lib/explorer.d.ts +165 -0
- package/dist/lib/feedback.d.ts +35 -0
- package/dist/lib/form-filler.d.ts +101 -0
- package/dist/lib/ios-driver.d.ts +38 -0
- package/dist/lib/jail-guard.d.ts +59 -0
- package/dist/lib/license.d.ts +51 -0
- package/dist/lib/live-server.d.ts +52 -0
- package/dist/lib/lock.d.ts +30 -0
- package/dist/lib/logger.d.ts +68 -0
- package/dist/lib/memory.d.ts +259 -0
- package/dist/lib/patterns.d.ts +202 -0
- package/dist/lib/profiler.d.ts +75 -0
- package/dist/lib/prompt-runner.d.ts +101 -0
- package/dist/lib/quiescence.d.ts +44 -0
- package/dist/lib/recorder.d.ts +155 -0
- package/dist/lib/repl.d.ts +29 -0
- package/dist/lib/reporter.d.ts +269 -0
- package/dist/lib/runner-utils.d.ts +316 -0
- package/dist/lib/scaffold.d.ts +53 -0
- package/dist/lib/step-handlers.d.ts +390 -0
- package/dist/lib/triage.d.ts +50 -0
- package/dist/lib/wizard.d.ts +42 -0
- package/dist/lib/zip-util.d.ts +36 -0
- package/docs/ARCHITECTURE.md +154 -0
- package/docs/CLI_CONTRACT.md +131 -0
- package/docs/CLI_STUDIO_CONTRACT.md +123 -0
- package/docs/PERFORMANCE_BASELINE.md +71 -0
- package/docs/PRODUCT_STATUS.md +56 -0
- package/docs/USER_MANUAL.md +764 -0
- package/package.json +66 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AndroidDriver } from './adb.js';
|
|
2
|
+
import { QaReportData, Reporter } from './reporter.js';
|
|
3
|
+
import { MemoryEngine } from './memory.js';
|
|
4
|
+
import { CheckpointManager } from './checkpoint.js';
|
|
5
|
+
import { BaselineManager } from './baseline.js';
|
|
6
|
+
import { SemanticResolver } from './ai/index.js';
|
|
7
|
+
import { type PromptStep, type PromptStepType, type RunOptions } from './runner-utils.js';
|
|
8
|
+
export type { PromptStep, PromptStepType, RunOptions };
|
|
9
|
+
/**
|
|
10
|
+
* Core engine responsible for parsing test specs and coordinating execution
|
|
11
|
+
* on an Android device using the provided driver and services.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PromptRunner {
|
|
14
|
+
private driver;
|
|
15
|
+
private memory;
|
|
16
|
+
private reporter;
|
|
17
|
+
private checkpoints;
|
|
18
|
+
private baselines;
|
|
19
|
+
private lastHierarchy;
|
|
20
|
+
private screenDimensions;
|
|
21
|
+
private navBarHeight;
|
|
22
|
+
private targetPackage;
|
|
23
|
+
/**
|
|
24
|
+
* Initializes a new instance of the PromptRunner.
|
|
25
|
+
* Uses dependency injection for core services, defaulting to singletons if omitted.
|
|
26
|
+
*
|
|
27
|
+
* @param driver - The Android ADB driver for device communication.
|
|
28
|
+
* @param memory - The memory engine for storing and retrieving learned locators.
|
|
29
|
+
* @param reporter - The reporting engine for test results.
|
|
30
|
+
* @param checkpoints - Manager for test step checkpoints and resuming.
|
|
31
|
+
* @param baselines - Manager for visual baseline testing.
|
|
32
|
+
*/
|
|
33
|
+
constructor(driver?: AndroidDriver, memory?: MemoryEngine, reporter?: Reporter, checkpoints?: CheckpointManager, baselines?: BaselineManager, semanticResolver?: SemanticResolver);
|
|
34
|
+
private semanticResolver;
|
|
35
|
+
private healEnabled;
|
|
36
|
+
private activeLocale;
|
|
37
|
+
private runtimeVariables;
|
|
38
|
+
private loopStack;
|
|
39
|
+
/**
|
|
40
|
+
* Recursively expands `INCLUDE '<path>'` directives within a spec file.
|
|
41
|
+
* Resolves paths relative to current spec directory and guards against circular recursion.
|
|
42
|
+
*
|
|
43
|
+
* @param specFilePath - Path to the root spec file.
|
|
44
|
+
* @param visitedFiles - Set of visited absolute file paths in the recursion stack.
|
|
45
|
+
* @returns The fully expanded spec string.
|
|
46
|
+
* @throws SpecRecursionError if circular spec inclusion is detected.
|
|
47
|
+
*/
|
|
48
|
+
expandSpecIncludes(specFilePath: string, visitedFiles?: Set<string>): string;
|
|
49
|
+
/**
|
|
50
|
+
* Expands high-level macro steps in a test spec into concrete primitive actions.
|
|
51
|
+
*
|
|
52
|
+
* @param specText - Original spec text containing potential high-level intents.
|
|
53
|
+
* @param resolver - Optional custom semantic resolver.
|
|
54
|
+
* @returns The expanded specification string and count of expanded steps.
|
|
55
|
+
*/
|
|
56
|
+
expandSpec(specText: string, resolver?: SemanticResolver): Promise<{
|
|
57
|
+
expanded: string;
|
|
58
|
+
stepsAdded: number;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Parses a multi-line, plain-English test specification into a structured array of actionable steps.
|
|
62
|
+
* Understands variable interpolation, optional steps, flow control blocks (IF, LOOP), and all action types.
|
|
63
|
+
*
|
|
64
|
+
* @param promptText - The raw plain-English spec to parse.
|
|
65
|
+
* @param customVars - Optional key-value pairs for string interpolation.
|
|
66
|
+
* @returns An array of parsed PromptStep objects structured into an execution AST.
|
|
67
|
+
*/
|
|
68
|
+
parsePrompt(promptText: string, customVars?: Record<string, string>): PromptStep[];
|
|
69
|
+
/**
|
|
70
|
+
* Executes a plain-English test spec against the connected Android device.
|
|
71
|
+
* Handles device locking, memory loading, sequential execution, checkpointing,
|
|
72
|
+
* error recovery, and final report generation.
|
|
73
|
+
*
|
|
74
|
+
* @param specFilePath - The absolute or relative path to the plain-English spec file.
|
|
75
|
+
* @param pkgOrOptions - The target app package name (legacy) or a RunOptions configuration object.
|
|
76
|
+
* @param legacySerial - The target device serial number (legacy support).
|
|
77
|
+
* @returns A promise that resolves to the final QA report data upon completion or failure.
|
|
78
|
+
* @throws Error if the spec file does not exist.
|
|
79
|
+
*/
|
|
80
|
+
runSpec(specFilePath: string, pkgOrOptions?: string | RunOptions, legacySerial?: string): Promise<QaReportData>;
|
|
81
|
+
private getCleanHierarchy;
|
|
82
|
+
/**
|
|
83
|
+
* Expectation-driven dynamic polling: waits for an element matching target to appear on screen.
|
|
84
|
+
* Proceeds as soon as the element exists without waiting for blind static sleeps.
|
|
85
|
+
*/
|
|
86
|
+
private ensureInViewport;
|
|
87
|
+
private waitForTarget;
|
|
88
|
+
private buildDiagnosticError;
|
|
89
|
+
executeStep(step: PromptStep, serial?: string, upcomingSteps?: PromptStep[]): Promise<{
|
|
90
|
+
fastForwarded?: boolean;
|
|
91
|
+
reason?: string;
|
|
92
|
+
skipCount?: number;
|
|
93
|
+
} | void>;
|
|
94
|
+
private findTargetInputField;
|
|
95
|
+
private matchNodes;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A singleton instance of the PromptRunner.
|
|
99
|
+
* Pre-configured with default dependencies for convenient global usage across the framework.
|
|
100
|
+
*/
|
|
101
|
+
export declare const promptRunner: PromptRunner;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module quiescence
|
|
3
|
+
* @description Dynamic Screen Quiescence & Idling Sentinel for PromptTest.
|
|
4
|
+
*
|
|
5
|
+
* Implements self-synchronizing stability detection inspired by Playwright's networkidle
|
|
6
|
+
* and Android Espresso's IdlingResource. Replaces fragile static timers with dual-sample
|
|
7
|
+
* layout stabilization and active in-flight loading sentinel checks.
|
|
8
|
+
*/
|
|
9
|
+
import type { UiNode } from './crawler.js';
|
|
10
|
+
import type { ExecutionContext } from './step-handlers.js';
|
|
11
|
+
export interface QuiescenceResult {
|
|
12
|
+
/** Whether the screen reached verified stability before the timeout */
|
|
13
|
+
settled: boolean;
|
|
14
|
+
/** Milliseconds elapsed during stabilization */
|
|
15
|
+
durationMs: number;
|
|
16
|
+
/** Final structural hash of the quiescent screen */
|
|
17
|
+
finalHash: string;
|
|
18
|
+
/** Flattened UI nodes of the quiescent screen */
|
|
19
|
+
flat: UiNode[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Inspects a flattened UI hierarchy to detect active in-flight network spinners,
|
|
23
|
+
* shimmers, progress bars, or server-waiting indicators.
|
|
24
|
+
*
|
|
25
|
+
* @param nodes - Flattened array of UiNodes
|
|
26
|
+
* @returns Status indicating whether loading is in progress and why.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isLoadingInProgress(nodes: UiNode[]): {
|
|
29
|
+
loading: boolean;
|
|
30
|
+
reason?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Dynamically waits until the application screen achieves 100% quiescence:
|
|
34
|
+
* 1. All active loading indicators and spinners have vanished.
|
|
35
|
+
* 2. Two consecutive UI hierarchy snapshots yield matching structural hashes.
|
|
36
|
+
*
|
|
37
|
+
* Exits immediately once settled, saving seconds on fast devices while providing
|
|
38
|
+
* dynamic patience for slow network requests or cloud emulators.
|
|
39
|
+
*
|
|
40
|
+
* @param ctx - Execution context providing driver and hierarchy access.
|
|
41
|
+
* @param timeoutMs - Maximum wait ceiling (defaults to 4500ms).
|
|
42
|
+
* @param sampleIntervalMs - Interval between stability probe samples (defaults to 150ms).
|
|
43
|
+
*/
|
|
44
|
+
export declare function waitForQuiescence(ctx: ExecutionContext, timeoutMs?: number, sampleIntervalMs?: number): Promise<QuiescenceResult>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { AndroidDriver } from './adb.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the recording session.
|
|
4
|
+
*/
|
|
5
|
+
export interface RecordOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If true, the recorder will append new captured steps to the existing test spec file
|
|
8
|
+
* rather than overwriting or creating a new file.
|
|
9
|
+
*/
|
|
10
|
+
append?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a discrete user interaction event captured during the session.
|
|
14
|
+
*/
|
|
15
|
+
export interface RecordedEvent {
|
|
16
|
+
/** The generated plain-English instruction for this event. */
|
|
17
|
+
stepText: string;
|
|
18
|
+
/** The exact epoch timestamp (in milliseconds) when this event occurred. */
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The core engine that listens to device input and transforms raw interaction telemetry
|
|
23
|
+
* into semantic PromptTest step instructions.
|
|
24
|
+
*/
|
|
25
|
+
export declare class AutonomousRecorder {
|
|
26
|
+
onStep?: (step: string) => void;
|
|
27
|
+
private driver;
|
|
28
|
+
private deviceLock;
|
|
29
|
+
private isRecording;
|
|
30
|
+
private recordedSteps;
|
|
31
|
+
private existingSteps;
|
|
32
|
+
private existingFileHeader;
|
|
33
|
+
private lastHierarchyFlat;
|
|
34
|
+
private lastScreenTitle;
|
|
35
|
+
private visitedScreens;
|
|
36
|
+
private targetPackage;
|
|
37
|
+
private isAppendMode;
|
|
38
|
+
private resolvedOutputPath;
|
|
39
|
+
private resolvedReportPath;
|
|
40
|
+
private activeInput;
|
|
41
|
+
private geteventProcess;
|
|
42
|
+
private isRefreshingHierarchy;
|
|
43
|
+
private targetSerial;
|
|
44
|
+
private touchMaxX;
|
|
45
|
+
private touchMaxY;
|
|
46
|
+
private displayWidth;
|
|
47
|
+
private displayHeight;
|
|
48
|
+
private activeTouchX;
|
|
49
|
+
private activeTouchY;
|
|
50
|
+
private touchDownTime;
|
|
51
|
+
private isTouchActive;
|
|
52
|
+
private isSwipeGesture;
|
|
53
|
+
private lastHierarchyTimestamp;
|
|
54
|
+
private lastTapTimestamp;
|
|
55
|
+
private lastRecordedTapTarget;
|
|
56
|
+
private inFlightTapQueue;
|
|
57
|
+
private inputDebounceTimer;
|
|
58
|
+
private logcatEventProcess;
|
|
59
|
+
private logcatCrashProcess;
|
|
60
|
+
private hierarchyCacheTime;
|
|
61
|
+
private hierarchyStale;
|
|
62
|
+
private lastScrollTimestamp;
|
|
63
|
+
private lastScrollDirection;
|
|
64
|
+
private currentScreenName;
|
|
65
|
+
private sessionScreenSections;
|
|
66
|
+
private sessionStartTime;
|
|
67
|
+
private screenshotDir;
|
|
68
|
+
private screenshotCounter;
|
|
69
|
+
private crashDetected;
|
|
70
|
+
private lastScreenTransitionTime;
|
|
71
|
+
/**
|
|
72
|
+
* Initializes a new AutonomousRecorder.
|
|
73
|
+
* @param driver An optional AndroidDriver instance to use. If omitted, the default singleton is used.
|
|
74
|
+
*/
|
|
75
|
+
constructor(driver?: AndroidDriver);
|
|
76
|
+
/**
|
|
77
|
+
* Flushes recorded steps and markdown summary report immediately to disk.
|
|
78
|
+
* Ensures captured steps are never lost even if process terminates unexpectedly.
|
|
79
|
+
*/
|
|
80
|
+
private flushToDisk;
|
|
81
|
+
/**
|
|
82
|
+
* Records a new test step, auto-flushes to disk immediately, and outputs to console.
|
|
83
|
+
*/
|
|
84
|
+
private appendStep;
|
|
85
|
+
private extractBrandSlug;
|
|
86
|
+
/**
|
|
87
|
+
* Starts an interactive real-time recording session on the target Android device.
|
|
88
|
+
* Automatically detects the active app, starts capturing gestures and key events,
|
|
89
|
+
* monitors screen transitions, and writes out a plain-text spec.
|
|
90
|
+
*
|
|
91
|
+
* @param outputSpecPath Optional file path to save the generated test spec to.
|
|
92
|
+
* @param serial Optional serial number of the target device to record from.
|
|
93
|
+
* @param options Additional recording configuration options.
|
|
94
|
+
* @returns A promise that resolves when the recording session concludes.
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Starts a non-blocking recording session (used by both CLI and Live Server).
|
|
98
|
+
*/
|
|
99
|
+
startSession(outputSpecPath?: string, serial?: string, options?: RecordOptions): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Stops an active recording session, terminates background processes,
|
|
102
|
+
* releases device lock, and returns the recorded steps and file paths.
|
|
103
|
+
*/
|
|
104
|
+
stopSession(): Promise<{
|
|
105
|
+
steps: string[];
|
|
106
|
+
specPath: string;
|
|
107
|
+
reportPath: string;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Starts an interactive real-time recording session on the target Android device.
|
|
111
|
+
* Automatically detects the active app, starts capturing gestures and key events,
|
|
112
|
+
* monitors screen transitions, and writes out a plain-text spec.
|
|
113
|
+
*
|
|
114
|
+
* @param outputSpecPath Optional file path to save the generated test spec to.
|
|
115
|
+
* @param serial Optional serial number of the target device to record from.
|
|
116
|
+
* @param options Additional recording configuration options.
|
|
117
|
+
* @returns A promise that resolves when the recording session concludes.
|
|
118
|
+
*/
|
|
119
|
+
startRecording(outputSpecPath?: string, serial?: string, options?: RecordOptions): Promise<void>;
|
|
120
|
+
private startEventStream;
|
|
121
|
+
private cleanLabel;
|
|
122
|
+
private handleScroll;
|
|
123
|
+
private handleSwipe;
|
|
124
|
+
private handleLongPressAt;
|
|
125
|
+
private handleTapAt;
|
|
126
|
+
private handleKeyPress;
|
|
127
|
+
private scheduleInputDebounce;
|
|
128
|
+
private flushActiveInput;
|
|
129
|
+
private syncActiveInputText;
|
|
130
|
+
private recordInputText;
|
|
131
|
+
private startLogcatScreenWatcher;
|
|
132
|
+
private startLogcatCrashWatcher;
|
|
133
|
+
private captureSessionScreenshot;
|
|
134
|
+
private triggerAsyncHierarchyRefresh;
|
|
135
|
+
private doHierarchyRefresh;
|
|
136
|
+
private detectAndLogTransientAlerts;
|
|
137
|
+
private refreshHierarchySync;
|
|
138
|
+
private isIconGlyph;
|
|
139
|
+
private cleanDialogOrCompoundLabel;
|
|
140
|
+
private isCardMetadataSubtitle;
|
|
141
|
+
private findPrimaryCardTitle;
|
|
142
|
+
private resolveActionLabel;
|
|
143
|
+
private getCurrentStepNumber;
|
|
144
|
+
private detectAndLogScreenHeader;
|
|
145
|
+
private resolveFieldLabel;
|
|
146
|
+
private isPlaceholderText;
|
|
147
|
+
private saveSpec;
|
|
148
|
+
private saveReport;
|
|
149
|
+
private printExitSummary;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Pre-instantiated global singleton instance of the AutonomousRecorder.
|
|
153
|
+
* Use this for starting recording sessions without managing class instances manually.
|
|
154
|
+
*/
|
|
155
|
+
export declare const autonomousRecorder: AutonomousRecorder;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module repl
|
|
3
|
+
* @description
|
|
4
|
+
* Interactive Live REPL (Playground) for PromptTest.
|
|
5
|
+
* Allows developers and QA engineers to drive connected Android devices interactively
|
|
6
|
+
* in real time using plain-English instructions with instant latency feedback, UI inspection,
|
|
7
|
+
* screenshot capturing, and spec file export.
|
|
8
|
+
*/
|
|
9
|
+
import { AndroidDriver } from './adb.js';
|
|
10
|
+
import { PromptRunner } from './prompt-runner.js';
|
|
11
|
+
export interface ReplOptions {
|
|
12
|
+
serial?: string;
|
|
13
|
+
packageName?: string;
|
|
14
|
+
input?: NodeJS.ReadableStream;
|
|
15
|
+
output?: NodeJS.WritableStream;
|
|
16
|
+
}
|
|
17
|
+
export interface ReplSession {
|
|
18
|
+
history: string[];
|
|
19
|
+
successfulSteps: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Starts the interactive PromptTest live REPL session.
|
|
23
|
+
*
|
|
24
|
+
* @param driver - The AndroidDriver instance to communicate with the device.
|
|
25
|
+
* @param runner - The PromptRunner instance to execute steps.
|
|
26
|
+
* @param options - Configuration options for the REPL session.
|
|
27
|
+
* @returns Promise that resolves when the REPL session exits.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startRepl(driver?: AndroidDriver, runner?: PromptRunner, options?: ReplOptions): Promise<ReplSession>;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptTest Reporting Engine
|
|
3
|
+
*
|
|
4
|
+
* This module serves as the test audit and reporting engine for PromptTest.
|
|
5
|
+
* It records step data, computes test execution metrics, and generates
|
|
6
|
+
* comprehensive reports in multiple formats including JSON, Markdown, and
|
|
7
|
+
* JUnit XML. It plays a critical role in providing observability and
|
|
8
|
+
* traceability for autonomous test executions.
|
|
9
|
+
*/
|
|
10
|
+
import type { PerformanceReport } from './profiler.js';
|
|
11
|
+
/**
|
|
12
|
+
* Represents a single executed step or action during the test run.
|
|
13
|
+
*/
|
|
14
|
+
export interface AuditStep {
|
|
15
|
+
/** The sequential 1-based index of this step in the test run. */
|
|
16
|
+
stepIndex: number;
|
|
17
|
+
/** ISO 8601 timestamp of when the step was executed. */
|
|
18
|
+
timestamp: string;
|
|
19
|
+
/** The high-level test phase (e.g., 'Setup', 'Navigation', 'Assertion'). */
|
|
20
|
+
phase: string;
|
|
21
|
+
/** A human-readable description of what the step attempts to do. */
|
|
22
|
+
description: string;
|
|
23
|
+
/** The specific technical action taken (e.g., 'click', 'input', 'assert'). */
|
|
24
|
+
action: string;
|
|
25
|
+
/** The UI element or component targeted by this action, if any. */
|
|
26
|
+
target?: string;
|
|
27
|
+
/** The outcome of the step execution. */
|
|
28
|
+
status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED';
|
|
29
|
+
/** Local file path or relative URL to the screenshot taken during this step, if any. */
|
|
30
|
+
screenshotPath?: string;
|
|
31
|
+
/** Elapsed execution time for this step in milliseconds. */
|
|
32
|
+
durationMs?: number;
|
|
33
|
+
/** Relative path to the failure triage bundle directory if step failed. */
|
|
34
|
+
triageBundle?: string;
|
|
35
|
+
/** Relative execution offset in milliseconds from start of run / video recording. */
|
|
36
|
+
videoOffsetMs?: number;
|
|
37
|
+
/** Additional diagnostic data or context about the step. */
|
|
38
|
+
details?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Contains the aggregated data and metrics for a completed test run.
|
|
42
|
+
*/
|
|
43
|
+
export interface QaReportData {
|
|
44
|
+
/** The Android package name of the tested application. */
|
|
45
|
+
packageName: string;
|
|
46
|
+
/** The identifier of the device used for the test execution. */
|
|
47
|
+
deviceId: string;
|
|
48
|
+
/** ISO 8601 timestamp marking the start of the test run. */
|
|
49
|
+
startTime: string;
|
|
50
|
+
/** ISO 8601 timestamp marking the end of the test run. */
|
|
51
|
+
endTime: string;
|
|
52
|
+
/** Total duration of the test execution in seconds. */
|
|
53
|
+
durationSeconds: number;
|
|
54
|
+
/** The total number of steps executed during the run. */
|
|
55
|
+
totalSteps: number;
|
|
56
|
+
/** The number of steps that completed successfully. */
|
|
57
|
+
passedSteps: number;
|
|
58
|
+
/** The number of steps that failed. */
|
|
59
|
+
failedSteps: number;
|
|
60
|
+
/** The number of steps that were skipped. */
|
|
61
|
+
skippedSteps: number;
|
|
62
|
+
/** The number of steps that completed with warnings. */
|
|
63
|
+
warnSteps: number;
|
|
64
|
+
/** A list of critical error messages or sentinels detected during the run. */
|
|
65
|
+
errorsDetected: string[];
|
|
66
|
+
/** Optional relative path to screen recording video (MP4). */
|
|
67
|
+
videoPath?: string;
|
|
68
|
+
/** Optional performance profiler metrics (PF-01). */
|
|
69
|
+
performanceMetrics?: PerformanceReport;
|
|
70
|
+
/** Details of any locators auto-healed during the test run */
|
|
71
|
+
healsApplied?: Array<{
|
|
72
|
+
original: string;
|
|
73
|
+
healed: string;
|
|
74
|
+
stepNumber: number;
|
|
75
|
+
}>;
|
|
76
|
+
/** The chronological list of all audit steps executed. */
|
|
77
|
+
steps: AuditStep[];
|
|
78
|
+
}
|
|
79
|
+
/** Supported output report serialization formats. */
|
|
80
|
+
export type ReportFormat = 'json' | 'md' | 'junit' | 'html';
|
|
81
|
+
/**
|
|
82
|
+
* Options for configuring the QaReporter.
|
|
83
|
+
*/
|
|
84
|
+
export interface QaReporterOptions {
|
|
85
|
+
/** Directory where reports and artifacts are saved. */
|
|
86
|
+
outputDir?: string;
|
|
87
|
+
/** List of report formats to generate ('json', 'md', 'junit', 'html'). */
|
|
88
|
+
formats?: ReportFormat[];
|
|
89
|
+
/** Whether to embed screenshots directly into the HTML report as base64 data URIs. */
|
|
90
|
+
embedScreenshots?: boolean;
|
|
91
|
+
}
|
|
92
|
+
export type StepListener = (step: AuditStep) => void;
|
|
93
|
+
export type CompleteListener = (report: QaReportData) => void;
|
|
94
|
+
export type ErrorListener = (errorMsg: string) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Pluggable reporter interface (A-02).
|
|
97
|
+
* Implement this to add Slack, TestRail, Allure, or any custom sink.
|
|
98
|
+
* Pass an instance via `RunOptions.reporter` or the `--reporter` CLI flag.
|
|
99
|
+
*/
|
|
100
|
+
export interface Reporter {
|
|
101
|
+
/**
|
|
102
|
+
* Initializes the reporter for a new test run.
|
|
103
|
+
*
|
|
104
|
+
* @param packageName - The target app package name.
|
|
105
|
+
* @param deviceId - The ID of the target device.
|
|
106
|
+
*/
|
|
107
|
+
init(packageName: string, deviceId: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Records a new step in the test run.
|
|
110
|
+
*/
|
|
111
|
+
logStep(phase: string, description: string, action: string, status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED', target?: string, screenshotBuffer?: Buffer, details?: Record<string, unknown>, durationMs?: number, triageBundle?: string): AuditStep;
|
|
112
|
+
/**
|
|
113
|
+
* Logs a critical error or anomaly detected during the run.
|
|
114
|
+
*/
|
|
115
|
+
logError(errorMsg: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Attaches a video recording path to the report.
|
|
118
|
+
*/
|
|
119
|
+
setVideoPath?(videoPath: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Sets whether screenshots should be embedded as base64 in HTML reports.
|
|
122
|
+
*/
|
|
123
|
+
setEmbedScreenshots?(embed: boolean): void;
|
|
124
|
+
/**
|
|
125
|
+
* Sets active report formats.
|
|
126
|
+
*/
|
|
127
|
+
setFormats?(formats: ReportFormat[]): void;
|
|
128
|
+
/**
|
|
129
|
+
* Subscribes to real-time step audit events.
|
|
130
|
+
*/
|
|
131
|
+
onStep?(listener: StepListener): () => void;
|
|
132
|
+
/**
|
|
133
|
+
* Subscribes to test suite completion events.
|
|
134
|
+
*/
|
|
135
|
+
onComplete?(listener: CompleteListener): () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Subscribes to critical error events.
|
|
138
|
+
*/
|
|
139
|
+
onError?(listener: ErrorListener): () => void;
|
|
140
|
+
/**
|
|
141
|
+
* Finalizes the execution and generates the final test reports.
|
|
142
|
+
*/
|
|
143
|
+
generateReport(customFileName?: string): Promise<QaReportData>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Default implementation of the Reporter interface.
|
|
147
|
+
* Generates local JSON, Markdown, and JUnit XML report files.
|
|
148
|
+
*/
|
|
149
|
+
export declare class QaReporter implements Reporter {
|
|
150
|
+
private outputDir;
|
|
151
|
+
private steps;
|
|
152
|
+
private errorsDetected;
|
|
153
|
+
private startTime;
|
|
154
|
+
private packageName;
|
|
155
|
+
private deviceId;
|
|
156
|
+
private pendingWrites;
|
|
157
|
+
private formats;
|
|
158
|
+
private videoPath?;
|
|
159
|
+
private embedScreenshots;
|
|
160
|
+
private performanceMetrics?;
|
|
161
|
+
private screenshotBuffers;
|
|
162
|
+
private stepListeners;
|
|
163
|
+
private completeListeners;
|
|
164
|
+
private errorListeners;
|
|
165
|
+
/**
|
|
166
|
+
* Sets the performance metrics collected by the profiler.
|
|
167
|
+
*/
|
|
168
|
+
setPerformanceMetrics(metrics: PerformanceReport): void;
|
|
169
|
+
/**
|
|
170
|
+
* Constructs a new QaReporter.
|
|
171
|
+
*
|
|
172
|
+
* @param outputDirOrOptions - Optional path or QaReporterOptions configuration object.
|
|
173
|
+
* @param formats - Optional array of desired output report formats ('json', 'md', 'junit', 'html').
|
|
174
|
+
*/
|
|
175
|
+
constructor(outputDirOrOptions?: string | QaReporterOptions, formats?: ReportFormat[]);
|
|
176
|
+
/**
|
|
177
|
+
* Enables or disables base64 screenshot embedding in HTML reports.
|
|
178
|
+
*/
|
|
179
|
+
setEmbedScreenshots(embed: boolean): void;
|
|
180
|
+
/**
|
|
181
|
+
* Subscribes a listener to individual step execution events.
|
|
182
|
+
* Returns an unsubscribe function.
|
|
183
|
+
*/
|
|
184
|
+
onStep(listener: StepListener): () => void;
|
|
185
|
+
/**
|
|
186
|
+
* Subscribes a listener to run completion events.
|
|
187
|
+
* Returns an unsubscribe function.
|
|
188
|
+
*/
|
|
189
|
+
onComplete(listener: CompleteListener): () => void;
|
|
190
|
+
/**
|
|
191
|
+
* Subscribes a listener to error events.
|
|
192
|
+
* Returns an unsubscribe function.
|
|
193
|
+
*/
|
|
194
|
+
onError(listener: ErrorListener): () => void;
|
|
195
|
+
/**
|
|
196
|
+
* Sets the desired output report formats.
|
|
197
|
+
*/
|
|
198
|
+
setFormats(formats: ReportFormat[]): void;
|
|
199
|
+
/**
|
|
200
|
+
* Attaches a video recording path to the report.
|
|
201
|
+
*/
|
|
202
|
+
setVideoPath(videoPath: string): void;
|
|
203
|
+
/**
|
|
204
|
+
* Initializes the reporter for a new test run, resetting all internal state.
|
|
205
|
+
*
|
|
206
|
+
* @param packageName - The target app package name.
|
|
207
|
+
* @param deviceId - The ID of the target device.
|
|
208
|
+
*/
|
|
209
|
+
init(packageName: string, deviceId: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Releases in-memory screenshot buffers to bound process memory ceiling.
|
|
212
|
+
*/
|
|
213
|
+
clearScreenshotBuffers(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Records a new step in the test run and triggers background screenshot writing if provided.
|
|
216
|
+
*
|
|
217
|
+
* @param phase - The test phase of this step.
|
|
218
|
+
* @param description - Human-readable description of the step.
|
|
219
|
+
* @param action - The specific action taken.
|
|
220
|
+
* @param status - The execution status of the step.
|
|
221
|
+
* @param target - Optional target element identifier.
|
|
222
|
+
* @param screenshotBuffer - Optional image buffer of the screen state.
|
|
223
|
+
* @param details - Optional extra context data.
|
|
224
|
+
* @param durationMs - Optional elapsed execution time in milliseconds.
|
|
225
|
+
* @param triageBundle - Optional relative path to failure triage directory.
|
|
226
|
+
* @returns The generated AuditStep object.
|
|
227
|
+
*/
|
|
228
|
+
logStep(phase: string, description: string, action: string, status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED', target?: string, screenshotBuffer?: Buffer, details?: Record<string, unknown>, durationMs?: number, triageBundle?: string): AuditStep;
|
|
229
|
+
/**
|
|
230
|
+
* Logs a critical error or anomaly detected during the run.
|
|
231
|
+
*
|
|
232
|
+
* @param errorMsg - The error message to log.
|
|
233
|
+
*/
|
|
234
|
+
logError(errorMsg: string): void;
|
|
235
|
+
/**
|
|
236
|
+
* Finalizes the execution, waits for pending I/O, and generates the requested test reports.
|
|
237
|
+
*
|
|
238
|
+
* @param customFileName - Optional base name for the report files.
|
|
239
|
+
* @returns A Promise resolving to the aggregated report data.
|
|
240
|
+
*/
|
|
241
|
+
generateReport(customFileName?: string): Promise<QaReportData>;
|
|
242
|
+
private escapeXml;
|
|
243
|
+
private escapeHtml;
|
|
244
|
+
private formatJunitXml;
|
|
245
|
+
private formatMarkdownReport;
|
|
246
|
+
private resolveScreenshotData;
|
|
247
|
+
private formatHtmlReport;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Generates an interactive, standalone HTML report string from QaReportData.
|
|
251
|
+
*
|
|
252
|
+
* Features:
|
|
253
|
+
* - Executive dashboard with circular pass-rate gauge and summary metrics cards.
|
|
254
|
+
* - Live real-time search and status category filters.
|
|
255
|
+
* - Full-screen interactive Lightbox modal with zoom, previous/next, and keyboard navigation.
|
|
256
|
+
* - Visual baseline diff viewer for visual regression test steps.
|
|
257
|
+
* - Failure triage bundle explorer with direct links to artifacts.
|
|
258
|
+
* - Server-Sent Events (SSE) live monitoring integration when served over HTTP.
|
|
259
|
+
*/
|
|
260
|
+
export declare function generateHtmlReport(data: QaReportData, options?: {
|
|
261
|
+
suiteName?: string;
|
|
262
|
+
embedScreenshots?: boolean;
|
|
263
|
+
screenshotResolver?: (step: AuditStep) => string | undefined;
|
|
264
|
+
}): string;
|
|
265
|
+
/**
|
|
266
|
+
* A singleton instance of QaReporter provided for convenience.
|
|
267
|
+
* Can be used throughout the test execution for simplified reporting.
|
|
268
|
+
*/
|
|
269
|
+
export declare const qaReporter: QaReporter;
|