prompttest 1.3.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/CONTRIBUTING.md +80 -0
- package/LICENSE +36 -0
- package/LICENSES.md +81 -0
- package/README.md +402 -0
- package/SECURITY.md +56 -0
- package/dist/bin/prompttest.d.ts +2 -0
- package/dist/bin/prompttest.js +1020 -0
- package/dist/constants/commands.d.ts +125 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.js +862 -0
- package/dist/lib/adb.d.ts +394 -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 +111 -0
- package/dist/lib/benchmark.d.ts +100 -0
- package/dist/lib/checkpoint.d.ts +61 -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 +106 -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 +121 -0
- package/dist/lib/form-filler.d.ts +101 -0
- package/dist/lib/ios-driver.d.ts +38 -0
- package/dist/lib/live-server.d.ts +47 -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/prompt-runner.d.ts +100 -0
- package/dist/lib/recorder.d.ts +115 -0
- package/dist/lib/repl.d.ts +29 -0
- package/dist/lib/reporter.d.ts +253 -0
- package/dist/lib/runner-utils.d.ts +290 -0
- package/dist/lib/step-handlers.d.ts +388 -0
- package/docs/ARCHITECTURE.md +154 -0
- package/docs/USER_MANUAL.md +765 -0
- package/package.json +90 -0
|
@@ -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,253 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Represents a single executed step or action during the test run.
|
|
12
|
+
*/
|
|
13
|
+
export interface AuditStep {
|
|
14
|
+
/** The sequential 1-based index of this step in the test run. */
|
|
15
|
+
stepIndex: number;
|
|
16
|
+
/** ISO 8601 timestamp of when the step was executed. */
|
|
17
|
+
timestamp: string;
|
|
18
|
+
/** The high-level test phase (e.g., 'Setup', 'Navigation', 'Assertion'). */
|
|
19
|
+
phase: string;
|
|
20
|
+
/** A human-readable description of what the step attempts to do. */
|
|
21
|
+
description: string;
|
|
22
|
+
/** The specific technical action taken (e.g., 'click', 'input', 'assert'). */
|
|
23
|
+
action: string;
|
|
24
|
+
/** The UI element or component targeted by this action, if any. */
|
|
25
|
+
target?: string;
|
|
26
|
+
/** The outcome of the step execution. */
|
|
27
|
+
status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED';
|
|
28
|
+
/** Local file path or relative URL to the screenshot taken during this step, if any. */
|
|
29
|
+
screenshotPath?: string;
|
|
30
|
+
/** Elapsed execution time for this step in milliseconds. */
|
|
31
|
+
durationMs?: number;
|
|
32
|
+
/** Relative path to the failure triage bundle directory if step failed. */
|
|
33
|
+
triageBundle?: string;
|
|
34
|
+
/** Additional diagnostic data or context about the step. */
|
|
35
|
+
details?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Contains the aggregated data and metrics for a completed test run.
|
|
39
|
+
*/
|
|
40
|
+
export interface QaReportData {
|
|
41
|
+
/** The Android package name of the tested application. */
|
|
42
|
+
packageName: string;
|
|
43
|
+
/** The identifier of the device used for the test execution. */
|
|
44
|
+
deviceId: string;
|
|
45
|
+
/** ISO 8601 timestamp marking the start of the test run. */
|
|
46
|
+
startTime: string;
|
|
47
|
+
/** ISO 8601 timestamp marking the end of the test run. */
|
|
48
|
+
endTime: string;
|
|
49
|
+
/** Total duration of the test execution in seconds. */
|
|
50
|
+
durationSeconds: number;
|
|
51
|
+
/** The total number of steps executed during the run. */
|
|
52
|
+
totalSteps: number;
|
|
53
|
+
/** The number of steps that completed successfully. */
|
|
54
|
+
passedSteps: number;
|
|
55
|
+
/** The number of steps that failed. */
|
|
56
|
+
failedSteps: number;
|
|
57
|
+
/** The number of steps that were skipped. */
|
|
58
|
+
skippedSteps: number;
|
|
59
|
+
/** The number of steps that completed with warnings. */
|
|
60
|
+
warnSteps: number;
|
|
61
|
+
/** A list of critical error messages or sentinels detected during the run. */
|
|
62
|
+
errorsDetected: string[];
|
|
63
|
+
/** Optional relative path to screen recording video (MP4). */
|
|
64
|
+
videoPath?: string;
|
|
65
|
+
/** The chronological list of all audit steps executed. */
|
|
66
|
+
steps: AuditStep[];
|
|
67
|
+
}
|
|
68
|
+
/** Supported output report serialization formats. */
|
|
69
|
+
export type ReportFormat = 'json' | 'md' | 'junit' | 'html';
|
|
70
|
+
/**
|
|
71
|
+
* Options for configuring the QaReporter.
|
|
72
|
+
*/
|
|
73
|
+
export interface QaReporterOptions {
|
|
74
|
+
/** Directory where reports and artifacts are saved. */
|
|
75
|
+
outputDir?: string;
|
|
76
|
+
/** List of report formats to generate ('json', 'md', 'junit', 'html'). */
|
|
77
|
+
formats?: ReportFormat[];
|
|
78
|
+
/** Whether to embed screenshots directly into the HTML report as base64 data URIs. */
|
|
79
|
+
embedScreenshots?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export type StepListener = (step: AuditStep) => void;
|
|
82
|
+
export type CompleteListener = (report: QaReportData) => void;
|
|
83
|
+
export type ErrorListener = (errorMsg: string) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Pluggable reporter interface (A-02).
|
|
86
|
+
* Implement this to add Slack, TestRail, Allure, or any custom sink.
|
|
87
|
+
* Pass an instance via `RunOptions.reporter` or the `--reporter` CLI flag.
|
|
88
|
+
*/
|
|
89
|
+
export interface Reporter {
|
|
90
|
+
/**
|
|
91
|
+
* Initializes the reporter for a new test run.
|
|
92
|
+
*
|
|
93
|
+
* @param packageName - The target app package name.
|
|
94
|
+
* @param deviceId - The ID of the target device.
|
|
95
|
+
*/
|
|
96
|
+
init(packageName: string, deviceId: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Records a new step in the test run.
|
|
99
|
+
*/
|
|
100
|
+
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;
|
|
101
|
+
/**
|
|
102
|
+
* Logs a critical error or anomaly detected during the run.
|
|
103
|
+
*/
|
|
104
|
+
logError(errorMsg: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Attaches a video recording path to the report.
|
|
107
|
+
*/
|
|
108
|
+
setVideoPath?(videoPath: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Sets whether screenshots should be embedded as base64 in HTML reports.
|
|
111
|
+
*/
|
|
112
|
+
setEmbedScreenshots?(embed: boolean): void;
|
|
113
|
+
/**
|
|
114
|
+
* Sets active report formats.
|
|
115
|
+
*/
|
|
116
|
+
setFormats?(formats: ReportFormat[]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Subscribes to real-time step audit events.
|
|
119
|
+
*/
|
|
120
|
+
onStep?(listener: StepListener): () => void;
|
|
121
|
+
/**
|
|
122
|
+
* Subscribes to test suite completion events.
|
|
123
|
+
*/
|
|
124
|
+
onComplete?(listener: CompleteListener): () => void;
|
|
125
|
+
/**
|
|
126
|
+
* Subscribes to critical error events.
|
|
127
|
+
*/
|
|
128
|
+
onError?(listener: ErrorListener): () => void;
|
|
129
|
+
/**
|
|
130
|
+
* Finalizes the execution and generates the final test reports.
|
|
131
|
+
*/
|
|
132
|
+
generateReport(customFileName?: string): Promise<QaReportData>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Default implementation of the Reporter interface.
|
|
136
|
+
* Generates local JSON, Markdown, and JUnit XML report files.
|
|
137
|
+
*/
|
|
138
|
+
export declare class QaReporter implements Reporter {
|
|
139
|
+
private outputDir;
|
|
140
|
+
private steps;
|
|
141
|
+
private errorsDetected;
|
|
142
|
+
private startTime;
|
|
143
|
+
private packageName;
|
|
144
|
+
private deviceId;
|
|
145
|
+
private pendingWrites;
|
|
146
|
+
private formats;
|
|
147
|
+
private videoPath?;
|
|
148
|
+
private embedScreenshots;
|
|
149
|
+
private screenshotBuffers;
|
|
150
|
+
private stepListeners;
|
|
151
|
+
private completeListeners;
|
|
152
|
+
private errorListeners;
|
|
153
|
+
/**
|
|
154
|
+
* Constructs a new QaReporter.
|
|
155
|
+
*
|
|
156
|
+
* @param outputDirOrOptions - Optional path or QaReporterOptions configuration object.
|
|
157
|
+
* @param formats - Optional array of desired output report formats ('json', 'md', 'junit', 'html').
|
|
158
|
+
*/
|
|
159
|
+
constructor(outputDirOrOptions?: string | QaReporterOptions, formats?: ReportFormat[]);
|
|
160
|
+
/**
|
|
161
|
+
* Enables or disables base64 screenshot embedding in HTML reports.
|
|
162
|
+
*/
|
|
163
|
+
setEmbedScreenshots(embed: boolean): void;
|
|
164
|
+
/**
|
|
165
|
+
* Subscribes a listener to individual step execution events.
|
|
166
|
+
* Returns an unsubscribe function.
|
|
167
|
+
*/
|
|
168
|
+
onStep(listener: StepListener): () => void;
|
|
169
|
+
/**
|
|
170
|
+
* Subscribes a listener to run completion events.
|
|
171
|
+
* Returns an unsubscribe function.
|
|
172
|
+
*/
|
|
173
|
+
onComplete(listener: CompleteListener): () => void;
|
|
174
|
+
/**
|
|
175
|
+
* Subscribes a listener to error events.
|
|
176
|
+
* Returns an unsubscribe function.
|
|
177
|
+
*/
|
|
178
|
+
onError(listener: ErrorListener): () => void;
|
|
179
|
+
/**
|
|
180
|
+
* Sets the desired output report formats.
|
|
181
|
+
*/
|
|
182
|
+
setFormats(formats: ReportFormat[]): void;
|
|
183
|
+
/**
|
|
184
|
+
* Attaches a video recording path to the report.
|
|
185
|
+
*/
|
|
186
|
+
setVideoPath(videoPath: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Initializes the reporter for a new test run, resetting all internal state.
|
|
189
|
+
*
|
|
190
|
+
* @param packageName - The target app package name.
|
|
191
|
+
* @param deviceId - The ID of the target device.
|
|
192
|
+
*/
|
|
193
|
+
init(packageName: string, deviceId: string): void;
|
|
194
|
+
/**
|
|
195
|
+
* Releases in-memory screenshot buffers to bound process memory ceiling.
|
|
196
|
+
*/
|
|
197
|
+
clearScreenshotBuffers(): void;
|
|
198
|
+
/**
|
|
199
|
+
* Records a new step in the test run and triggers background screenshot writing if provided.
|
|
200
|
+
*
|
|
201
|
+
* @param phase - The test phase of this step.
|
|
202
|
+
* @param description - Human-readable description of the step.
|
|
203
|
+
* @param action - The specific action taken.
|
|
204
|
+
* @param status - The execution status of the step.
|
|
205
|
+
* @param target - Optional target element identifier.
|
|
206
|
+
* @param screenshotBuffer - Optional image buffer of the screen state.
|
|
207
|
+
* @param details - Optional extra context data.
|
|
208
|
+
* @param durationMs - Optional elapsed execution time in milliseconds.
|
|
209
|
+
* @param triageBundle - Optional relative path to failure triage directory.
|
|
210
|
+
* @returns The generated AuditStep object.
|
|
211
|
+
*/
|
|
212
|
+
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;
|
|
213
|
+
/**
|
|
214
|
+
* Logs a critical error or anomaly detected during the run.
|
|
215
|
+
*
|
|
216
|
+
* @param errorMsg - The error message to log.
|
|
217
|
+
*/
|
|
218
|
+
logError(errorMsg: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* Finalizes the execution, waits for pending I/O, and generates the requested test reports.
|
|
221
|
+
*
|
|
222
|
+
* @param customFileName - Optional base name for the report files.
|
|
223
|
+
* @returns A Promise resolving to the aggregated report data.
|
|
224
|
+
*/
|
|
225
|
+
generateReport(customFileName?: string): Promise<QaReportData>;
|
|
226
|
+
private escapeXml;
|
|
227
|
+
private escapeHtml;
|
|
228
|
+
private formatJunitXml;
|
|
229
|
+
private formatMarkdownReport;
|
|
230
|
+
private resolveScreenshotData;
|
|
231
|
+
private formatHtmlReport;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Generates an interactive, standalone HTML report string from QaReportData.
|
|
235
|
+
*
|
|
236
|
+
* Features:
|
|
237
|
+
* - Executive dashboard with circular pass-rate gauge and summary metrics cards.
|
|
238
|
+
* - Live real-time search and status category filters.
|
|
239
|
+
* - Full-screen interactive Lightbox modal with zoom, previous/next, and keyboard navigation.
|
|
240
|
+
* - Visual baseline diff viewer for visual regression test steps.
|
|
241
|
+
* - Failure triage bundle explorer with direct links to artifacts.
|
|
242
|
+
* - Server-Sent Events (SSE) live monitoring integration when served over HTTP.
|
|
243
|
+
*/
|
|
244
|
+
export declare function generateHtmlReport(data: QaReportData, options?: {
|
|
245
|
+
suiteName?: string;
|
|
246
|
+
embedScreenshots?: boolean;
|
|
247
|
+
screenshotResolver?: (step: AuditStep) => string | undefined;
|
|
248
|
+
}): string;
|
|
249
|
+
/**
|
|
250
|
+
* A singleton instance of QaReporter provided for convenience.
|
|
251
|
+
* Can be used throughout the test execution for simplified reporting.
|
|
252
|
+
*/
|
|
253
|
+
export declare const qaReporter: QaReporter;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module runner-utils
|
|
3
|
+
* @description
|
|
4
|
+
* Modular helper utilities for PromptTest runner orchestration.
|
|
5
|
+
* Encapsulates spec inclusion expansion, natural language prompt parsing,
|
|
6
|
+
* AST block hierarchy assembly, fuzzy/spatial/ordinal node matching,
|
|
7
|
+
* and diagnostic error generation.
|
|
8
|
+
*/
|
|
9
|
+
import { UiNode } from './crawler.js';
|
|
10
|
+
import { MemoryEngine } from './memory.js';
|
|
11
|
+
import type { QaReportData, Reporter, ReportFormat } from './reporter.js';
|
|
12
|
+
/**
|
|
13
|
+
* Valid action and flow control verbs supported by PromptTest.
|
|
14
|
+
*/
|
|
15
|
+
export type PromptStepType = 'TAP' | 'LONG_PRESS' | 'TYPE' | 'CLEAR' | 'VERIFY' | 'BACK' | 'SCROLL' | 'SWIPE' | 'TOGGLE' | 'SELECT' | 'LAUNCH_APP' | 'RESTART_APP' | 'TERMINATE_APP' | 'CLEAR_DATA' | 'GRANT_PERMISSION' | 'DEEP_LINK' | 'WAIT' | 'IF_VISIBLE' | 'LOOP' | 'WAIT_UNTIL' | 'SET_VARIABLE' | 'DEVICE_STATE' | 'RUN_JS' | 'ENTER_OTP' | 'API_REQUEST' | 'EMAIL_ASSERT';
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for executing a test specification.
|
|
18
|
+
*/
|
|
19
|
+
export interface RunOptions {
|
|
20
|
+
/** The target Android application package name. */
|
|
21
|
+
packageName?: string;
|
|
22
|
+
/** The serial number of the target Android device/emulator. */
|
|
23
|
+
serial?: string;
|
|
24
|
+
/** Policy for when to capture screenshots. */
|
|
25
|
+
screenshotMode?: 'on-failure' | 'all';
|
|
26
|
+
/** If true, execution proceeds even after a non-optional step fails. */
|
|
27
|
+
continueOnError?: boolean;
|
|
28
|
+
/** If true, clears app data before running the spec. */
|
|
29
|
+
fresh?: boolean;
|
|
30
|
+
/** Local path to the APK if installation is needed. */
|
|
31
|
+
apkPath?: string;
|
|
32
|
+
/** Variables for interpolation within the spec text. */
|
|
33
|
+
variables?: Record<string, string>;
|
|
34
|
+
/** Resume from last checkpoint if one exists for this spec. */
|
|
35
|
+
resume?: boolean;
|
|
36
|
+
/** Save a screenshot baseline after every passing step. */
|
|
37
|
+
saveBaseline?: boolean;
|
|
38
|
+
/** Compare screenshots against saved baselines on every step. */
|
|
39
|
+
compareBaseline?: boolean;
|
|
40
|
+
/** Visual diff threshold (0–1). Defaults to 0.02 (2%). */
|
|
41
|
+
baselineThreshold?: number;
|
|
42
|
+
/** If true, records screen to an MP4 video during spec execution. */
|
|
43
|
+
video?: boolean;
|
|
44
|
+
/** Specific report formats to emit ('json', 'md', 'junit', 'html'). */
|
|
45
|
+
reporters?: ReportFormat[];
|
|
46
|
+
/** Custom reporter instance (A-02). Defaults to the built-in QaReporter. */
|
|
47
|
+
reporter?: Reporter;
|
|
48
|
+
/** Enable automatic locator self-healing on failure. */
|
|
49
|
+
heal?: boolean;
|
|
50
|
+
/** Disable AI resolution (force pure heuristic mode). */
|
|
51
|
+
noAi?: boolean;
|
|
52
|
+
/** Path to external CSV or JSON dataset for data-driven testing. */
|
|
53
|
+
dataFile?: string;
|
|
54
|
+
/** Total number of data-driven iterations to execute. */
|
|
55
|
+
iterations?: number;
|
|
56
|
+
/** Execute only a specific 1-indexed data row from dataset. */
|
|
57
|
+
onlyRow?: number;
|
|
58
|
+
/** Active language/locale for UI taxonomy and matching (e.g. 'en', 'es', 'hi'). */
|
|
59
|
+
locale?: string;
|
|
60
|
+
/** Whether to inline screenshots as base64 in the generated HTML report. */
|
|
61
|
+
embedScreenshots?: boolean;
|
|
62
|
+
/** Start a live streaming monitor HTTP server (boolean or port number). */
|
|
63
|
+
serve?: boolean | number;
|
|
64
|
+
/** Enable benchmark mode to output and log per-step latency metrics. */
|
|
65
|
+
benchmark?: boolean;
|
|
66
|
+
/** Dry-run parse and validate spec without device interaction. */
|
|
67
|
+
dryRun?: boolean;
|
|
68
|
+
/** Print parsed steps table and exit without executing. */
|
|
69
|
+
listSteps?: boolean;
|
|
70
|
+
/** Filter execution to specific step indices or ranges (e.g. '1-3,5'). */
|
|
71
|
+
only?: string;
|
|
72
|
+
/** Filter execution to specs matching specific tags (e.g. 'smoke'). */
|
|
73
|
+
tags?: string;
|
|
74
|
+
/** Emit machine-readable JSON execution summary to stdout. */
|
|
75
|
+
json?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Represents a single parsed action step in a plain-English test spec.
|
|
79
|
+
*/
|
|
80
|
+
export interface PromptStep {
|
|
81
|
+
/** The original unparsed text from the spec file. */
|
|
82
|
+
originalText: string;
|
|
83
|
+
/** The action type resolved from the text. */
|
|
84
|
+
type: PromptStepType;
|
|
85
|
+
/** The primary target node or element text to interact with. */
|
|
86
|
+
target?: string;
|
|
87
|
+
/** The value to input or select (e.g., text to type). */
|
|
88
|
+
value?: string;
|
|
89
|
+
/** Wait duration in milliseconds (used for WAIT steps). */
|
|
90
|
+
durationMs?: number;
|
|
91
|
+
/** Direction for swipe or scroll steps. */
|
|
92
|
+
direction?: 'left' | 'right' | 'up' | 'down';
|
|
93
|
+
/** The desired boolean state (e.g., for toggles or checkboxes). */
|
|
94
|
+
desiredState?: boolean;
|
|
95
|
+
/** Ordinal indicator for differentiating multiple matching targets. */
|
|
96
|
+
ordinal?: '1st' | '2nd' | '3rd' | '4th' | '5th' | 'first' | 'last';
|
|
97
|
+
/** Text of another element this target is relative to (spatial matching). */
|
|
98
|
+
relativeTo?: string;
|
|
99
|
+
/** The expected state of the target (e.g., 'visible', 'exists', 'absent', 'hidden') for verifications. */
|
|
100
|
+
expectedState?: 'visible' | 'exists' | 'enabled' | 'disabled' | 'absent' | 'hidden';
|
|
101
|
+
/** If true, asserts that the target element is NOT present. */
|
|
102
|
+
negative?: boolean;
|
|
103
|
+
/** If true, the test will not fail if this step fails. */
|
|
104
|
+
optional?: boolean;
|
|
105
|
+
/** Target text or locator checked by conditional statements (IF_VISIBLE). */
|
|
106
|
+
conditionTarget?: string;
|
|
107
|
+
/** Steps executed when a condition evaluates to true. */
|
|
108
|
+
thenSteps?: PromptStep[];
|
|
109
|
+
/** Steps executed when a condition evaluates to false. */
|
|
110
|
+
elseSteps?: PromptStep[];
|
|
111
|
+
/** Steps executed repeatedly inside a loop. */
|
|
112
|
+
childSteps?: PromptStep[];
|
|
113
|
+
/** Total iterations for fixed-count loops. */
|
|
114
|
+
loopCount?: number;
|
|
115
|
+
/** Name of variable populated during iterations (e.g. for-each). */
|
|
116
|
+
loopVariable?: string;
|
|
117
|
+
/** Variable identifier set during SET_VARIABLE actions. */
|
|
118
|
+
variableName?: string;
|
|
119
|
+
/** Expression or literal string assigned to a variable. */
|
|
120
|
+
variableExpression?: string;
|
|
121
|
+
/** Hardware or connectivity state toggled (DEVICE_STATE). */
|
|
122
|
+
deviceAction?: 'wifi' | 'airplane' | 'orientation' | 'notifications';
|
|
123
|
+
/** Target state value ('on', 'off', 'portrait', 'landscape', etc.). */
|
|
124
|
+
deviceStateValue?: string | boolean;
|
|
125
|
+
/** Sandboxed JavaScript code snippet (RUN_JS). */
|
|
126
|
+
jsCode?: string;
|
|
127
|
+
/** Tracked source file and line number for modular spec reporting. */
|
|
128
|
+
sourceLocation?: {
|
|
129
|
+
file: string;
|
|
130
|
+
line: number;
|
|
131
|
+
};
|
|
132
|
+
/** API HTTP Method (GET, POST, etc.) */
|
|
133
|
+
apiMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
134
|
+
/** API endpoint URL */
|
|
135
|
+
apiUrl?: string;
|
|
136
|
+
/** Request body JSON string */
|
|
137
|
+
apiBody?: string;
|
|
138
|
+
/** JSON response path to extract into a variable */
|
|
139
|
+
apiStorePath?: string;
|
|
140
|
+
/** Variable identifier to store API response value */
|
|
141
|
+
apiStoreVariable?: string;
|
|
142
|
+
/** Expected HTTP response status code */
|
|
143
|
+
apiExpectedStatus?: number;
|
|
144
|
+
/** Recipient email address for email assertions */
|
|
145
|
+
emailRecipient?: string;
|
|
146
|
+
/** Expected email subject line */
|
|
147
|
+
emailSubject?: string;
|
|
148
|
+
/** Expected substring inside email body */
|
|
149
|
+
emailBodyContains?: string;
|
|
150
|
+
/** Healed locator provenance (original target string) */
|
|
151
|
+
healedFrom?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Recursively expands `INCLUDE '<path>'` directives within a spec file.
|
|
155
|
+
* Resolves paths relative to current spec directory and guards against circular recursion.
|
|
156
|
+
*
|
|
157
|
+
* @param specFilePath - Path to the root spec file.
|
|
158
|
+
* @param visitedFiles - Set of visited absolute file paths in the recursion stack.
|
|
159
|
+
* @returns The fully expanded spec string.
|
|
160
|
+
* @throws SpecRecursionError if circular spec inclusion is detected.
|
|
161
|
+
*/
|
|
162
|
+
export declare function expandSpecIncludes(specFilePath: string, visitedFiles?: Set<string>): string;
|
|
163
|
+
/**
|
|
164
|
+
* Assembles a flat list of parsed prompt steps into a hierarchical execution AST.
|
|
165
|
+
* Scopes IF_VISIBLE blocks with thenSteps and elseSteps, and LOOP blocks with childSteps.
|
|
166
|
+
*/
|
|
167
|
+
export declare function assembleAstBlocks(flatSteps: Array<PromptStep & {
|
|
168
|
+
_isControl?: 'ELSE' | 'END';
|
|
169
|
+
}>): PromptStep[];
|
|
170
|
+
/**
|
|
171
|
+
* Parses a multi-line, plain-English test specification into a structured array of actionable steps.
|
|
172
|
+
* Understands variable interpolation, optional steps, flow control blocks (IF, LOOP), and all action types.
|
|
173
|
+
*
|
|
174
|
+
* @param promptText - The raw plain-English spec to parse.
|
|
175
|
+
* @param customVars - Optional key-value pairs for string interpolation.
|
|
176
|
+
* @returns An array of parsed PromptStep objects structured into an execution AST.
|
|
177
|
+
*/
|
|
178
|
+
export declare function parsePrompt(promptText: string, customVars?: Record<string, string>): PromptStep[];
|
|
179
|
+
/**
|
|
180
|
+
* Generates an error message augmented with actionable suggestions of closest visible nodes.
|
|
181
|
+
*/
|
|
182
|
+
export declare function buildDiagnosticError(target: string, flat: UiNode[], context: string): Error;
|
|
183
|
+
/**
|
|
184
|
+
* Heuristically finds the most relevant EditText input field for a given target label or intent.
|
|
185
|
+
*/
|
|
186
|
+
export declare function findTargetInputField(nodes: UiNode[], target: string, value?: string, memory?: MemoryEngine): UiNode | null;
|
|
187
|
+
/**
|
|
188
|
+
* Matches UI nodes against a query string using exact matching, memory, self-healing, spatial, and ordinal rules.
|
|
189
|
+
*/
|
|
190
|
+
export declare function matchNodes(nodes: UiNode[], query: string, memory: MemoryEngine, activeLocale?: string, step?: PromptStep, screenHash?: string): UiNode[];
|
|
191
|
+
/**
|
|
192
|
+
* Result of comparing two UI hierarchy snapshots.
|
|
193
|
+
*/
|
|
194
|
+
export interface HierarchyDiff {
|
|
195
|
+
/** True if the structural content or visible element count changed */
|
|
196
|
+
hasChanged: boolean;
|
|
197
|
+
/** Previous hierarchy fingerprint hash */
|
|
198
|
+
previousHash: string;
|
|
199
|
+
/** Current hierarchy fingerprint hash */
|
|
200
|
+
currentHash: string;
|
|
201
|
+
/** Difference in total node count */
|
|
202
|
+
nodeCountDelta: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Computes a fast 32-bit FNV-1a polynomial hash of a flattened UI node hierarchy.
|
|
206
|
+
* Encodes text, contentDesc, resourceId, and spatial coordinates to detect screen shifts.
|
|
207
|
+
*
|
|
208
|
+
* @param nodes - Flattened array of UiNode elements.
|
|
209
|
+
* @returns Hexadecimal fingerprint string.
|
|
210
|
+
*/
|
|
211
|
+
export declare function computeHierarchyHash(nodes: UiNode[]): string;
|
|
212
|
+
/**
|
|
213
|
+
* Patterns matching volatile real-time data that changes without representing a new screen state:
|
|
214
|
+
* - Timestamps and clocks (e.g. "10:45 AM", "12:00:30", "14:30")
|
|
215
|
+
* - Relative time spans (e.g. "2 mins ago", "yesterday", "3 days ago")
|
|
216
|
+
* - Currency and price figures (e.g. "$14.99", "₹500", "€10.00")
|
|
217
|
+
* - Dynamic booking / order / serial IDs (e.g. "#ORD-12345", "ID: 981723")
|
|
218
|
+
* - Battery percentage and status bars (e.g. "85%", "100%")
|
|
219
|
+
*/
|
|
220
|
+
export declare const VOLATILE_DATA_PATTERNS: readonly RegExp[];
|
|
221
|
+
/**
|
|
222
|
+
* Normalizes a text string by stripping volatile dynamic data (clocks, timestamps, prices, IDs).
|
|
223
|
+
*
|
|
224
|
+
* @param text - Raw element text or content description.
|
|
225
|
+
* @returns Canonicalized stable string.
|
|
226
|
+
*/
|
|
227
|
+
export declare function normalizeSemanticText(text: string): string;
|
|
228
|
+
/**
|
|
229
|
+
* Computes a canonical semantic hash representing the structural route and layout of a screen,
|
|
230
|
+
* immune to volatile data (clock ticks, prices, dynamic order IDs, or minor status bar changes).
|
|
231
|
+
*
|
|
232
|
+
* @param nodes - Array of UI nodes representing the screen.
|
|
233
|
+
* @param screenDims - Optional screen dimensions to exclude system status bar.
|
|
234
|
+
* @returns Stable hexadecimal fingerprint.
|
|
235
|
+
*/
|
|
236
|
+
export declare function computeCanonicalSemanticHash(nodes: UiNode[], screenDims?: {
|
|
237
|
+
width: number;
|
|
238
|
+
height: number;
|
|
239
|
+
}): string;
|
|
240
|
+
/**
|
|
241
|
+
* Compares two sets of UI hierarchy nodes to determine whether a meaningful screen transition occurred.
|
|
242
|
+
*
|
|
243
|
+
* @param previousNodes - The earlier hierarchy snapshot.
|
|
244
|
+
* @param currentNodes - The newly retrieved hierarchy snapshot.
|
|
245
|
+
* @returns HierarchyDiff analysis.
|
|
246
|
+
*/
|
|
247
|
+
export declare function compareHierarchyNodes(previousNodes: UiNode[], currentNodes: UiNode[]): HierarchyDiff;
|
|
248
|
+
/**
|
|
249
|
+
* Parses a comma-separated step index range string (e.g., "1-3,5,8-10") into a set of 1-based step numbers.
|
|
250
|
+
*
|
|
251
|
+
* @param rangeStr - Raw range string provided via `--only`.
|
|
252
|
+
* @returns Set of 1-based step indices.
|
|
253
|
+
*/
|
|
254
|
+
export declare function parseStepRange(rangeStr: string): Set<number>;
|
|
255
|
+
/**
|
|
256
|
+
* Extracts metadata tags from comments in a test specification file.
|
|
257
|
+
* Supports patterns like `# @tags: smoke, auth`, `# @tag smoke`, and `# @smoke`.
|
|
258
|
+
*
|
|
259
|
+
* @param specContent - Raw text content of the spec file.
|
|
260
|
+
* @returns Array of unique lowercase tag strings.
|
|
261
|
+
*/
|
|
262
|
+
export declare function extractSpecTags(specContent: string): string[];
|
|
263
|
+
/**
|
|
264
|
+
* Renders a structured CLI table listing all parsed PromptStep objects.
|
|
265
|
+
* Used by the `--list-steps` CLI flag.
|
|
266
|
+
*
|
|
267
|
+
* @param steps - Array of parsed PromptStep objects.
|
|
268
|
+
* @returns Multi-line formatted ASCII table string.
|
|
269
|
+
*/
|
|
270
|
+
export declare function formatStepTable(steps: PromptStep[]): string;
|
|
271
|
+
/**
|
|
272
|
+
* Creates a synthetic QaReportData object for early-exit execution modes like dry-run, list-steps, or skipped specs.
|
|
273
|
+
*
|
|
274
|
+
* @param packageName - Target package identifier.
|
|
275
|
+
* @param deviceId - Active device identifier.
|
|
276
|
+
* @param steps - Array of PromptSteps to include in report.
|
|
277
|
+
* @param stepStatus - Status to assign to each step ('PASS' | 'SKIPPED').
|
|
278
|
+
* @param phaseName - High-level phase name.
|
|
279
|
+
* @returns Fully formed QaReportData.
|
|
280
|
+
*/
|
|
281
|
+
export declare function createSyntheticReport(packageName: string, deviceId: string, steps?: PromptStep[], stepStatus?: 'PASS' | 'SKIPPED', phaseName?: string): QaReportData;
|
|
282
|
+
/**
|
|
283
|
+
* Automatically masks sensitive input values (passwords, PINs, auth tokens, API keys)
|
|
284
|
+
* for safe logging and report generation.
|
|
285
|
+
*
|
|
286
|
+
* @param value - The input text value to check.
|
|
287
|
+
* @param target - The element target label or description.
|
|
288
|
+
* @returns Sanitized or masked string.
|
|
289
|
+
*/
|
|
290
|
+
export declare function maskSensitiveValue(value: string, target?: string): string;
|