spana-test 0.0.2 → 0.2.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/.agents/skills/spana-testing/SKILL.md +304 -0
- package/README.md +308 -88
- package/dist/agent/index.d.ts +110 -0
- package/dist/agent/index.js +25 -0
- package/dist/allure-PTTVORQ6.js +124 -0
- package/dist/allure-PTTVORQ6.js.map +1 -0
- package/dist/android-PAPJJWVN.js +34 -0
- package/dist/android-PAPJJWVN.js.map +1 -0
- package/dist/chunk-3FSZNKEF.js +62 -0
- package/dist/chunk-3FSZNKEF.js.map +1 -0
- package/dist/chunk-3YR4GUGE.js +249 -0
- package/dist/chunk-3YR4GUGE.js.map +1 -0
- package/dist/{discover-XIRJTZ7Z.js → chunk-AEKDFFPJ.js} +12 -5
- package/dist/{discover-XIRJTZ7Z.js.map → chunk-AEKDFFPJ.js.map} +1 -1
- package/dist/chunk-BF37W5EG.js +125 -0
- package/dist/chunk-BF37W5EG.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-EXLUY7KT.js +21 -0
- package/dist/chunk-EXLUY7KT.js.map +1 -0
- package/dist/chunk-FNDOEMOL.js +62 -0
- package/dist/chunk-FNDOEMOL.js.map +1 -0
- package/dist/{chunk-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
- package/dist/chunk-GZK22EIE.js.map +1 -0
- package/dist/chunk-HWFDXIXR.js +183 -0
- package/dist/chunk-HWFDXIXR.js.map +1 -0
- package/dist/chunk-IJIASIX5.js +314 -0
- package/dist/chunk-IJIASIX5.js.map +1 -0
- package/dist/chunk-KJPHH2TW.js +168 -0
- package/dist/chunk-KJPHH2TW.js.map +1 -0
- package/dist/chunk-L7MFJF46.js +137 -0
- package/dist/chunk-L7MFJF46.js.map +1 -0
- package/dist/chunk-MRH7SK52.js +134 -0
- package/dist/chunk-MRH7SK52.js.map +1 -0
- package/dist/chunk-P7JQRLP4.js +114 -0
- package/dist/chunk-P7JQRLP4.js.map +1 -0
- package/dist/chunk-S2XNAKSO.js +1087 -0
- package/dist/chunk-S2XNAKSO.js.map +1 -0
- package/dist/chunk-S4R4OR7T.js +358 -0
- package/dist/chunk-S4R4OR7T.js.map +1 -0
- package/dist/chunk-SFBRFB2N.js +277 -0
- package/dist/chunk-SFBRFB2N.js.map +1 -0
- package/dist/chunk-VNYF5BHX.js +494 -0
- package/dist/chunk-VNYF5BHX.js.map +1 -0
- package/dist/chunk-WBU34APM.js +38 -0
- package/dist/chunk-WBU34APM.js.map +1 -0
- package/dist/chunk-WQ4GXUUE.js +2402 -0
- package/dist/chunk-WQ4GXUUE.js.map +1 -0
- package/dist/chunk-YBZCOQXJ.js +311 -0
- package/dist/chunk-YBZCOQXJ.js.map +1 -0
- package/dist/cli.js +428 -34
- package/dist/cli.js.map +1 -1
- package/dist/compiler-74VGKZO6.js +312 -0
- package/dist/compiler-74VGKZO6.js.map +1 -0
- package/dist/config-loader-BJJ3IJJ7.js +9 -0
- package/dist/config-loader-BJJ3IJJ7.js.map +1 -0
- package/dist/console-XWKUTP3D.js +164 -0
- package/dist/console-XWKUTP3D.js.map +1 -0
- package/dist/coordinator-BbUjvvnX.d.ts +383 -0
- package/dist/discover-KZKXHZZA.js +14 -0
- package/dist/discover-KZKXHZZA.js.map +1 -0
- package/dist/doctor-command-T2UX5RV5.js +732 -0
- package/dist/doctor-command-T2UX5RV5.js.map +1 -0
- package/dist/element-DZ0HyJ3C.d.ts +25 -0
- package/dist/flow-BUC9Mf8W.d.ts +128 -0
- package/dist/gherkin/steps.d.ts +32 -0
- package/dist/gherkin/steps.js +39 -0
- package/dist/gherkin/steps.js.map +1 -0
- package/dist/{html-GRB34S6X.js → html-GE6Q4DCG.js} +76 -22
- package/dist/html-GE6Q4DCG.js.map +1 -0
- package/dist/index.d.ts +159 -144
- package/dist/index.js +39 -165
- package/dist/index.js.map +1 -1
- package/dist/init-command-GVMRXIMY.js +121 -0
- package/dist/init-command-GVMRXIMY.js.map +1 -0
- package/dist/init-flow-command-R76AXF4Z.js +34 -0
- package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
- package/dist/installer-YZJ4DV3F.js +22 -0
- package/dist/installer-YZJ4DV3F.js.map +1 -0
- package/dist/ios-ZW6XVNLG.js +50 -0
- package/dist/ios-ZW6XVNLG.js.map +1 -0
- package/dist/json-KS67BZYU.js +39 -0
- package/dist/json-KS67BZYU.js.map +1 -0
- package/dist/{junit-NAGZJOGQ.js → junit-HLC62MK6.js} +15 -4
- package/dist/junit-HLC62MK6.js.map +1 -0
- package/dist/provider-A57C3MU6.js +12 -0
- package/dist/provider-A57C3MU6.js.map +1 -0
- package/dist/redact-U72BUBBR.js +77 -0
- package/dist/redact-U72BUBBR.js.map +1 -0
- package/dist/runner-UXNHVVGG.js +20 -0
- package/dist/runner-UXNHVVGG.js.map +1 -0
- package/dist/server-W7OA3DDN.js +530 -0
- package/dist/server-W7OA3DDN.js.map +1 -0
- package/dist/session-TMNOKYLG.js +17 -0
- package/dist/session-TMNOKYLG.js.map +1 -0
- package/dist/studio-command-6VHTHDUK.js +24 -0
- package/dist/studio-command-6VHTHDUK.js.map +1 -0
- package/dist/test-command-AHMOZLV4.js +2852 -0
- package/dist/test-command-AHMOZLV4.js.map +1 -0
- package/dist/validator-35624P7S.js +20 -0
- package/dist/validator-35624P7S.js.map +1 -0
- package/package.json +41 -4
- package/studio-dist/assets/index-DC6DIXfl.js +188 -0
- package/studio-dist/assets/index-DDKsnBwD.css +1 -0
- package/studio-dist/index.html +13 -0
- package/dist/chunk-CYEDLQJ4.js.map +0 -1
- package/dist/chunk-PVNNKPBW.js +0 -64
- package/dist/chunk-PVNNKPBW.js.map +0 -1
- package/dist/chunk-VZZH66U5.js +0 -1781
- package/dist/chunk-VZZH66U5.js.map +0 -1
- package/dist/console-GPV3M3PC.js +0 -71
- package/dist/console-GPV3M3PC.js.map +0 -1
- package/dist/html-GRB34S6X.js.map +0 -1
- package/dist/json-FK2NSRGC.js +0 -20
- package/dist/json-FK2NSRGC.js.map +0 -1
- package/dist/junit-NAGZJOGQ.js.map +0 -1
- package/dist/runner-LBQUCG3K.js +0 -12
- package/dist/session-U7VP5J2C.js +0 -122
- package/dist/session-U7VP5J2C.js.map +0 -1
- package/dist/test-command-WPYLJYIK.js +0 -636
- package/dist/test-command-WPYLJYIK.js.map +0 -1
- package/dist/validator-J4YSBB66.js +0 -33
- package/dist/validator-J4YSBB66.js.map +0 -1
- /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,157 +1,172 @@
|
|
|
1
|
-
|
|
1
|
+
export { F as FlowConfig, a as FlowContext, b as FlowDefinition, c as FlowFn, P as PromiseApp, d as PromiseExpectation, f as flow } from './flow-BUC9Mf8W.js';
|
|
2
|
+
import { P as Platform, A as AppiumExecutionConfig, a as AppConfig } from './coordinator-BbUjvvnX.js';
|
|
3
|
+
export { b as ArtifactConfig, B as BackUntilVisibleOptions, c as BrowserConsoleLog, d as BrowserHAR, e as BrowserJSError, f as BrowserMockResponse, g as BrowserName, h as BrowserNetworkConditions, i as BrowserRouteMatcher, D as DeviceInfo, j as DismissKeyboardOptions, E as ExtendedSelector, k as ProvConfig, R as RelativeSelector, S as ScrollUntilVisibleOptions, l as Selector, T as TouchAction, m as TouchSequence, W as WebExecutionConfig, n as defineConfig } from './coordinator-BbUjvvnX.js';
|
|
4
|
+
export { E as Element } from './element-DZ0HyJ3C.js';
|
|
5
|
+
import 'effect';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
interface AppConfig {
|
|
19
|
-
url?: string;
|
|
20
|
-
packageName?: string;
|
|
21
|
-
bundleId?: string;
|
|
7
|
+
/** Result of a single test step (tap, assertVisible, typeText, etc.) within a flow. */
|
|
8
|
+
interface StepResult {
|
|
9
|
+
/** The command name (e.g., "tap", "assertVisible", "typeText"). */
|
|
10
|
+
command: string;
|
|
11
|
+
/** The selector used for this step, if any. */
|
|
12
|
+
selector?: unknown;
|
|
13
|
+
/** Whether this step passed or failed. */
|
|
14
|
+
status: "passed" | "failed";
|
|
15
|
+
/** Wall-clock duration of this step in milliseconds. */
|
|
16
|
+
durationMs: number;
|
|
17
|
+
/** Error message if this step failed. */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** Screenshots or artifacts captured during this step. */
|
|
20
|
+
attachments?: Attachment[];
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
/** A screenshot, hierarchy dump, or other artifact captured during a test. */
|
|
23
|
+
interface Attachment {
|
|
24
|
+
/** Display name for this attachment (e.g., "failure-screenshot"). */
|
|
25
|
+
name: string;
|
|
26
|
+
/** MIME type: "image/png", "application/json", or "text/plain". */
|
|
27
|
+
contentType: string;
|
|
28
|
+
/** Absolute file path to the attachment on disk. */
|
|
29
|
+
path: string;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
/** Gherkin step keywords used in scenario-style flows. */
|
|
32
|
+
type ScenarioStepKeyword = "Given" | "When" | "Then" | "And" | "But" | "Before" | "After";
|
|
33
|
+
/** Result of a Gherkin scenario step (Given/When/Then). */
|
|
34
|
+
interface ScenarioStepResult {
|
|
35
|
+
/** The Gherkin keyword (Given, When, Then, And, But). */
|
|
36
|
+
keyword: ScenarioStepKeyword;
|
|
37
|
+
/** The step description text. */
|
|
38
|
+
text: string;
|
|
39
|
+
/** Whether this scenario step passed, failed, or was skipped. */
|
|
40
|
+
status: "passed" | "failed" | "skipped";
|
|
41
|
+
/** Wall-clock duration of this step in milliseconds. */
|
|
42
|
+
durationMs: number;
|
|
43
|
+
/** Error message if this step failed. */
|
|
44
|
+
error?: string;
|
|
45
|
+
/** Driver-level steps executed within this scenario step. */
|
|
46
|
+
steps?: StepResult[];
|
|
37
47
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
artifacts?: ArtifactConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Classification of a test failure. Used by the error classifier to categorize
|
|
50
|
+
* failures and provide actionable suggestions.
|
|
51
|
+
*/
|
|
52
|
+
type FailureCategory = "element-not-found" | "element-not-visible" | "element-off-screen" | "element-not-interactive" | "text-mismatch" | "timeout" | "device-disconnected" | "app-crashed" | "app-not-installed" | "driver-error" | "config-error" | "unknown";
|
|
53
|
+
/** Structured error from a failed flow, including classification and actionable suggestion. */
|
|
54
|
+
interface FlowError {
|
|
55
|
+
/** Human-readable error message. */
|
|
56
|
+
message: string;
|
|
57
|
+
/** Stack trace, if available. */
|
|
58
|
+
stack?: string;
|
|
59
|
+
/** Error category for classification and reporting. */
|
|
60
|
+
category: FailureCategory;
|
|
61
|
+
/** Actionable suggestion for resolving the failure (e.g., "increase waitTimeout"). */
|
|
62
|
+
suggestion?: string;
|
|
63
|
+
/** Stable machine-readable code for this failure. */
|
|
64
|
+
errorCode?: string;
|
|
65
|
+
/** Machine-readable remediation guidance for this failure. */
|
|
66
|
+
suggestedFix?: string;
|
|
67
|
+
/** Canonical docs page for follow-up guidance. */
|
|
68
|
+
docsUrl?: string;
|
|
60
69
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}>;
|
|
86
|
-
enabled: Schema.optional<typeof Schema.Boolean>;
|
|
87
|
-
visible: Schema.optional<typeof Schema.Boolean>;
|
|
88
|
-
clickable: Schema.optional<typeof Schema.Boolean>;
|
|
89
|
-
focused: Schema.optional<typeof Schema.Boolean>;
|
|
90
|
-
children: Schema.optional<Schema.Array$<Schema.suspend<any, any, never>>>;
|
|
91
|
-
}>;
|
|
92
|
-
type Element = typeof Element.Type;
|
|
93
|
-
|
|
94
|
-
interface WaitOptions {
|
|
95
|
-
timeout?: number;
|
|
96
|
-
pollInterval?: number;
|
|
97
|
-
settleTimeout?: number;
|
|
70
|
+
/** Result of a single flow execution on a specific platform. */
|
|
71
|
+
interface FlowResult {
|
|
72
|
+
/** Flow name as defined in the flow file. */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Platform this flow ran on. */
|
|
75
|
+
platform: Platform;
|
|
76
|
+
/** Final status after all retry attempts. */
|
|
77
|
+
status: "passed" | "failed" | "skipped";
|
|
78
|
+
/** True if the flow failed initially but passed on retry. */
|
|
79
|
+
flaky?: boolean;
|
|
80
|
+
/** Number of attempts made (present when retries > 0). */
|
|
81
|
+
attempts?: number;
|
|
82
|
+
/** Total wall-clock duration in milliseconds. */
|
|
83
|
+
durationMs: number;
|
|
84
|
+
/** Error details if the flow failed. */
|
|
85
|
+
error?: FlowError;
|
|
86
|
+
/** Screenshots and artifacts captured during this flow. */
|
|
87
|
+
attachments?: Attachment[];
|
|
88
|
+
/** Driver-level step results (tap, assert, type, etc.). */
|
|
89
|
+
steps?: StepResult[];
|
|
90
|
+
/** Gherkin scenario step results (Given/When/Then). */
|
|
91
|
+
scenarioSteps?: ScenarioStepResult[];
|
|
92
|
+
/** Worker/device name when running in parallel mode. */
|
|
93
|
+
workerName?: string;
|
|
98
94
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
back(): Promise<void>;
|
|
127
|
-
takeScreenshot(name?: string): Promise<Uint8Array>;
|
|
95
|
+
/** Aggregate summary of a complete test run across all platforms. */
|
|
96
|
+
interface RunSummary {
|
|
97
|
+
/** Total number of flow executions (flows x platforms). */
|
|
98
|
+
total: number;
|
|
99
|
+
/** Number of flows that passed. */
|
|
100
|
+
passed: number;
|
|
101
|
+
/** Number of flows that failed. */
|
|
102
|
+
failed: number;
|
|
103
|
+
/** Number of flows that were skipped. */
|
|
104
|
+
skipped: number;
|
|
105
|
+
/** Number of flows that were flaky (failed then passed on retry). */
|
|
106
|
+
flaky: number;
|
|
107
|
+
/** Total wall-clock duration of the entire run in milliseconds. */
|
|
108
|
+
durationMs: number;
|
|
109
|
+
/** All individual flow results. */
|
|
110
|
+
results: FlowResult[];
|
|
111
|
+
/** Platforms included in this run. */
|
|
112
|
+
platforms: Platform[];
|
|
113
|
+
/** True if the run was stopped early due to --bail. */
|
|
114
|
+
bailedOut?: boolean;
|
|
115
|
+
/** The bail limit that triggered early stop. */
|
|
116
|
+
bailLimit?: number;
|
|
117
|
+
/** Per-worker execution stats (parallel mode only). */
|
|
118
|
+
workerStats?: Map<string, {
|
|
119
|
+
flowCount: number;
|
|
120
|
+
totalMs: number;
|
|
121
|
+
}>;
|
|
128
122
|
}
|
|
129
|
-
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Reporter interface for receiving test lifecycle events.
|
|
125
|
+
*
|
|
126
|
+
* Implement this interface to create custom reporters. All hooks except
|
|
127
|
+
* `onRunComplete` are optional. Export a Reporter object or a factory
|
|
128
|
+
* function as the default export of your reporter module.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import type { Reporter } from "spana";
|
|
133
|
+
*
|
|
134
|
+
* const myReporter: Reporter = {
|
|
135
|
+
* onFlowFail(result) { console.log(`FAIL: ${result.name}`); },
|
|
136
|
+
* onRunComplete(summary) { console.log(`${summary.passed}/${summary.total} passed`); },
|
|
137
|
+
* };
|
|
138
|
+
* export default myReporter;
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
interface Reporter {
|
|
142
|
+
/** Called when a flow starts execution. */
|
|
143
|
+
onFlowStart?(name: string, platform: Platform, workerName?: string): void;
|
|
144
|
+
/** Called when a flow passes (after all steps succeed). */
|
|
145
|
+
onFlowPass?(result: FlowResult): void;
|
|
146
|
+
/** Called when a flow fails (after all retry attempts are exhausted). */
|
|
147
|
+
onFlowFail?(result: FlowResult): void;
|
|
148
|
+
/** Called once after all flows complete. Required. */
|
|
149
|
+
onRunComplete(summary: RunSummary): void;
|
|
150
|
+
/** Total number of flows to run (for progress display). */
|
|
151
|
+
flowCount?: number;
|
|
152
|
+
/** Per-platform flow counts for detailed progress display. */
|
|
153
|
+
platformFlowCounts?: Partial<Record<Platform, number>>;
|
|
134
154
|
}
|
|
135
155
|
|
|
136
|
-
interface
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
autoLaunch?: boolean;
|
|
141
|
-
artifacts?: ArtifactConfig;
|
|
156
|
+
interface ProviderRunResult {
|
|
157
|
+
passed: boolean;
|
|
158
|
+
name?: string;
|
|
159
|
+
reason?: string;
|
|
142
160
|
}
|
|
143
|
-
interface
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
platform: Platform;
|
|
161
|
+
interface CloudProviderHelper {
|
|
162
|
+
prepareCapabilities(platform: Platform, caps: Record<string, unknown>, appConfig?: AppConfig): Promise<Record<string, unknown>>;
|
|
163
|
+
cleanup(): Promise<void>;
|
|
147
164
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
165
|
+
interface CloudProvider {
|
|
166
|
+
name(): string;
|
|
167
|
+
createHelper(appiumUrl: string, config: AppiumExecutionConfig): CloudProviderHelper;
|
|
168
|
+
extractMeta(sessionId: string, caps: Record<string, unknown>, meta: Record<string, string>): void;
|
|
169
|
+
reportResult(appiumUrl: string, meta: Record<string, string>, result: ProviderRunResult): Promise<void>;
|
|
153
170
|
}
|
|
154
|
-
declare function flow(name: string, fn: FlowFn): FlowDefinition;
|
|
155
|
-
declare function flow(name: string, config: FlowConfig, fn: FlowFn): FlowDefinition;
|
|
156
171
|
|
|
157
|
-
export {
|
|
172
|
+
export { AppConfig, type Attachment, type CloudProvider, type CloudProviderHelper, type FailureCategory, type FlowError, type FlowResult, Platform, type Reporter, type RunSummary, type ScenarioStepResult, type StepResult };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import "./chunk-YBZCOQXJ.js";
|
|
2
|
+
import {
|
|
3
|
+
defineConfig
|
|
4
|
+
} from "./chunk-L7MFJF46.js";
|
|
5
|
+
import "./chunk-S2XNAKSO.js";
|
|
6
|
+
import "./chunk-VNYF5BHX.js";
|
|
7
|
+
import "./chunk-DGUM43GV.js";
|
|
8
|
+
|
|
1
9
|
// src/api/flow.ts
|
|
2
10
|
function flow(name, configOrFn, maybeFn) {
|
|
3
11
|
if (typeof configOrFn === "function") {
|
|
@@ -6,180 +14,46 @@ function flow(name, configOrFn, maybeFn) {
|
|
|
6
14
|
return { name, fn: maybeFn, config: configOrFn };
|
|
7
15
|
}
|
|
8
16
|
|
|
9
|
-
// src/api/app.ts
|
|
10
|
-
import { Effect as Effect3 } from "effect";
|
|
11
|
-
|
|
12
|
-
// src/smart/coordinator.ts
|
|
13
|
-
import { Effect as Effect2 } from "effect";
|
|
14
|
-
|
|
15
|
-
// src/errors.ts
|
|
16
|
-
import { Schema } from "effect";
|
|
17
|
-
var ElementNotFoundError = class extends Schema.TaggedError()(
|
|
18
|
-
"ElementNotFoundError",
|
|
19
|
-
{
|
|
20
|
-
message: Schema.String,
|
|
21
|
-
selector: Schema.Unknown,
|
|
22
|
-
timeoutMs: Schema.optional(Schema.Number)
|
|
23
|
-
}
|
|
24
|
-
) {
|
|
25
|
-
};
|
|
26
|
-
var TextMismatchError = class extends Schema.TaggedError()(
|
|
27
|
-
"TextMismatchError",
|
|
28
|
-
{
|
|
29
|
-
message: Schema.String,
|
|
30
|
-
expected: Schema.String,
|
|
31
|
-
actual: Schema.optional(Schema.String),
|
|
32
|
-
selector: Schema.Unknown
|
|
33
|
-
}
|
|
34
|
-
) {
|
|
35
|
-
};
|
|
36
|
-
var TimeoutError = class extends Schema.TaggedError()(
|
|
37
|
-
"TimeoutError",
|
|
38
|
-
{
|
|
39
|
-
message: Schema.String,
|
|
40
|
-
operation: Schema.String,
|
|
41
|
-
timeoutMs: Schema.Number
|
|
42
|
-
}
|
|
43
|
-
) {
|
|
44
|
-
};
|
|
45
|
-
var WaitTimeoutError = class extends Schema.TaggedError()(
|
|
46
|
-
"WaitTimeoutError",
|
|
47
|
-
{
|
|
48
|
-
message: Schema.String,
|
|
49
|
-
selector: Schema.Unknown,
|
|
50
|
-
timeoutMs: Schema.Number
|
|
51
|
-
}
|
|
52
|
-
) {
|
|
53
|
-
};
|
|
54
|
-
var DriverError = class extends Schema.TaggedError()(
|
|
55
|
-
"DriverError",
|
|
56
|
-
{
|
|
57
|
-
message: Schema.String,
|
|
58
|
-
command: Schema.optional(Schema.String),
|
|
59
|
-
exitCode: Schema.optional(Schema.Number),
|
|
60
|
-
stdout: Schema.optional(Schema.String),
|
|
61
|
-
stderr: Schema.optional(Schema.String)
|
|
62
|
-
}
|
|
63
|
-
) {
|
|
64
|
-
};
|
|
65
|
-
var DeviceDisconnectedError = class extends Schema.TaggedError()(
|
|
66
|
-
"DeviceDisconnectedError",
|
|
67
|
-
{
|
|
68
|
-
message: Schema.String,
|
|
69
|
-
deviceId: Schema.optional(Schema.String),
|
|
70
|
-
platform: Schema.optional(Schema.String)
|
|
71
|
-
}
|
|
72
|
-
) {
|
|
73
|
-
};
|
|
74
|
-
var AppCrashedError = class extends Schema.TaggedError()(
|
|
75
|
-
"AppCrashedError",
|
|
76
|
-
{
|
|
77
|
-
message: Schema.String,
|
|
78
|
-
appId: Schema.optional(Schema.String),
|
|
79
|
-
platform: Schema.optional(Schema.String)
|
|
80
|
-
}
|
|
81
|
-
) {
|
|
82
|
-
};
|
|
83
|
-
var AppNotInstalledError = class extends Schema.TaggedError()(
|
|
84
|
-
"AppNotInstalledError",
|
|
85
|
-
{
|
|
86
|
-
message: Schema.String,
|
|
87
|
-
appId: Schema.String,
|
|
88
|
-
platform: Schema.optional(Schema.String)
|
|
89
|
-
}
|
|
90
|
-
) {
|
|
91
|
-
};
|
|
92
|
-
var FlowSyntaxError = class extends Schema.TaggedError()(
|
|
93
|
-
"FlowSyntaxError",
|
|
94
|
-
{
|
|
95
|
-
message: Schema.String,
|
|
96
|
-
filePath: Schema.String
|
|
97
|
-
}
|
|
98
|
-
) {
|
|
99
|
-
};
|
|
100
|
-
var DeviceNotFoundError = class extends Schema.TaggedError()(
|
|
101
|
-
"DeviceNotFoundError",
|
|
102
|
-
{
|
|
103
|
-
message: Schema.String,
|
|
104
|
-
platform: Schema.optional(Schema.String),
|
|
105
|
-
deviceId: Schema.optional(Schema.String)
|
|
106
|
-
}
|
|
107
|
-
) {
|
|
108
|
-
};
|
|
109
|
-
var ConfigError = class extends Schema.TaggedError()(
|
|
110
|
-
"ConfigError",
|
|
111
|
-
{
|
|
112
|
-
message: Schema.String,
|
|
113
|
-
filePath: Schema.optional(Schema.String)
|
|
114
|
-
}
|
|
115
|
-
) {
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/smart/auto-wait.ts
|
|
119
|
-
import { Duration, Effect } from "effect";
|
|
120
|
-
|
|
121
|
-
// src/api/expect.ts
|
|
122
|
-
import { Effect as Effect4 } from "effect";
|
|
123
|
-
|
|
124
|
-
// src/schemas/selector.ts
|
|
125
|
-
import { Schema as Schema2 } from "effect";
|
|
126
|
-
var TestIDSelector = Schema2.Struct({ testID: Schema2.String });
|
|
127
|
-
var TextSelector = Schema2.Struct({ text: Schema2.String });
|
|
128
|
-
var AccessibilityLabelSelector = Schema2.Struct({ accessibilityLabel: Schema2.String });
|
|
129
|
-
var PointSelector = Schema2.Struct({
|
|
130
|
-
point: Schema2.Struct({ x: Schema2.Number, y: Schema2.Number })
|
|
131
|
-
});
|
|
132
|
-
var Selector = Schema2.Union(
|
|
133
|
-
Schema2.String,
|
|
134
|
-
TestIDSelector,
|
|
135
|
-
TextSelector,
|
|
136
|
-
AccessibilityLabelSelector,
|
|
137
|
-
PointSelector
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
// src/schemas/config.ts
|
|
141
|
-
function defineConfig(config) {
|
|
142
|
-
return config;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
17
|
// src/schemas/element.ts
|
|
146
|
-
import { Schema
|
|
147
|
-
var Bounds =
|
|
148
|
-
x:
|
|
149
|
-
y:
|
|
150
|
-
width:
|
|
151
|
-
height:
|
|
18
|
+
import { Schema } from "effect";
|
|
19
|
+
var Bounds = Schema.Struct({
|
|
20
|
+
x: Schema.Number,
|
|
21
|
+
y: Schema.Number,
|
|
22
|
+
width: Schema.Number,
|
|
23
|
+
height: Schema.Number
|
|
152
24
|
});
|
|
153
|
-
var Element =
|
|
154
|
-
id:
|
|
155
|
-
text:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
25
|
+
var Element = Schema.Struct({
|
|
26
|
+
id: Schema.optional(Schema.String),
|
|
27
|
+
text: Schema.optional(Schema.String),
|
|
28
|
+
value: Schema.optional(Schema.String),
|
|
29
|
+
accessibilityLabel: Schema.optional(Schema.String),
|
|
30
|
+
resourceId: Schema.optional(Schema.String),
|
|
31
|
+
elementType: Schema.optional(Schema.String),
|
|
159
32
|
bounds: Bounds,
|
|
160
|
-
enabled:
|
|
161
|
-
visible:
|
|
162
|
-
clickable:
|
|
163
|
-
focused:
|
|
164
|
-
|
|
165
|
-
|
|
33
|
+
enabled: Schema.optional(Schema.Boolean),
|
|
34
|
+
visible: Schema.optional(Schema.Boolean),
|
|
35
|
+
clickable: Schema.optional(Schema.Boolean),
|
|
36
|
+
focused: Schema.optional(Schema.Boolean),
|
|
37
|
+
attributes: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.String })),
|
|
38
|
+
children: Schema.optional(
|
|
39
|
+
Schema.Array(Schema.suspend(() => Element))
|
|
166
40
|
)
|
|
167
41
|
});
|
|
168
|
-
var ViewHierarchy =
|
|
42
|
+
var ViewHierarchy = Schema.Struct({
|
|
169
43
|
root: Element,
|
|
170
|
-
timestamp:
|
|
44
|
+
timestamp: Schema.Number
|
|
171
45
|
});
|
|
172
46
|
|
|
173
47
|
// src/schemas/device.ts
|
|
174
|
-
import { Schema as
|
|
175
|
-
var DeviceInfo =
|
|
176
|
-
platform:
|
|
177
|
-
deviceId:
|
|
178
|
-
name:
|
|
179
|
-
isEmulator:
|
|
180
|
-
screenWidth:
|
|
181
|
-
screenHeight:
|
|
182
|
-
driverType:
|
|
48
|
+
import { Schema as Schema2 } from "effect";
|
|
49
|
+
var DeviceInfo = Schema2.Struct({
|
|
50
|
+
platform: Schema2.Literal("android", "ios", "web"),
|
|
51
|
+
deviceId: Schema2.String,
|
|
52
|
+
name: Schema2.String,
|
|
53
|
+
isEmulator: Schema2.Boolean,
|
|
54
|
+
screenWidth: Schema2.Number,
|
|
55
|
+
screenHeight: Schema2.Number,
|
|
56
|
+
driverType: Schema2.Literal("playwright", "uiautomator2", "wda", "appium")
|
|
183
57
|
});
|
|
184
58
|
export {
|
|
185
59
|
defineConfig,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/flow.ts","../src/api/app.ts","../src/smart/coordinator.ts","../src/errors.ts","../src/smart/auto-wait.ts","../src/api/expect.ts","../src/schemas/selector.ts","../src/schemas/config.ts","../src/schemas/element.ts","../src/schemas/device.ts"],"sourcesContent":["import type { Selector, Platform } from \"../schemas/selector.js\";\nimport type { ArtifactConfig } from \"../schemas/config.js\";\nimport type { PromiseApp } from \"./app.js\";\nimport type { PromiseExpectation } from \"./expect.js\";\n\nexport interface FlowConfig {\n tags?: string[];\n platforms?: Platform[];\n timeout?: number;\n autoLaunch?: boolean; // default true\n artifacts?: ArtifactConfig;\n}\n\nexport interface FlowContext {\n app: PromiseApp;\n expect: (selector: Selector) => PromiseExpectation;\n platform: Platform;\n}\n\nexport type FlowFn = (ctx: FlowContext) => Promise<void>;\n\nexport interface FlowDefinition {\n name: string;\n fn: FlowFn;\n config: FlowConfig;\n}\n\n// Overloads: flow(name, fn) and flow(name, config, fn)\nexport function flow(name: string, fn: FlowFn): FlowDefinition;\nexport function flow(name: string, config: FlowConfig, fn: FlowFn): FlowDefinition;\nexport function flow(name: string, configOrFn: FlowConfig | FlowFn, maybeFn?: FlowFn): FlowDefinition {\n if (typeof configOrFn === \"function\") {\n return { name, fn: configOrFn, config: {} };\n }\n return { name, fn: maybeFn!, config: configOrFn };\n}\n","import { Effect } from \"effect\";\nimport type { RawDriverService } from \"../drivers/raw-driver.js\";\nimport type { Selector } from \"../schemas/selector.js\";\nimport { createCoordinator, type Direction, type CoordinatorConfig } from \"../smart/coordinator.js\";\nimport type { WaitOptions } from \"../smart/auto-wait.js\";\nimport type { StepRecorder } from \"../core/step-recorder.js\";\n\nexport interface PromiseApp {\n tap(selector: Selector, opts?: WaitOptions): Promise<void>;\n tapXY(x: number, y: number): Promise<void>;\n doubleTap(selector: Selector, opts?: WaitOptions): Promise<void>;\n longPress(selector: Selector, opts?: { duration?: number } & WaitOptions): Promise<void>;\n longPressXY(x: number, y: number, opts?: { duration?: number }): Promise<void>;\n inputText(text: string): Promise<void>;\n pressKey(key: string): Promise<void>;\n hideKeyboard(): Promise<void>;\n swipe(direction: Direction, opts?: { duration?: number }): Promise<void>;\n scroll(direction: Direction): Promise<void>;\n launch(opts?: { deepLink?: string }): Promise<void>;\n stop(): Promise<void>;\n kill(): Promise<void>;\n clearState(): Promise<void>;\n openLink(url: string): Promise<void>;\n back(): Promise<void>;\n takeScreenshot(name?: string): Promise<Uint8Array>;\n}\n\nexport function createPromiseApp(\n driver: RawDriverService,\n appId: string,\n config: CoordinatorConfig,\n recorder?: StepRecorder,\n): PromiseApp {\n const coord = createCoordinator(driver, config);\n\n const run = <A, E>(effect: Effect.Effect<A, E>) =>\n Effect.runPromise(effect);\n\n const runStep = <A>(\n command: string,\n action: () => Promise<A>,\n opts?: { selector?: unknown; captureScreenshot?: boolean },\n ) => recorder\n ? recorder.runStep(command, action, opts)\n : action();\n\n const runScreenshotStep = (\n command: string,\n action: () => Promise<Uint8Array>,\n opts?: { selector?: unknown; name?: string },\n ) => recorder\n ? recorder.runScreenshotStep(command, action, opts)\n : action();\n\n return {\n tap: (selector, opts) => runStep(\"tap\", () => run(coord.tap(selector, opts)), { selector, captureScreenshot: true }),\n tapXY: (x, y) => runStep(\"tapXY\", () => run(coord.tapXY(x, y)), {\n selector: { point: { x, y } },\n captureScreenshot: true,\n }),\n doubleTap: (selector, opts) => runStep(\"doubleTap\", () => run(coord.doubleTap(selector, opts)), { selector, captureScreenshot: true }),\n longPress: (selector, opts) => runStep(\"longPress\", () => run(coord.longPress(selector, opts?.duration, opts)), { selector, captureScreenshot: true }),\n longPressXY: (x, y, opts) => runStep(\"longPressXY\", () => run(coord.longPressXY(x, y, opts?.duration)), {\n selector: { point: { x, y } },\n captureScreenshot: true,\n }),\n inputText: (text) => runStep(\"inputText\", () => run(driver.inputText(text)), { captureScreenshot: true }),\n pressKey: (key) => runStep(`pressKey(${key})`, () => run(driver.pressKey(key)), { captureScreenshot: true }),\n hideKeyboard: () => runStep(\"hideKeyboard\", () => run(driver.hideKeyboard()), { captureScreenshot: true }),\n swipe: (direction, opts) => runStep(`swipe(${direction})`, () => run(coord.swipe(direction, opts)), { captureScreenshot: true }),\n scroll: (direction) => runStep(`scroll(${direction})`, () => run(coord.scroll(direction)), { captureScreenshot: true }),\n launch: (opts) => runStep(\"launch\", () => run(driver.launchApp(appId, opts)), {\n selector: opts,\n captureScreenshot: true,\n }),\n stop: () => runStep(\"stop\", () => run(driver.stopApp(appId)), { captureScreenshot: true }),\n kill: () => runStep(\"kill\", () => run(driver.killApp(appId)), { captureScreenshot: true }),\n clearState: () => runStep(\"clearState\", () => run(driver.clearAppState(appId)), { captureScreenshot: true }),\n openLink: (url) => runStep(\"openLink\", () => run(driver.openLink(url)), {\n selector: { url },\n captureScreenshot: true,\n }),\n back: () => runStep(\"back\", () => run(driver.back()), { captureScreenshot: true }),\n takeScreenshot: (name) => runScreenshotStep(\n name ? `takeScreenshot(${name})` : \"takeScreenshot\",\n () => run(driver.takeScreenshot()),\n { name },\n ),\n };\n}\n","import { Effect } from \"effect\";\nimport type { RawDriverService } from \"../drivers/raw-driver.js\";\nimport type { Element } from \"../schemas/element.js\";\nimport type { Selector } from \"../schemas/selector.js\";\nimport type { DriverError, ElementNotFoundError, WaitTimeoutError } from \"../errors.js\";\nimport { TextMismatchError } from \"../errors.js\";\nimport { centerOf } from \"./element-matcher.js\";\nimport { waitForElement, waitForNotVisible, type WaitOptions } from \"./auto-wait.js\";\n\nexport type Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\ntype HierarchyParser = (raw: string) => Element;\n\nexport interface CoordinatorConfig {\n parse: HierarchyParser;\n defaults?: WaitOptions;\n screenWidth?: number;\n screenHeight?: number;\n}\n\nexport function createCoordinator(driver: RawDriverService, config: CoordinatorConfig) {\n const { parse, defaults } = config;\n\n return {\n tap: (selector: Selector, opts?: WaitOptions): Effect.Effect<void, ElementNotFoundError | WaitTimeoutError | DriverError> =>\n Effect.gen(function* () {\n const element = yield* waitForElement(driver, selector, parse, { ...defaults, ...opts });\n const { x, y } = centerOf(element);\n yield* driver.tapAtCoordinate(x, y);\n }),\n\n tapXY: (x: number, y: number): Effect.Effect<void, DriverError> =>\n driver.tapAtCoordinate(x, y),\n\n doubleTap: (selector: Selector, opts?: WaitOptions): Effect.Effect<void, ElementNotFoundError | WaitTimeoutError | DriverError> =>\n Effect.gen(function* () {\n const element = yield* waitForElement(driver, selector, parse, { ...defaults, ...opts });\n const { x, y } = centerOf(element);\n yield* driver.doubleTapAtCoordinate(x, y);\n }),\n\n longPress: (selector: Selector, duration: number = 1000, opts?: WaitOptions): Effect.Effect<void, ElementNotFoundError | WaitTimeoutError | DriverError> =>\n Effect.gen(function* () {\n const element = yield* waitForElement(driver, selector, parse, { ...defaults, ...opts });\n const { x, y } = centerOf(element);\n yield* driver.longPressAtCoordinate(x, y, duration);\n }),\n\n longPressXY: (x: number, y: number, duration: number = 1000): Effect.Effect<void, DriverError> =>\n driver.longPressAtCoordinate(x, y, duration),\n\n inputText: (text: string): Effect.Effect<void, DriverError> =>\n driver.inputText(text),\n\n pressKey: (key: string): Effect.Effect<void, DriverError> =>\n driver.pressKey(key),\n\n hideKeyboard: (): Effect.Effect<void, DriverError> =>\n driver.hideKeyboard(),\n\n swipe: (direction: Direction, opts?: { duration?: number }): Effect.Effect<void, DriverError> =>\n Effect.gen(function* () {\n const w = config.screenWidth ?? 1080;\n const h = config.screenHeight ?? 1920;\n const cx = w / 2;\n const cy = h / 2;\n const dur = opts?.duration ?? 300;\n const dist = Math.min(w, h) * 0.4;\n\n const coords = {\n up: { startX: cx, startY: cy + dist / 2, endX: cx, endY: cy - dist / 2 },\n down: { startX: cx, startY: cy - dist / 2, endX: cx, endY: cy + dist / 2 },\n left: { startX: cx + dist / 2, startY: cy, endX: cx - dist / 2, endY: cy },\n right: { startX: cx - dist / 2, startY: cy, endX: cx + dist / 2, endY: cy },\n }[direction];\n\n yield* driver.swipe(coords.startX, coords.startY, coords.endX, coords.endY, dur);\n }),\n\n scroll: (direction: Direction): Effect.Effect<void, DriverError> =>\n Effect.gen(function* () {\n const w = config.screenWidth ?? 1080;\n const h = config.screenHeight ?? 1920;\n const cx = w / 2;\n const cy = h / 2;\n const dist = Math.min(w, h) * 0.3;\n\n const coords = {\n up: { startX: cx, startY: cy + dist, endX: cx, endY: cy - dist },\n down: { startX: cx, startY: cy - dist, endX: cx, endY: cy + dist },\n left: { startX: cx + dist, startY: cy, endX: cx - dist, endY: cy },\n right: { startX: cx - dist, startY: cy, endX: cx + dist, endY: cy },\n }[direction];\n\n yield* driver.swipe(coords.startX, coords.startY, coords.endX, coords.endY, 500);\n }),\n\n assertVisible: (selector: Selector, opts?: WaitOptions): Effect.Effect<Element, ElementNotFoundError | WaitTimeoutError | DriverError> =>\n waitForElement(driver, selector, parse, { ...defaults, ...opts }),\n\n assertHidden: (selector: Selector, opts?: WaitOptions): Effect.Effect<void, WaitTimeoutError | DriverError> =>\n waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }),\n\n assertText: (selector: Selector, expected: string, opts?: WaitOptions): Effect.Effect<void, ElementNotFoundError | WaitTimeoutError | TextMismatchError | DriverError> =>\n Effect.gen(function* () {\n const element = yield* waitForElement(driver, selector, parse, { ...defaults, ...opts });\n if (element.text !== expected) {\n return yield* new TextMismatchError({\n message: `Expected text \"${expected}\" but got \"${element.text ?? \"(no text)\"}\"`,\n expected,\n actual: element.text,\n selector,\n });\n }\n }),\n };\n}\n","import { Schema } from \"effect\";\n\n// Assertion errors\n\nexport class ElementNotFoundError extends Schema.TaggedError<ElementNotFoundError>()(\n \"ElementNotFoundError\",\n {\n message: Schema.String,\n selector: Schema.Unknown,\n timeoutMs: Schema.optional(Schema.Number),\n },\n) {}\n\nexport class TextMismatchError extends Schema.TaggedError<TextMismatchError>()(\n \"TextMismatchError\",\n {\n message: Schema.String,\n expected: Schema.String,\n actual: Schema.optional(Schema.String),\n selector: Schema.Unknown,\n },\n) {}\n\n// Timeout errors\n\nexport class TimeoutError extends Schema.TaggedError<TimeoutError>()(\n \"TimeoutError\",\n {\n message: Schema.String,\n operation: Schema.String,\n timeoutMs: Schema.Number,\n },\n) {}\n\nexport class WaitTimeoutError extends Schema.TaggedError<WaitTimeoutError>()(\n \"WaitTimeoutError\",\n {\n message: Schema.String,\n selector: Schema.Unknown,\n timeoutMs: Schema.Number,\n },\n) {}\n\n// Connection errors\n\nexport class DriverError extends Schema.TaggedError<DriverError>()(\n \"DriverError\",\n {\n message: Schema.String,\n command: Schema.optional(Schema.String),\n exitCode: Schema.optional(Schema.Number),\n stdout: Schema.optional(Schema.String),\n stderr: Schema.optional(Schema.String),\n },\n) {}\n\nexport class DeviceDisconnectedError extends Schema.TaggedError<DeviceDisconnectedError>()(\n \"DeviceDisconnectedError\",\n {\n message: Schema.String,\n deviceId: Schema.optional(Schema.String),\n platform: Schema.optional(Schema.String),\n },\n) {}\n\n// App errors\n\nexport class AppCrashedError extends Schema.TaggedError<AppCrashedError>()(\n \"AppCrashedError\",\n {\n message: Schema.String,\n appId: Schema.optional(Schema.String),\n platform: Schema.optional(Schema.String),\n },\n) {}\n\nexport class AppNotInstalledError extends Schema.TaggedError<AppNotInstalledError>()(\n \"AppNotInstalledError\",\n {\n message: Schema.String,\n appId: Schema.String,\n platform: Schema.optional(Schema.String),\n },\n) {}\n\n// Config errors\n\nexport class FlowSyntaxError extends Schema.TaggedError<FlowSyntaxError>()(\n \"FlowSyntaxError\",\n {\n message: Schema.String,\n filePath: Schema.String,\n },\n) {}\n\nexport class DeviceNotFoundError extends Schema.TaggedError<DeviceNotFoundError>()(\n \"DeviceNotFoundError\",\n {\n message: Schema.String,\n platform: Schema.optional(Schema.String),\n deviceId: Schema.optional(Schema.String),\n },\n) {}\n\nexport class ConfigError extends Schema.TaggedError<ConfigError>()(\n \"ConfigError\",\n {\n message: Schema.String,\n filePath: Schema.optional(Schema.String),\n },\n) {}\n\n// Union type of all error types\n\nexport type ProvError =\n | ElementNotFoundError\n | TextMismatchError\n | TimeoutError\n | WaitTimeoutError\n | DriverError\n | DeviceDisconnectedError\n | AppCrashedError\n | AppNotInstalledError\n | FlowSyntaxError\n | DeviceNotFoundError\n | ConfigError;\n","import { Duration, Effect } from \"effect\";\nimport { type DriverError, ElementNotFoundError, WaitTimeoutError } from \"../errors.js\";\nimport type { Element } from \"../schemas/element.js\";\nimport type { Selector } from \"../schemas/selector.js\";\nimport type { RawDriverService } from \"../drivers/raw-driver.js\";\nimport { findElement } from \"./element-matcher.js\";\n\nexport interface WaitOptions {\n timeout?: number; // default 5000ms\n pollInterval?: number; // default 200ms\n settleTimeout?: number; // default 500ms — wait for hierarchy to stabilize\n}\n\nconst DEFAULT_TIMEOUT = 5000;\nconst DEFAULT_POLL_INTERVAL = 200;\n\n/** Parse a raw hierarchy string (JSON from web, XML from native — caller provides parser) */\ntype HierarchyParser = (raw: string) => Element;\n\n/** Poll until an element matching selector is found */\nexport function waitForElement(\n driver: RawDriverService,\n selector: Selector,\n parse: HierarchyParser,\n opts?: WaitOptions,\n): Effect.Effect<Element, ElementNotFoundError | WaitTimeoutError | DriverError> {\n const timeout = opts?.timeout ?? DEFAULT_TIMEOUT;\n const pollInterval = opts?.pollInterval ?? DEFAULT_POLL_INTERVAL;\n\n return Effect.gen(function* () {\n const start = Date.now();\n while (Date.now() - start < timeout) {\n const raw = yield* driver.dumpHierarchy();\n const root = parse(raw);\n const element = findElement(root, selector);\n if (element) return element;\n yield* Effect.sleep(Duration.millis(pollInterval));\n }\n return yield* new ElementNotFoundError({\n message: `Element not found within ${timeout}ms — selector: ${JSON.stringify(selector)}`,\n selector,\n timeoutMs: timeout,\n });\n });\n}\n\n/** Poll until element matching selector is NOT visible */\nexport function waitForNotVisible(\n driver: RawDriverService,\n selector: Selector,\n parse: HierarchyParser,\n opts?: WaitOptions,\n): Effect.Effect<void, WaitTimeoutError | DriverError> {\n const timeout = opts?.timeout ?? DEFAULT_TIMEOUT;\n const pollInterval = opts?.pollInterval ?? DEFAULT_POLL_INTERVAL;\n\n return Effect.gen(function* () {\n const start = Date.now();\n while (Date.now() - start < timeout) {\n const raw = yield* driver.dumpHierarchy();\n const root = parse(raw);\n const element = findElement(root, selector);\n if (!element) return;\n yield* Effect.sleep(Duration.millis(pollInterval));\n }\n return yield* new WaitTimeoutError({\n message: `Element still visible after ${timeout}ms — selector: ${JSON.stringify(selector)}`,\n selector,\n timeoutMs: timeout,\n });\n });\n}\n","import { Effect } from \"effect\";\nimport type { RawDriverService } from \"../drivers/raw-driver.js\";\nimport type { Selector } from \"../schemas/selector.js\";\nimport { createCoordinator, type CoordinatorConfig } from \"../smart/coordinator.js\";\nimport type { WaitOptions } from \"../smart/auto-wait.js\";\nimport type { StepRecorder } from \"../core/step-recorder.js\";\n\nexport interface PromiseExpectation {\n toBeVisible(opts?: WaitOptions): Promise<void>;\n toBeHidden(opts?: WaitOptions): Promise<void>;\n toHaveText(expected: string, opts?: WaitOptions): Promise<void>;\n}\n\nexport function createPromiseExpect(\n driver: RawDriverService,\n config: CoordinatorConfig,\n recorder?: StepRecorder,\n): (selector: Selector) => PromiseExpectation {\n const coord = createCoordinator(driver, config);\n\n const run = <A, E>(effect: Effect.Effect<A, E>) =>\n Effect.runPromise(effect);\n\n const runStep = <A>(\n command: string,\n selector: Selector,\n action: () => Promise<A>,\n ) => recorder\n ? recorder.runStep(command, action, { selector, captureScreenshot: false })\n : action();\n\n return (selector: Selector): PromiseExpectation => ({\n toBeVisible: (opts) => runStep(\"expect.toBeVisible\", selector, () => run(coord.assertVisible(selector, opts)).then(() => {})),\n toBeHidden: (opts) => runStep(\"expect.toBeHidden\", selector, () => run(coord.assertHidden(selector, opts))),\n toHaveText: (expected, opts) => runStep(`expect.toHaveText(${JSON.stringify(expected)})`, selector, () => run(coord.assertText(selector, expected, opts))),\n });\n}\n","import { Schema } from \"effect\";\n\nexport type Platform = \"android\" | \"ios\" | \"web\";\n\nconst TestIDSelector = Schema.Struct({ testID: Schema.String });\nconst TextSelector = Schema.Struct({ text: Schema.String });\nconst AccessibilityLabelSelector = Schema.Struct({ accessibilityLabel: Schema.String });\nconst PointSelector = Schema.Struct({\n point: Schema.Struct({ x: Schema.Number, y: Schema.Number }),\n});\n\nexport const Selector = Schema.Union(\n Schema.String,\n TestIDSelector,\n TextSelector,\n AccessibilityLabelSelector,\n PointSelector,\n);\nexport type Selector = typeof Selector.Type;\n","import type { Platform } from \"./selector.js\";\n\nexport interface LaunchOptions {\n clearState?: boolean;\n clearKeychain?: boolean;\n deepLink?: string;\n launchArguments?: Record<string, unknown>;\n}\n\nexport interface AppConfig {\n url?: string;\n packageName?: string;\n bundleId?: string;\n}\n\nexport interface ArtifactConfig {\n outputDir?: string;\n captureOnFailure?: boolean;\n captureOnSuccess?: boolean;\n captureSteps?: boolean;\n screenshot?: boolean;\n uiHierarchy?: boolean;\n}\n\nexport interface HookContext {\n app: unknown; // Will be typed properly when App is defined\n expect?: unknown;\n platform?: Platform;\n result?: unknown;\n summary?: unknown;\n}\n\nexport interface ProvConfig {\n apps?: {\n web?: AppConfig;\n android?: AppConfig;\n ios?: AppConfig;\n };\n defaults?: {\n waitTimeout?: number;\n pollInterval?: number;\n settleTimeout?: number;\n retries?: number;\n };\n platforms?: Platform[];\n flowDir?: string;\n reporters?: string[];\n hooks?: {\n beforeAll?: (ctx: HookContext) => Promise<void>;\n beforeEach?: (ctx: HookContext) => Promise<void>;\n afterEach?: (ctx: HookContext) => Promise<void>;\n afterAll?: (ctx: HookContext) => Promise<void>;\n };\n artifacts?: ArtifactConfig;\n}\n\nexport function defineConfig(config: ProvConfig): ProvConfig {\n return config;\n}\n","import { Schema } from \"effect\";\n\nexport const Bounds = Schema.Struct({\n x: Schema.Number,\n y: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n});\nexport type Bounds = typeof Bounds.Type;\n\nexport const Element = Schema.Struct({\n id: Schema.optional(Schema.String),\n text: Schema.optional(Schema.String),\n accessibilityLabel: Schema.optional(Schema.String),\n resourceId: Schema.optional(Schema.String),\n elementType: Schema.optional(Schema.String),\n bounds: Bounds,\n enabled: Schema.optional(Schema.Boolean),\n visible: Schema.optional(Schema.Boolean),\n clickable: Schema.optional(Schema.Boolean),\n focused: Schema.optional(Schema.Boolean),\n children: Schema.optional(\n Schema.Array(Schema.suspend((): Schema.Schema<any, any, never> => Element)),\n ),\n});\nexport type Element = typeof Element.Type;\n\nexport const ViewHierarchy = Schema.Struct({\n root: Element,\n timestamp: Schema.Number,\n});\nexport type ViewHierarchy = typeof ViewHierarchy.Type;\n","import { Schema } from \"effect\";\n\nexport const DeviceInfo = Schema.Struct({\n platform: Schema.Literal(\"android\", \"ios\", \"web\"),\n deviceId: Schema.String,\n name: Schema.String,\n isEmulator: Schema.Boolean,\n screenWidth: Schema.Number,\n screenHeight: Schema.Number,\n driverType: Schema.Literal(\"playwright\", \"uiautomator2\", \"wda\"),\n});\nexport type DeviceInfo = typeof DeviceInfo.Type;\n"],"mappings":"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","names":["Effect","Effect","Effect","Schema","Schema","Schema"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/flow.ts","../src/schemas/element.ts","../src/schemas/device.ts"],"sourcesContent":["import type { Selector, Platform } from \"../schemas/selector.js\";\nimport type { ArtifactConfig } from \"../schemas/config.js\";\nimport type { PromiseApp } from \"./app.js\";\nimport type { PromiseExpectation } from \"./expect.js\";\n\nexport interface WhenCondition {\n /** Only run on these platforms */\n platform?: Platform | Platform[];\n /** Only run when this environment variable is set */\n env?: string;\n}\n\nexport interface FlowDefaults {\n waitTimeout?: number;\n pollInterval?: number;\n settleTimeout?: number;\n waitForIdleTimeout?: number;\n typingDelay?: number;\n /** Starting poll interval for adaptive backoff. Default: 50ms. */\n initialPollInterval?: number;\n /** Hierarchy cache TTL in ms. Default: 100. Set to 0 to disable. */\n hierarchyCacheTtl?: number;\n}\n\nexport interface FlowConfig {\n tags?: string[];\n platforms?: Platform[];\n timeout?: number;\n autoLaunch?: boolean; // default true\n artifacts?: ArtifactConfig;\n when?: WhenCondition;\n /** Per-flow overrides for timing defaults. Merged with global defaults. */\n defaults?: FlowDefaults;\n}\n\nexport interface FlowContext {\n app: PromiseApp;\n expect: (selector: Selector) => PromiseExpectation;\n platform: Platform;\n}\n\nexport type FlowFn = (ctx: FlowContext) => Promise<void>;\n\nexport interface FlowDefinition {\n name: string;\n fn: FlowFn;\n config: FlowConfig;\n}\n\n// Overloads: flow(name, fn) and flow(name, config, fn)\nexport function flow(name: string, fn: FlowFn): FlowDefinition;\nexport function flow(name: string, config: FlowConfig, fn: FlowFn): FlowDefinition;\nexport function flow(\n name: string,\n configOrFn: FlowConfig | FlowFn,\n maybeFn?: FlowFn,\n): FlowDefinition {\n if (typeof configOrFn === \"function\") {\n return { name, fn: configOrFn, config: {} };\n }\n return { name, fn: maybeFn!, config: configOrFn };\n}\n","import { Schema } from \"effect\";\n\nexport const Bounds = Schema.Struct({\n x: Schema.Number,\n y: Schema.Number,\n width: Schema.Number,\n height: Schema.Number,\n});\nexport type Bounds = typeof Bounds.Type;\n\nexport const Element = Schema.Struct({\n id: Schema.optional(Schema.String),\n text: Schema.optional(Schema.String),\n value: Schema.optional(Schema.String),\n accessibilityLabel: Schema.optional(Schema.String),\n resourceId: Schema.optional(Schema.String),\n elementType: Schema.optional(Schema.String),\n bounds: Bounds,\n enabled: Schema.optional(Schema.Boolean),\n visible: Schema.optional(Schema.Boolean),\n clickable: Schema.optional(Schema.Boolean),\n focused: Schema.optional(Schema.Boolean),\n attributes: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.String })),\n children: Schema.optional(\n Schema.Array(Schema.suspend((): Schema.Schema<any, any, never> => Element)),\n ),\n});\nexport type Element = typeof Element.Type;\n\nexport const ViewHierarchy = Schema.Struct({\n root: Element,\n timestamp: Schema.Number,\n});\nexport type ViewHierarchy = typeof ViewHierarchy.Type;\n","import { Schema } from \"effect\";\n\nexport const DeviceInfo = Schema.Struct({\n platform: Schema.Literal(\"android\", \"ios\", \"web\"),\n deviceId: Schema.String,\n name: Schema.String,\n isEmulator: Schema.Boolean,\n screenWidth: Schema.Number,\n screenHeight: Schema.Number,\n driverType: Schema.Literal(\"playwright\", \"uiautomator2\", \"wda\", \"appium\"),\n});\nexport type DeviceInfo = typeof DeviceInfo.Type;\n"],"mappings":";;;;;;;;;AAoDO,SAAS,KACd,MACA,YACA,SACgB;AAChB,MAAI,OAAO,eAAe,YAAY;AACpC,WAAO,EAAE,MAAM,IAAI,YAAY,QAAQ,CAAC,EAAE;AAAA,EAC5C;AACA,SAAO,EAAE,MAAM,IAAI,SAAU,QAAQ,WAAW;AAClD;;;AC7DA,SAAS,cAAc;AAEhB,IAAM,SAAS,OAAO,OAAO;AAAA,EAClC,GAAG,OAAO;AAAA,EACV,GAAG,OAAO;AAAA,EACV,OAAO,OAAO;AAAA,EACd,QAAQ,OAAO;AACjB,CAAC;AAGM,IAAM,UAAU,OAAO,OAAO;AAAA,EACnC,IAAI,OAAO,SAAS,OAAO,MAAM;AAAA,EACjC,MAAM,OAAO,SAAS,OAAO,MAAM;AAAA,EACnC,OAAO,OAAO,SAAS,OAAO,MAAM;AAAA,EACpC,oBAAoB,OAAO,SAAS,OAAO,MAAM;AAAA,EACjD,YAAY,OAAO,SAAS,OAAO,MAAM;AAAA,EACzC,aAAa,OAAO,SAAS,OAAO,MAAM;AAAA,EAC1C,QAAQ;AAAA,EACR,SAAS,OAAO,SAAS,OAAO,OAAO;AAAA,EACvC,SAAS,OAAO,SAAS,OAAO,OAAO;AAAA,EACvC,WAAW,OAAO,SAAS,OAAO,OAAO;AAAA,EACzC,SAAS,OAAO,SAAS,OAAO,OAAO;AAAA,EACvC,YAAY,OAAO,SAAS,OAAO,OAAO,EAAE,KAAK,OAAO,QAAQ,OAAO,OAAO,OAAO,CAAC,CAAC;AAAA,EACvF,UAAU,OAAO;AAAA,IACf,OAAO,MAAM,OAAO,QAAQ,MAAsC,OAAO,CAAC;AAAA,EAC5E;AACF,CAAC;AAGM,IAAM,gBAAgB,OAAO,OAAO;AAAA,EACzC,MAAM;AAAA,EACN,WAAW,OAAO;AACpB,CAAC;;;AChCD,SAAS,UAAAA,eAAc;AAEhB,IAAM,aAAaA,QAAO,OAAO;AAAA,EACtC,UAAUA,QAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,EAChD,UAAUA,QAAO;AAAA,EACjB,MAAMA,QAAO;AAAA,EACb,YAAYA,QAAO;AAAA,EACnB,aAAaA,QAAO;AAAA,EACpB,cAAcA,QAAO;AAAA,EACrB,YAAYA,QAAO,QAAQ,cAAc,gBAAgB,OAAO,QAAQ;AAC1E,CAAC;","names":["Schema"]}
|