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,316 @@
|
|
|
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 { AndroidDriver } from './adb.js';
|
|
11
|
+
import { MemoryEngine } from './memory.js';
|
|
12
|
+
import type { QaReportData, Reporter, ReportFormat } from './reporter.js';
|
|
13
|
+
/**
|
|
14
|
+
* Valid action and flow control verbs supported by PromptTest.
|
|
15
|
+
*/
|
|
16
|
+
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';
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for executing a test specification.
|
|
19
|
+
*/
|
|
20
|
+
export interface RunOptions {
|
|
21
|
+
/** The target Android application package name. */
|
|
22
|
+
packageName?: string;
|
|
23
|
+
/** The serial number of the target Android device/emulator. */
|
|
24
|
+
serial?: string;
|
|
25
|
+
/** Policy for when to capture screenshots. */
|
|
26
|
+
screenshotMode?: 'on-failure' | 'all';
|
|
27
|
+
/** If true, execution proceeds even after a non-optional step fails. */
|
|
28
|
+
continueOnError?: boolean;
|
|
29
|
+
/** If true, clears app data before running the spec. */
|
|
30
|
+
fresh?: boolean;
|
|
31
|
+
/** Local path to the APK if installation is needed. */
|
|
32
|
+
apkPath?: string;
|
|
33
|
+
/** Variables for interpolation within the spec text. */
|
|
34
|
+
variables?: Record<string, string>;
|
|
35
|
+
/** Resume from last checkpoint if one exists for this spec. */
|
|
36
|
+
resume?: boolean;
|
|
37
|
+
/** Save a screenshot baseline after every passing step. */
|
|
38
|
+
saveBaseline?: boolean;
|
|
39
|
+
/** Compare screenshots against saved baselines on every step. */
|
|
40
|
+
compareBaseline?: boolean;
|
|
41
|
+
/** Visual diff threshold (0–1). Defaults to 0.02 (2%). */
|
|
42
|
+
baselineThreshold?: number;
|
|
43
|
+
/** If true, records screen to an MP4 video during spec execution. */
|
|
44
|
+
video?: boolean;
|
|
45
|
+
/** Specific report formats to emit ('json', 'md', 'junit', 'html'). */
|
|
46
|
+
reporters?: ReportFormat[];
|
|
47
|
+
/** Custom reporter instance (A-02). Defaults to the built-in QaReporter. */
|
|
48
|
+
reporter?: Reporter;
|
|
49
|
+
/** Enable automatic locator self-healing on failure. */
|
|
50
|
+
heal?: boolean;
|
|
51
|
+
/** Disable AI resolution (force pure heuristic mode). */
|
|
52
|
+
noAi?: boolean;
|
|
53
|
+
/** Path to external CSV or JSON dataset for data-driven testing. */
|
|
54
|
+
dataFile?: string;
|
|
55
|
+
/** Total number of data-driven iterations to execute. */
|
|
56
|
+
iterations?: number;
|
|
57
|
+
/** Execute only a specific 1-indexed data row from dataset. */
|
|
58
|
+
onlyRow?: number;
|
|
59
|
+
/** Active language/locale for UI taxonomy and matching (e.g. 'en', 'es', 'hi'). */
|
|
60
|
+
locale?: string;
|
|
61
|
+
/** Whether to inline screenshots as base64 in the generated HTML report. */
|
|
62
|
+
embedScreenshots?: boolean;
|
|
63
|
+
/** Start a live streaming monitor HTTP server (boolean or port number). */
|
|
64
|
+
serve?: boolean | number;
|
|
65
|
+
/** Enable benchmark mode to output and log per-step latency metrics. */
|
|
66
|
+
benchmark?: boolean;
|
|
67
|
+
/** Dry-run parse and validate spec without device interaction. */
|
|
68
|
+
dryRun?: boolean;
|
|
69
|
+
/** Print parsed steps table and exit without executing. */
|
|
70
|
+
listSteps?: boolean;
|
|
71
|
+
/** Filter execution to specific step indices or ranges (e.g. '1-3,5'). */
|
|
72
|
+
only?: string;
|
|
73
|
+
/** Filter execution to specs matching specific tags (e.g. 'smoke'). */
|
|
74
|
+
tags?: string;
|
|
75
|
+
/** Emit machine-readable JSON execution summary to stdout. */
|
|
76
|
+
json?: boolean;
|
|
77
|
+
/** Real-time mobile performance & FPS profiler (PF-01). */
|
|
78
|
+
profile?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents a single parsed action step in a plain-English test spec.
|
|
82
|
+
*/
|
|
83
|
+
export interface PromptStep {
|
|
84
|
+
/** The original unparsed text from the spec file. */
|
|
85
|
+
originalText: string;
|
|
86
|
+
/** The action type resolved from the text. */
|
|
87
|
+
type: PromptStepType;
|
|
88
|
+
/** The primary target node or element text to interact with. */
|
|
89
|
+
target?: string;
|
|
90
|
+
/** The value to input or select (e.g., text to type). */
|
|
91
|
+
value?: string;
|
|
92
|
+
/** Wait duration in milliseconds (used for WAIT steps). */
|
|
93
|
+
durationMs?: number;
|
|
94
|
+
/** Direction for swipe or scroll steps. */
|
|
95
|
+
direction?: 'left' | 'right' | 'up' | 'down';
|
|
96
|
+
/** The desired boolean state (e.g., for toggles or checkboxes). */
|
|
97
|
+
desiredState?: boolean;
|
|
98
|
+
/** Ordinal indicator for differentiating multiple matching targets. */
|
|
99
|
+
ordinal?: '1st' | '2nd' | '3rd' | '4th' | '5th' | 'first' | 'last';
|
|
100
|
+
/** Text of another element this target is relative to (spatial matching). */
|
|
101
|
+
relativeTo?: string;
|
|
102
|
+
/** The expected state of the target (e.g., 'visible', 'exists', 'absent', 'hidden') for verifications. */
|
|
103
|
+
expectedState?: 'visible' | 'exists' | 'enabled' | 'disabled' | 'absent' | 'hidden';
|
|
104
|
+
/** If true, asserts that the target element is NOT present. */
|
|
105
|
+
negative?: boolean;
|
|
106
|
+
/** If true, the test will not fail if this step fails. */
|
|
107
|
+
optional?: boolean;
|
|
108
|
+
/** Target text or locator checked by conditional statements (IF_VISIBLE). */
|
|
109
|
+
conditionTarget?: string;
|
|
110
|
+
/** Steps executed when a condition evaluates to true. */
|
|
111
|
+
thenSteps?: PromptStep[];
|
|
112
|
+
/** Steps executed when a condition evaluates to false. */
|
|
113
|
+
elseSteps?: PromptStep[];
|
|
114
|
+
/** Steps executed repeatedly inside a loop. */
|
|
115
|
+
childSteps?: PromptStep[];
|
|
116
|
+
/** Total iterations for fixed-count loops. */
|
|
117
|
+
loopCount?: number;
|
|
118
|
+
/** Name of variable populated during iterations (e.g. for-each). */
|
|
119
|
+
loopVariable?: string;
|
|
120
|
+
/** Variable identifier set during SET_VARIABLE actions. */
|
|
121
|
+
variableName?: string;
|
|
122
|
+
/** Expression or literal string assigned to a variable. */
|
|
123
|
+
variableExpression?: string;
|
|
124
|
+
/** Hardware or connectivity state toggled (DEVICE_STATE). */
|
|
125
|
+
deviceAction?: 'wifi' | 'airplane' | 'orientation' | 'notifications';
|
|
126
|
+
/** Target state value ('on', 'off', 'portrait', 'landscape', etc.). */
|
|
127
|
+
deviceStateValue?: string | boolean;
|
|
128
|
+
/** Sandboxed JavaScript code snippet (RUN_JS). */
|
|
129
|
+
jsCode?: string;
|
|
130
|
+
/** Tracked source file and line number for modular spec reporting. */
|
|
131
|
+
sourceLocation?: {
|
|
132
|
+
file: string;
|
|
133
|
+
line: number;
|
|
134
|
+
};
|
|
135
|
+
/** API HTTP Method (GET, POST, etc.) */
|
|
136
|
+
apiMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
137
|
+
/** API endpoint URL */
|
|
138
|
+
apiUrl?: string;
|
|
139
|
+
/** Request body JSON string */
|
|
140
|
+
apiBody?: string;
|
|
141
|
+
/** JSON response path to extract into a variable */
|
|
142
|
+
apiStorePath?: string;
|
|
143
|
+
/** Variable identifier to store API response value */
|
|
144
|
+
apiStoreVariable?: string;
|
|
145
|
+
/** Expected HTTP response status code */
|
|
146
|
+
apiExpectedStatus?: number;
|
|
147
|
+
/** Recipient email address for email assertions */
|
|
148
|
+
emailRecipient?: string;
|
|
149
|
+
/** Expected email subject line */
|
|
150
|
+
emailSubject?: string;
|
|
151
|
+
/** Expected substring inside email body */
|
|
152
|
+
emailBodyContains?: string;
|
|
153
|
+
/** Healed locator provenance (original target string) */
|
|
154
|
+
healedFrom?: string;
|
|
155
|
+
/** Healed replacement string chosen by self-healing */
|
|
156
|
+
healedTo?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Recursively expands `INCLUDE '<path>'` directives within a spec file.
|
|
160
|
+
* Resolves paths relative to current spec directory and guards against circular recursion.
|
|
161
|
+
*
|
|
162
|
+
* @param specFilePath - Path to the root spec file.
|
|
163
|
+
* @param visitedFiles - Set of visited absolute file paths in the recursion stack.
|
|
164
|
+
* @returns The fully expanded spec string.
|
|
165
|
+
* @throws SpecRecursionError if circular spec inclusion is detected.
|
|
166
|
+
*/
|
|
167
|
+
export declare function expandSpecIncludes(specFilePath: string, visitedFiles?: Set<string>): string;
|
|
168
|
+
/**
|
|
169
|
+
* Assembles a flat list of parsed prompt steps into a hierarchical execution AST.
|
|
170
|
+
* Scopes IF_VISIBLE blocks with thenSteps and elseSteps, and LOOP blocks with childSteps.
|
|
171
|
+
*/
|
|
172
|
+
export declare function assembleAstBlocks(flatSteps: Array<PromptStep & {
|
|
173
|
+
_isControl?: 'ELSE' | 'END';
|
|
174
|
+
}>): PromptStep[];
|
|
175
|
+
/**
|
|
176
|
+
* Parses a multi-line, plain-English test specification into a structured array of actionable steps.
|
|
177
|
+
* Understands variable interpolation, optional steps, flow control blocks (IF, LOOP), and all action types.
|
|
178
|
+
*
|
|
179
|
+
* @param promptText - The raw plain-English spec to parse.
|
|
180
|
+
* @param customVars - Optional key-value pairs for string interpolation.
|
|
181
|
+
* @returns An array of parsed PromptStep objects structured into an execution AST.
|
|
182
|
+
*/
|
|
183
|
+
export declare function parsePrompt(promptText: string, customVars?: Record<string, string>): PromptStep[];
|
|
184
|
+
/**
|
|
185
|
+
* Generates an error message augmented with actionable suggestions of closest visible nodes.
|
|
186
|
+
*/
|
|
187
|
+
export declare function buildDiagnosticError(target: string, flat: UiNode[], context: string): Error;
|
|
188
|
+
/**
|
|
189
|
+
* Heuristically finds the most relevant EditText input field for a given target label or intent.
|
|
190
|
+
*/
|
|
191
|
+
export declare function findTargetInputField(nodes: UiNode[], target: string, value?: string, memory?: MemoryEngine): UiNode | null;
|
|
192
|
+
/**
|
|
193
|
+
* Matches UI nodes against a query string using exact matching, memory, self-healing, spatial, and ordinal rules.
|
|
194
|
+
*/
|
|
195
|
+
export declare function matchNodes(nodes: UiNode[], query: string, memory: MemoryEngine, activeLocale?: string, step?: PromptStep, screenHash?: string): UiNode[];
|
|
196
|
+
/**
|
|
197
|
+
* Result of comparing two UI hierarchy snapshots.
|
|
198
|
+
*/
|
|
199
|
+
export interface HierarchyDiff {
|
|
200
|
+
/** True if the structural content or visible element count changed */
|
|
201
|
+
hasChanged: boolean;
|
|
202
|
+
/** Previous hierarchy fingerprint hash */
|
|
203
|
+
previousHash: string;
|
|
204
|
+
/** Current hierarchy fingerprint hash */
|
|
205
|
+
currentHash: string;
|
|
206
|
+
/** Difference in total node count */
|
|
207
|
+
nodeCountDelta: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Computes a fast 32-bit FNV-1a polynomial hash of a flattened UI node hierarchy.
|
|
211
|
+
* Encodes text, contentDesc, resourceId, and spatial coordinates to detect screen shifts.
|
|
212
|
+
*
|
|
213
|
+
* @param nodes - Flattened array of UiNode elements.
|
|
214
|
+
* @returns Hexadecimal fingerprint string.
|
|
215
|
+
*/
|
|
216
|
+
export declare function computeHierarchyHash(nodes: UiNode[]): string;
|
|
217
|
+
/**
|
|
218
|
+
* Patterns matching volatile real-time data that changes without representing a new screen state:
|
|
219
|
+
* - Timestamps and clocks (e.g. "10:45 AM", "12:00:30", "14:30")
|
|
220
|
+
* - Relative time spans (e.g. "2 mins ago", "yesterday", "3 days ago")
|
|
221
|
+
* - Currency and price figures (e.g. "$14.99", "₹500", "€10.00")
|
|
222
|
+
* - Dynamic booking / order / serial IDs (e.g. "#ORD-12345", "ID: 981723")
|
|
223
|
+
* - Battery percentage and status bars (e.g. "85%", "100%")
|
|
224
|
+
*/
|
|
225
|
+
export declare const VOLATILE_DATA_PATTERNS: readonly RegExp[];
|
|
226
|
+
/**
|
|
227
|
+
* Normalizes a text string by stripping volatile dynamic data (clocks, timestamps, prices, IDs).
|
|
228
|
+
*
|
|
229
|
+
* @param text - Raw element text or content description.
|
|
230
|
+
* @returns Canonicalized stable string.
|
|
231
|
+
*/
|
|
232
|
+
export declare function normalizeSemanticText(text: string): string;
|
|
233
|
+
/**
|
|
234
|
+
* Computes a canonical semantic hash representing the structural route and layout of a screen,
|
|
235
|
+
* immune to volatile data (clock ticks, prices, dynamic order IDs, or minor status bar changes).
|
|
236
|
+
*
|
|
237
|
+
* @param nodes - Array of UI nodes representing the screen.
|
|
238
|
+
* @param screenDims - Optional screen dimensions to exclude system status bar.
|
|
239
|
+
* @returns Stable hexadecimal fingerprint.
|
|
240
|
+
*/
|
|
241
|
+
export declare function computeCanonicalSemanticHash(nodes: UiNode[], screenDims?: {
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
}): string;
|
|
245
|
+
/**
|
|
246
|
+
* Compares two sets of UI hierarchy nodes to determine whether a meaningful screen transition occurred.
|
|
247
|
+
*
|
|
248
|
+
* @param previousNodes - The earlier hierarchy snapshot.
|
|
249
|
+
* @param currentNodes - The newly retrieved hierarchy snapshot.
|
|
250
|
+
* @returns HierarchyDiff analysis.
|
|
251
|
+
*/
|
|
252
|
+
export declare function compareHierarchyNodes(previousNodes: UiNode[], currentNodes: UiNode[]): HierarchyDiff;
|
|
253
|
+
/**
|
|
254
|
+
* Parses a comma-separated step index range string (e.g., "1-3,5,8-10") into a set of 1-based step numbers.
|
|
255
|
+
*
|
|
256
|
+
* @param rangeStr - Raw range string provided via `--only`.
|
|
257
|
+
* @returns Set of 1-based step indices.
|
|
258
|
+
*/
|
|
259
|
+
export declare function parseStepRange(rangeStr: string): Set<number>;
|
|
260
|
+
/**
|
|
261
|
+
* Extracts metadata tags from comments in a test specification file.
|
|
262
|
+
* Supports patterns like `# @tags: smoke, auth`, `# @tag smoke`, and `# @smoke`.
|
|
263
|
+
*
|
|
264
|
+
* @param specContent - Raw text content of the spec file.
|
|
265
|
+
* @returns Array of unique lowercase tag strings.
|
|
266
|
+
*/
|
|
267
|
+
export declare function extractSpecTags(specContent: string): string[];
|
|
268
|
+
/**
|
|
269
|
+
* Renders a structured CLI table listing all parsed PromptStep objects.
|
|
270
|
+
* Used by the `--list-steps` CLI flag.
|
|
271
|
+
*
|
|
272
|
+
* @param steps - Array of parsed PromptStep objects.
|
|
273
|
+
* @returns Multi-line formatted ASCII table string.
|
|
274
|
+
*/
|
|
275
|
+
export declare function formatStepTable(steps: PromptStep[]): string;
|
|
276
|
+
/**
|
|
277
|
+
* Creates a synthetic QaReportData object for early-exit execution modes like dry-run, list-steps, or skipped specs.
|
|
278
|
+
*
|
|
279
|
+
* @param packageName - Target package identifier.
|
|
280
|
+
* @param deviceId - Active device identifier.
|
|
281
|
+
* @param steps - Array of PromptSteps to include in report.
|
|
282
|
+
* @param stepStatus - Status to assign to each step ('PASS' | 'SKIPPED').
|
|
283
|
+
* @param phaseName - High-level phase name.
|
|
284
|
+
* @returns Fully formed QaReportData.
|
|
285
|
+
*/
|
|
286
|
+
export declare function createSyntheticReport(packageName: string, deviceId: string, steps?: PromptStep[], stepStatus?: 'PASS' | 'SKIPPED', phaseName?: string): QaReportData;
|
|
287
|
+
/**
|
|
288
|
+
* Automatically masks sensitive input values (passwords, PINs, auth tokens, API keys)
|
|
289
|
+
* for safe logging and report generation.
|
|
290
|
+
*
|
|
291
|
+
* @param value - The input text value to check.
|
|
292
|
+
* @param target - The element target label or description.
|
|
293
|
+
* @returns Sanitized or masked string.
|
|
294
|
+
*/
|
|
295
|
+
export declare function maskSensitiveValue(value: string, target?: string): string;
|
|
296
|
+
export interface FailureTriageParams {
|
|
297
|
+
outputDir: string;
|
|
298
|
+
specName: string;
|
|
299
|
+
currentSpecName: string;
|
|
300
|
+
stepNum: number;
|
|
301
|
+
step: PromptStep;
|
|
302
|
+
error: Error;
|
|
303
|
+
stepStartTime: number;
|
|
304
|
+
startTime: number;
|
|
305
|
+
errorShot?: Buffer;
|
|
306
|
+
lastHierarchy?: {
|
|
307
|
+
xml?: string;
|
|
308
|
+
flat?: UiNode[];
|
|
309
|
+
} | null;
|
|
310
|
+
driver: AndroidDriver;
|
|
311
|
+
serial?: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Assembles failure triage folder, logs, hierarchy XML, match scores, and a ZIP archive.
|
|
315
|
+
*/
|
|
316
|
+
export declare function createFailureTriageBundle(params: FailureTriageParams): Promise<string | undefined>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module scaffold
|
|
3
|
+
* @description
|
|
4
|
+
* Inspects an active Android screen (or raw XML hierarchy) and synthesizes
|
|
5
|
+
* a starter plain-English test spec (.txt) containing Launch, Wait, form Type,
|
|
6
|
+
* button Tap, and element Verify steps.
|
|
7
|
+
*/
|
|
8
|
+
import { AndroidDriver } from './adb.js';
|
|
9
|
+
import { UiNode } from './crawler.js';
|
|
10
|
+
export interface ScaffoldOptions {
|
|
11
|
+
/** Target package to scaffold. Defaults to active foreground app */
|
|
12
|
+
packageName?: string;
|
|
13
|
+
/** Specific device serial to connect to */
|
|
14
|
+
deviceSerial?: string;
|
|
15
|
+
/** Explicit output path for the generated spec. Defaults to specs/<pkg>_scaffold.txt */
|
|
16
|
+
outputPath?: string;
|
|
17
|
+
/** Driver instance for dependency injection */
|
|
18
|
+
driver?: AndroidDriver;
|
|
19
|
+
/** Whether to explore interconnected screens and generate a multi-screen journey spec */
|
|
20
|
+
journey?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ScaffoldResult {
|
|
23
|
+
packageName: string;
|
|
24
|
+
specContent: string;
|
|
25
|
+
specPath?: string;
|
|
26
|
+
stepsCount: number;
|
|
27
|
+
inputCount: number;
|
|
28
|
+
buttonCount: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sanitizes node labels by stripping Private Use Area (PUA) icon font glyphs,
|
|
32
|
+
* special/non-printable unicode codepoints, and leading/trailing punctuation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sanitizeNodeLabel(label: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Derives a human-readable clean label from a UiNode.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getNodeLabel(node: UiNode): string;
|
|
39
|
+
/**
|
|
40
|
+
* Synthesizes a valid PromptTest specification from a flat list of UiNodes.
|
|
41
|
+
*/
|
|
42
|
+
export declare function scaffoldSpecFromNodes(nodes: UiNode[], packageName?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Validates that every generated step in a spec string parses cleanly with the PromptTest DSL.
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateScaffoldedSpec(specContent: string): {
|
|
47
|
+
valid: boolean;
|
|
48
|
+
errors: string[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Connects to the device, retrieves screen hierarchy, and writes a scaffolded spec file.
|
|
52
|
+
*/
|
|
53
|
+
export declare function scaffoldSpec(options?: ScaffoldOptions): Promise<ScaffoldResult>;
|