spana-test 0.4.0 → 0.5.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 +0 -0
- package/LICENSE +0 -0
- package/README.md +199 -68
- package/dist/{accessibility-audit-RS3VIWRT.js → accessibility-audit-YZOPUY3D.js} +7 -3
- package/dist/accessibility-audit-YZOPUY3D.js.map +1 -0
- package/dist/agent/index.d.ts +3 -84
- package/dist/agent/index.js +11 -10
- package/dist/agent/index.js.map +0 -0
- package/dist/allure-RNMEYTXS.js +0 -0
- package/dist/allure-RNMEYTXS.js.map +0 -0
- package/dist/{android-GFW6OXPQ.js → android-4NVTZMHL.js} +6 -2
- package/dist/{android-GFW6OXPQ.js.map → android-4NVTZMHL.js.map} +0 -0
- package/dist/appium-server-66GVUL24.js +0 -0
- package/dist/appium-server-66GVUL24.js.map +0 -0
- package/dist/baseline-manager-5TIUCNP5.js +0 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +0 -0
- package/dist/chunk-3FSZNKEF.js +0 -0
- package/dist/chunk-3FSZNKEF.js.map +0 -0
- package/dist/chunk-3TRMQCUT.js +0 -0
- package/dist/chunk-3TRMQCUT.js.map +0 -0
- package/dist/chunk-3YE2POGD.js +471 -0
- package/dist/chunk-3YE2POGD.js.map +1 -0
- package/dist/chunk-5245YBLL.js +0 -0
- package/dist/chunk-5245YBLL.js.map +0 -0
- package/dist/{chunk-3J4NG7JU.js → chunk-CY3DKTBZ.js} +8 -2
- package/dist/chunk-CY3DKTBZ.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +0 -0
- package/dist/chunk-DGUM43GV.js.map +0 -0
- package/dist/chunk-DTNK54C2.js +127 -0
- package/dist/chunk-DTNK54C2.js.map +1 -0
- package/dist/{chunk-EWIR2GVV.js → chunk-H27IBIGA.js} +19 -2
- package/dist/chunk-H27IBIGA.js.map +1 -0
- package/dist/chunk-H3RWZCID.js +439 -0
- package/dist/chunk-H3RWZCID.js.map +1 -0
- package/dist/{chunk-PZYZ4O6D.js → chunk-HCG4CJKR.js} +23 -5
- package/dist/chunk-HCG4CJKR.js.map +1 -0
- package/dist/{chunk-YGHDMA6D.js → chunk-HYSTRWYN.js} +142 -41
- package/dist/chunk-HYSTRWYN.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +0 -0
- package/dist/chunk-IHVZKQQW.js.map +0 -0
- package/dist/chunk-KJPHH2TW.js +0 -0
- package/dist/chunk-KJPHH2TW.js.map +0 -0
- package/dist/chunk-LAMTF4LX.js +89 -0
- package/dist/chunk-LAMTF4LX.js.map +1 -0
- package/dist/chunk-LRGT342X.js +2300 -0
- package/dist/chunk-LRGT342X.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +0 -0
- package/dist/chunk-OBCFACUW.js.map +0 -0
- package/dist/chunk-PJKIXVSO.js +5019 -0
- package/dist/chunk-PJKIXVSO.js.map +1 -0
- package/dist/chunk-S5JNNDXS.js +0 -0
- package/dist/chunk-S5JNNDXS.js.map +0 -0
- package/dist/{chunk-7VOWF42B.js → chunk-SQL3YRR5.js} +74 -8
- package/dist/chunk-SQL3YRR5.js.map +1 -0
- package/dist/{chunk-KYPLYRKW.js → chunk-UJQ7PID5.js} +47 -15
- package/dist/chunk-UJQ7PID5.js.map +1 -0
- package/dist/{chunk-FJAJ4YNC.js → chunk-WSA5QPTA.js} +2 -2
- package/dist/{chunk-FJAJ4YNC.js.map → chunk-WSA5QPTA.js.map} +0 -0
- package/dist/chunk-X2TJP7LB.js +0 -0
- package/dist/chunk-X2TJP7LB.js.map +0 -0
- package/dist/chunk-XENRC3YO.js +2486 -0
- package/dist/chunk-XENRC3YO.js.map +1 -0
- package/dist/cli.js +60 -20
- package/dist/cli.js.map +1 -1
- package/dist/compiler-X6WTFMYF.js +0 -0
- package/dist/compiler-X6WTFMYF.js.map +0 -0
- package/dist/config-loader-XGDDJGVY.js +9 -0
- package/dist/{config-loader-QM72GKEL.js.map → config-loader-XGDDJGVY.js.map} +0 -0
- package/dist/{console-7UW7VROK.js → console-MI2XB5RG.js} +8 -2
- package/dist/console-MI2XB5RG.js.map +1 -0
- package/dist/daemon-manager-FBISTX24.js +28 -0
- package/dist/{discover-CAQY6EG6.js.map → daemon-manager-FBISTX24.js.map} +0 -0
- package/dist/{discover-CAQY6EG6.js → discover-LHEBSUIP.js} +3 -3
- package/dist/{installer-PVBSX7UC.js.map → discover-LHEBSUIP.js.map} +0 -0
- package/dist/doctor-command-WB3O2H64.js +378 -0
- package/dist/doctor-command-WB3O2H64.js.map +1 -0
- package/dist/filters-Q3ALKWZ5.js +24 -0
- package/dist/{session-2MZVGYAC.js.map → filters-Q3ALKWZ5.js.map} +0 -0
- package/dist/{flow-thjUxXXx.d.ts → flow-CyRC-tTc.d.ts} +15 -7
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/gherkin/steps.js +0 -0
- package/dist/gherkin/steps.js.map +0 -0
- package/dist/github-pr-YMWIPCCZ.js +10 -0
- package/dist/github-pr-YMWIPCCZ.js.map +1 -0
- package/dist/html-F3X3XPSX.js +0 -0
- package/dist/html-F3X3XPSX.js.map +0 -0
- package/dist/index.d.ts +1129 -6
- package/dist/index.js +575 -6
- package/dist/index.js.map +1 -1
- package/dist/{init-command-U66XCM66.js → init-command-Z3QREABL.js} +60 -1
- package/dist/init-command-Z3QREABL.js.map +1 -0
- package/dist/{init-flow-command-PR7J5FBM.js → init-flow-command-4EKRVTNT.js} +2 -2
- package/dist/{init-flow-command-PR7J5FBM.js.map → init-flow-command-4EKRVTNT.js.map} +0 -0
- package/dist/{installer-PVBSX7UC.js → installer-VUPFWP5X.js} +7 -2
- package/dist/installer-VUPFWP5X.js.map +1 -0
- package/dist/ios-JPK43TFZ.js +0 -0
- package/dist/ios-JPK43TFZ.js.map +0 -0
- package/dist/json-JMRPUVY2.js +0 -0
- package/dist/json-JMRPUVY2.js.map +0 -0
- package/dist/junit-HLC62MK6.js +0 -0
- package/dist/junit-HLC62MK6.js.map +0 -0
- package/dist/machine-6H25TRTU.js +0 -0
- package/dist/machine-6H25TRTU.js.map +0 -0
- package/dist/provider-YIPU5K42.js +0 -0
- package/dist/provider-YIPU5K42.js.map +0 -0
- package/dist/redact-U72BUBBR.js +0 -0
- package/dist/redact-U72BUBBR.js.map +0 -0
- package/dist/runner-6HK62Q7B.js +0 -0
- package/dist/runner-6HK62Q7B.js.map +0 -0
- package/dist/screenshot-compare-3QRHHSFZ.js +116 -0
- package/dist/screenshot-compare-3QRHHSFZ.js.map +1 -0
- package/dist/{server-PZBRGU7P.js → server-PRM7BVVD.js} +14 -13
- package/dist/{server-PZBRGU7P.js.map → server-PRM7BVVD.js.map} +1 -1
- package/dist/server-QWJJB3WG.js +14 -0
- package/dist/server-QWJJB3WG.js.map +1 -0
- package/dist/session-2E6OK6BH.js +18 -0
- package/dist/session-2E6OK6BH.js.map +1 -0
- package/dist/session-Ddem-Q5n.d.ts +119 -0
- package/dist/{storybook-pBOPe_1D.d.ts → storybook-CxaP3YDz.d.ts} +265 -4
- package/dist/{studio-command-YDWQOMRX.js → studio-command-O3NN5BCG.js} +2 -2
- package/dist/{studio-command-YDWQOMRX.js.map → studio-command-O3NN5BCG.js.map} +0 -0
- package/dist/{test-command-B2VLWGDK.js → test-command-FYOZ6QAE.js} +231 -1341
- package/dist/test-command-FYOZ6QAE.js.map +1 -0
- package/dist/validator-HZ2A3NEI.js +0 -0
- package/dist/validator-HZ2A3NEI.js.map +0 -0
- package/package.json +7 -3
- package/studio-dist/assets/index-C-Io44gy.js +0 -0
- package/studio-dist/assets/index-DfM9lK4p.css +0 -0
- package/studio-dist/index.html +0 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +0 -1
- package/dist/chunk-3J4NG7JU.js.map +0 -1
- package/dist/chunk-7VOWF42B.js.map +0 -1
- package/dist/chunk-EWIR2GVV.js.map +0 -1
- package/dist/chunk-KYPLYRKW.js.map +0 -1
- package/dist/chunk-LC3QJIHY.js +0 -440
- package/dist/chunk-LC3QJIHY.js.map +0 -1
- package/dist/chunk-MCT4DYDK.js +0 -2671
- package/dist/chunk-MCT4DYDK.js.map +0 -1
- package/dist/chunk-PZYZ4O6D.js.map +0 -1
- package/dist/chunk-YAV6KBSW.js +0 -1318
- package/dist/chunk-YAV6KBSW.js.map +0 -1
- package/dist/chunk-YGHDMA6D.js.map +0 -1
- package/dist/config-loader-QM72GKEL.js +0 -9
- package/dist/console-7UW7VROK.js.map +0 -1
- package/dist/doctor-command-YGQPO7GH.js +0 -71
- package/dist/doctor-command-YGQPO7GH.js.map +0 -1
- package/dist/element-DZ0HyJ3C.d.ts +0 -25
- package/dist/init-command-U66XCM66.js.map +0 -1
- package/dist/screenshot-compare-JFHH2WR4.js +0 -75
- package/dist/screenshot-compare-JFHH2WR4.js.map +0 -1
- package/dist/session-2MZVGYAC.js +0 -17
- package/dist/test-command-B2VLWGDK.js.map +0 -1
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WSA5QPTA.js";
|
|
4
4
|
import {
|
|
5
5
|
collectDiagnosticSections
|
|
6
6
|
} from "./chunk-KJPHH2TW.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
buildElectrobunRuntime,
|
|
9
|
+
buildElectronRuntime,
|
|
10
|
+
buildLocalAndroidRuntime,
|
|
11
|
+
buildLocalIOSRuntime,
|
|
12
|
+
buildWebRuntime,
|
|
13
|
+
buildWebRuntimePool,
|
|
14
|
+
classifyError,
|
|
15
|
+
executeFlow,
|
|
16
|
+
runParallel,
|
|
17
|
+
speculativelyPrelaunchWebBrowser
|
|
18
|
+
} from "./chunk-LRGT342X.js";
|
|
19
|
+
import "./chunk-SQL3YRR5.js";
|
|
14
20
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
parseAndroidHierarchy,
|
|
19
|
-
parseIOSHierarchy,
|
|
20
|
-
resolveNetworkConditions,
|
|
21
|
-
setupUiAutomator2
|
|
22
|
-
} from "./chunk-MCT4DYDK.js";
|
|
23
|
-
import {
|
|
24
|
-
setupWDA
|
|
25
|
-
} from "./chunk-YGHDMA6D.js";
|
|
26
|
-
import {
|
|
27
|
-
ensureAndroidDevice
|
|
28
|
-
} from "./chunk-EWIR2GVV.js";
|
|
29
|
-
import {
|
|
30
|
-
connectPhysicalDevice,
|
|
31
|
-
ensureAppInstalled,
|
|
32
|
-
ensureIOSSimulator,
|
|
33
|
-
firstIOSPhysicalDevice
|
|
34
|
-
} from "./chunk-S5JNNDXS.js";
|
|
35
|
-
import {
|
|
36
|
-
allocatePort
|
|
37
|
-
} from "./chunk-OBCFACUW.js";
|
|
21
|
+
createCloudProviderHelper,
|
|
22
|
+
detectProvider
|
|
23
|
+
} from "./chunk-X2TJP7LB.js";
|
|
38
24
|
import {
|
|
39
25
|
applyShard,
|
|
40
26
|
discoverFlows,
|
|
@@ -44,988 +30,27 @@ import {
|
|
|
44
30
|
loadTestSource
|
|
45
31
|
} from "./chunk-3TRMQCUT.js";
|
|
46
32
|
import {
|
|
47
|
-
DriverError,
|
|
48
33
|
buildIOSLaunchConfiguration,
|
|
49
34
|
deviceStateToAppiumCapabilities,
|
|
50
|
-
flattenElements,
|
|
51
35
|
hasLaunchDeviceState,
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
parseAndroidHierarchy,
|
|
37
|
+
parseIOSHierarchy,
|
|
38
|
+
resolveNetworkConditions,
|
|
54
39
|
splitGraphemes
|
|
55
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-PJKIXVSO.js";
|
|
56
41
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
DriverError
|
|
43
|
+
} from "./chunk-XENRC3YO.js";
|
|
44
|
+
import "./chunk-HYSTRWYN.js";
|
|
45
|
+
import "./chunk-DTNK54C2.js";
|
|
46
|
+
import "./chunk-S5JNNDXS.js";
|
|
47
|
+
import "./chunk-OBCFACUW.js";
|
|
48
|
+
import "./chunk-H27IBIGA.js";
|
|
60
49
|
import "./chunk-DGUM43GV.js";
|
|
61
50
|
|
|
62
51
|
// src/cli/test-command.ts
|
|
63
52
|
import { resolve as resolve3, dirname as dirname3 } from "path";
|
|
64
53
|
|
|
65
|
-
// src/core/engine.ts
|
|
66
|
-
import { Effect as Effect3 } from "effect";
|
|
67
|
-
|
|
68
|
-
// src/core/artifacts.ts
|
|
69
|
-
import { writeFileSync, mkdirSync } from "fs";
|
|
70
|
-
import { join } from "path";
|
|
71
|
-
import { Effect } from "effect";
|
|
72
|
-
var DEFAULT_ARTIFACT_CONFIG = {
|
|
73
|
-
outputDir: "./spana-output",
|
|
74
|
-
captureOnFailure: true,
|
|
75
|
-
captureOnSuccess: false,
|
|
76
|
-
captureSteps: false,
|
|
77
|
-
screenshot: true,
|
|
78
|
-
uiHierarchy: true,
|
|
79
|
-
consoleLogs: true,
|
|
80
|
-
jsErrors: true,
|
|
81
|
-
har: true
|
|
82
|
-
};
|
|
83
|
-
function safeName(value) {
|
|
84
|
-
return value.replaceAll(/[^a-zA-Z0-9-_]/g, "_").replaceAll(/_+/g, "_").replaceAll(/^_+|_+$/g, "").slice(0, 80) || "artifact";
|
|
85
|
-
}
|
|
86
|
-
function flowArtifactDir(config, flowName, platform) {
|
|
87
|
-
const dir = join(config.outputDir, `${safeName(flowName)}-${platform}`);
|
|
88
|
-
mkdirSync(dir, { recursive: true });
|
|
89
|
-
return dir;
|
|
90
|
-
}
|
|
91
|
-
function createAttachment(name, contentType, path) {
|
|
92
|
-
return { name, contentType, path };
|
|
93
|
-
}
|
|
94
|
-
function writeJsonAttachment(dir, fileName, attachmentName, value) {
|
|
95
|
-
const path = join(dir, fileName);
|
|
96
|
-
writeFileSync(path, JSON.stringify(value, null, 2), "utf-8");
|
|
97
|
-
return createAttachment(attachmentName, "application/json", path);
|
|
98
|
-
}
|
|
99
|
-
function writeTextAttachment(dir, fileName, attachmentName, value) {
|
|
100
|
-
const path = join(dir, fileName);
|
|
101
|
-
writeFileSync(path, value, "utf-8");
|
|
102
|
-
return createAttachment(attachmentName, "text/plain", path);
|
|
103
|
-
}
|
|
104
|
-
function resolveArtifactConfig(...configs) {
|
|
105
|
-
return configs.reduce(
|
|
106
|
-
(resolved, config) => ({
|
|
107
|
-
...resolved,
|
|
108
|
-
...config
|
|
109
|
-
}),
|
|
110
|
-
{ ...DEFAULT_ARTIFACT_CONFIG }
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
async function captureArtifacts(driver, config, flowName, platform, status) {
|
|
114
|
-
const shouldCapture = status === "failed" && config.captureOnFailure || status === "passed" && config.captureOnSuccess;
|
|
115
|
-
if (!shouldCapture) return [];
|
|
116
|
-
const attachments = [];
|
|
117
|
-
const dir = flowArtifactDir(config, flowName, platform);
|
|
118
|
-
if (config.screenshot) {
|
|
119
|
-
try {
|
|
120
|
-
const screenshot = await Effect.runPromise(Effect.orDie(driver.takeScreenshot()));
|
|
121
|
-
const path = join(dir, "screenshot.png");
|
|
122
|
-
writeFileSync(path, screenshot);
|
|
123
|
-
attachments.push(createAttachment(`${status}-screenshot`, "image/png", path));
|
|
124
|
-
} catch {
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (config.uiHierarchy) {
|
|
128
|
-
try {
|
|
129
|
-
const hierarchy = await Effect.runPromise(Effect.orDie(driver.dumpHierarchy()));
|
|
130
|
-
const path = join(dir, "hierarchy.json");
|
|
131
|
-
writeFileSync(path, hierarchy, "utf-8");
|
|
132
|
-
attachments.push(createAttachment(`${status}-hierarchy`, "application/json", path));
|
|
133
|
-
} catch {
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (config.consoleLogs && driver.getConsoleLogs) {
|
|
137
|
-
try {
|
|
138
|
-
const consoleLogs = await Effect.runPromise(Effect.orDie(driver.getConsoleLogs()));
|
|
139
|
-
if (consoleLogs.length > 0) {
|
|
140
|
-
attachments.push(
|
|
141
|
-
writeJsonAttachment(dir, "console-logs.json", `${status}-console-logs`, consoleLogs)
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
} catch {
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (config.jsErrors && driver.getJSErrors) {
|
|
148
|
-
try {
|
|
149
|
-
const jsErrors = await Effect.runPromise(Effect.orDie(driver.getJSErrors()));
|
|
150
|
-
if (jsErrors.length > 0) {
|
|
151
|
-
attachments.push(
|
|
152
|
-
writeJsonAttachment(dir, "js-errors.json", `${status}-js-errors`, jsErrors)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
} catch {
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (config.har && driver.getHAR) {
|
|
159
|
-
try {
|
|
160
|
-
const har = await Effect.runPromise(Effect.orDie(driver.getHAR()));
|
|
161
|
-
if (har.log.entries.length > 0) {
|
|
162
|
-
attachments.push(writeJsonAttachment(dir, "network.har", `${status}-network-har`, har));
|
|
163
|
-
}
|
|
164
|
-
} catch {
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (status === "failed" && driver.getDriverLogs) {
|
|
168
|
-
try {
|
|
169
|
-
const driverLogs = await Effect.runPromise(Effect.orDie(driver.getDriverLogs()));
|
|
170
|
-
if (driverLogs.length > 0) {
|
|
171
|
-
attachments.push(
|
|
172
|
-
writeTextAttachment(
|
|
173
|
-
dir,
|
|
174
|
-
"driver-logs.txt",
|
|
175
|
-
`${status}-driver-logs`,
|
|
176
|
-
driverLogs.join("\n")
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return attachments;
|
|
184
|
-
}
|
|
185
|
-
async function captureStepScreenshot(driver, config, flowName, platform, stepIndex, stepName, screenshot) {
|
|
186
|
-
if (!config.screenshot) return void 0;
|
|
187
|
-
try {
|
|
188
|
-
const dir = join(flowArtifactDir(config, flowName, platform), "steps");
|
|
189
|
-
mkdirSync(dir, { recursive: true });
|
|
190
|
-
const fileName = `${String(stepIndex).padStart(3, "0")}-${safeName(stepName)}.png`;
|
|
191
|
-
const path = join(dir, fileName);
|
|
192
|
-
const bytes = screenshot ?? await Effect.runPromise(Effect.orDie(driver.takeScreenshot()));
|
|
193
|
-
writeFileSync(path, bytes);
|
|
194
|
-
return createAttachment(stepName, "image/png", path);
|
|
195
|
-
} catch {
|
|
196
|
-
return void 0;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/core/debug-repl.ts
|
|
201
|
-
import * as repl from "repl";
|
|
202
|
-
import { Effect as Effect2 } from "effect";
|
|
203
|
-
var didStartDebugRepl = false;
|
|
204
|
-
function toSuggestedSelectors(root) {
|
|
205
|
-
return flattenElements(root).filter((el) => el.visible !== false && (el.id || el.text || el.accessibilityLabel)).map((el) => ({
|
|
206
|
-
suggestedSelector: el.id ? { testID: el.id } : el.accessibilityLabel ? { accessibilityLabel: el.accessibilityLabel } : el.text ? { text: el.text } : "",
|
|
207
|
-
elementType: el.elementType,
|
|
208
|
-
text: el.text,
|
|
209
|
-
accessibilityLabel: el.accessibilityLabel,
|
|
210
|
-
bounds: el.bounds,
|
|
211
|
-
id: el.id
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
async function runDebugReplOnce(context) {
|
|
215
|
-
if (didStartDebugRepl) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
didStartDebugRepl = true;
|
|
219
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
220
|
-
console.log("Skipping debug REPL because stdin/stdout is not interactive.");
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
const hierarchy = async () => context.parseHierarchy(await Effect2.runPromise(context.driver.dumpHierarchy()));
|
|
224
|
-
const selectors = async () => toSuggestedSelectors(await hierarchy());
|
|
225
|
-
console.log("");
|
|
226
|
-
console.log(`Entering debug REPL for failed flow "${context.flowName}" on ${context.platform}.`);
|
|
227
|
-
console.log(
|
|
228
|
-
"Available bindings: app, expect, driver, platform, flowName, error, hierarchy(), selectors(), help()"
|
|
229
|
-
);
|
|
230
|
-
console.log('Use top-level await for async calls, for example: await app.tap({ text: "Login" })');
|
|
231
|
-
const replServer = repl.start({
|
|
232
|
-
prompt: `spana:${context.platform}> `,
|
|
233
|
-
ignoreUndefined: true,
|
|
234
|
-
useGlobal: false
|
|
235
|
-
});
|
|
236
|
-
replServer.context.app = context.app;
|
|
237
|
-
replServer.context.expect = context.expect;
|
|
238
|
-
replServer.context.driver = context.driver;
|
|
239
|
-
replServer.context.platform = context.platform;
|
|
240
|
-
replServer.context.flowName = context.flowName;
|
|
241
|
-
replServer.context.error = context.error;
|
|
242
|
-
replServer.context.hierarchy = hierarchy;
|
|
243
|
-
replServer.context.selectors = selectors;
|
|
244
|
-
replServer.context.help = () => {
|
|
245
|
-
console.log("app Promise-based app API with auto-waiting");
|
|
246
|
-
console.log("expect Assertion helper, e.g. await expect({ text: 'Done' }).toBeVisible()");
|
|
247
|
-
console.log("driver Raw driver service");
|
|
248
|
-
console.log("hierarchy Async helper returning the parsed UI tree");
|
|
249
|
-
console.log("selectors Async helper returning suggested selectors");
|
|
250
|
-
console.log(".exit Leave the REPL");
|
|
251
|
-
};
|
|
252
|
-
await new Promise((resolve4) => replServer.on("exit", resolve4));
|
|
253
|
-
console.log("");
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// src/core/step-recorder.ts
|
|
258
|
-
function errorMessage(error) {
|
|
259
|
-
return error instanceof Error ? error.message : String(error);
|
|
260
|
-
}
|
|
261
|
-
function createStepResult(command, durationMs, status, selector, error, attachments) {
|
|
262
|
-
return {
|
|
263
|
-
command,
|
|
264
|
-
selector,
|
|
265
|
-
status,
|
|
266
|
-
durationMs,
|
|
267
|
-
error,
|
|
268
|
-
attachments: attachments && attachments.length > 0 ? attachments : void 0
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function createStepRecorder(driver, artifactConfig, flowName, platform) {
|
|
272
|
-
const steps = [];
|
|
273
|
-
return {
|
|
274
|
-
async runStep(command, action, opts) {
|
|
275
|
-
const startedAt = Date.now();
|
|
276
|
-
try {
|
|
277
|
-
const result = await action();
|
|
278
|
-
const attachments = [];
|
|
279
|
-
if (opts?.captureScreenshot && artifactConfig.captureSteps) {
|
|
280
|
-
const attachment = await captureStepScreenshot(
|
|
281
|
-
driver,
|
|
282
|
-
artifactConfig,
|
|
283
|
-
flowName,
|
|
284
|
-
platform,
|
|
285
|
-
steps.length + 1,
|
|
286
|
-
command
|
|
287
|
-
);
|
|
288
|
-
if (attachment) attachments.push(attachment);
|
|
289
|
-
}
|
|
290
|
-
steps.push(
|
|
291
|
-
createStepResult(
|
|
292
|
-
command,
|
|
293
|
-
Date.now() - startedAt,
|
|
294
|
-
"passed",
|
|
295
|
-
opts?.selector,
|
|
296
|
-
void 0,
|
|
297
|
-
attachments
|
|
298
|
-
)
|
|
299
|
-
);
|
|
300
|
-
return result;
|
|
301
|
-
} catch (error) {
|
|
302
|
-
steps.push(
|
|
303
|
-
createStepResult(
|
|
304
|
-
command,
|
|
305
|
-
Date.now() - startedAt,
|
|
306
|
-
"failed",
|
|
307
|
-
opts?.selector,
|
|
308
|
-
errorMessage(error)
|
|
309
|
-
)
|
|
310
|
-
);
|
|
311
|
-
throw error;
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
async runScreenshotStep(command, action, opts) {
|
|
315
|
-
const startedAt = Date.now();
|
|
316
|
-
try {
|
|
317
|
-
const screenshot = await action();
|
|
318
|
-
const attachment = await captureStepScreenshot(
|
|
319
|
-
driver,
|
|
320
|
-
artifactConfig,
|
|
321
|
-
flowName,
|
|
322
|
-
platform,
|
|
323
|
-
steps.length + 1,
|
|
324
|
-
opts?.name ?? command,
|
|
325
|
-
screenshot
|
|
326
|
-
);
|
|
327
|
-
steps.push(
|
|
328
|
-
createStepResult(
|
|
329
|
-
command,
|
|
330
|
-
Date.now() - startedAt,
|
|
331
|
-
"passed",
|
|
332
|
-
opts?.selector,
|
|
333
|
-
void 0,
|
|
334
|
-
attachment ? [attachment] : void 0
|
|
335
|
-
)
|
|
336
|
-
);
|
|
337
|
-
return screenshot;
|
|
338
|
-
} catch (error) {
|
|
339
|
-
steps.push(
|
|
340
|
-
createStepResult(
|
|
341
|
-
command,
|
|
342
|
-
Date.now() - startedAt,
|
|
343
|
-
"failed",
|
|
344
|
-
opts?.selector,
|
|
345
|
-
errorMessage(error)
|
|
346
|
-
)
|
|
347
|
-
);
|
|
348
|
-
throw error;
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
getSteps() {
|
|
352
|
-
return steps;
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// src/report/classify-error.ts
|
|
358
|
-
var TAG_KEY = "_tag";
|
|
359
|
-
function selectorHint(selector) {
|
|
360
|
-
if (selector && typeof selector === "object") {
|
|
361
|
-
const s = selector;
|
|
362
|
-
if (s.testID) return `testID="${s.testID}"`;
|
|
363
|
-
if (s.text) return `text="${s.text}"`;
|
|
364
|
-
if (s.accessibilityLabel) return `accessibilityLabel="${s.accessibilityLabel}"`;
|
|
365
|
-
}
|
|
366
|
-
return JSON.stringify(selector);
|
|
367
|
-
}
|
|
368
|
-
function categorizeElementFailure(message) {
|
|
369
|
-
const lower = message.toLowerCase();
|
|
370
|
-
if (lower.includes("not visible") || lower.includes("visible=false")) {
|
|
371
|
-
return "element-not-visible";
|
|
372
|
-
}
|
|
373
|
-
if (lower.includes("off-screen") || lower.includes("zero size")) {
|
|
374
|
-
return "element-off-screen";
|
|
375
|
-
}
|
|
376
|
-
if (lower.includes("disabled") || lower.includes("not interactive")) {
|
|
377
|
-
return "element-not-interactive";
|
|
378
|
-
}
|
|
379
|
-
return "element-not-found";
|
|
380
|
-
}
|
|
381
|
-
function elementSuggestion(category, selector, timeoutMs) {
|
|
382
|
-
switch (category) {
|
|
383
|
-
case "element-not-visible":
|
|
384
|
-
return [
|
|
385
|
-
`Selector ${selector} matched an element, but it is currently hidden.`,
|
|
386
|
-
"Check whether an animation, modal, or loading state is covering it before retrying.",
|
|
387
|
-
"Consider increasing waitTimeout if the element becomes visible after a delay."
|
|
388
|
-
].join("\n");
|
|
389
|
-
case "element-off-screen":
|
|
390
|
-
return [
|
|
391
|
-
`Selector ${selector} matched an element that is off-screen.`,
|
|
392
|
-
"Use scrollUntilVisible() or scroll to the element before interacting with it.",
|
|
393
|
-
"If the target is above the current viewport, reverse the search direction."
|
|
394
|
-
].join("\n");
|
|
395
|
-
case "element-not-interactive":
|
|
396
|
-
return [
|
|
397
|
-
`Selector ${selector} matched an element that is disabled or not interactive.`,
|
|
398
|
-
"Wait for the app to enable it, or verify the prerequisite app state first.",
|
|
399
|
-
"Consider increasing waitTimeout if the control becomes enabled after async work completes."
|
|
400
|
-
].join("\n");
|
|
401
|
-
default:
|
|
402
|
-
return [
|
|
403
|
-
`Selector ${selector} was not found within ${timeoutMs ?? "?"}ms.`,
|
|
404
|
-
"Run `spana selectors` to inspect the current screen and confirm the best selector.",
|
|
405
|
-
"Consider increasing waitTimeout if the element appears after a delay."
|
|
406
|
-
].join("\n");
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
function categorizeDynamic(error, tag, msg) {
|
|
410
|
-
if (tag === "ElementNotFoundError" || tag === "WaitTimeoutError") {
|
|
411
|
-
const sel = selectorHint(error.selector);
|
|
412
|
-
if (msg.includes("scroll(s) toward")) {
|
|
413
|
-
return {
|
|
414
|
-
category: "element-not-found",
|
|
415
|
-
suggestion: [
|
|
416
|
-
`Selector ${sel} stayed off-screen while scrolling.`,
|
|
417
|
-
"Try increasing `maxScrolls` or `timeout`, or reverse the search direction",
|
|
418
|
-
'if the target is actually above the current viewport (for example `{ direction: "up" }`).'
|
|
419
|
-
].join("\n")
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
if (msg.includes("back action(s)")) {
|
|
423
|
-
return {
|
|
424
|
-
category: "element-not-found",
|
|
425
|
-
suggestion: [
|
|
426
|
-
`Selector ${sel} was not reached while navigating back.`,
|
|
427
|
-
"Try increasing `maxBacks` or `timeout`, or prefer an explicit in-app",
|
|
428
|
-
"back / close control on iOS-style screens instead of relying on system back."
|
|
429
|
-
].join("\n")
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
const category = categorizeElementFailure(msg);
|
|
433
|
-
return {
|
|
434
|
-
category,
|
|
435
|
-
suggestion: elementSuggestion(category, sel, error.timeoutMs)
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
if (tag === "TextMismatchError") {
|
|
439
|
-
const e = error;
|
|
440
|
-
return {
|
|
441
|
-
category: "text-mismatch",
|
|
442
|
-
suggestion: [
|
|
443
|
-
`Expected text "${e.expected}" but found "${e.actual ?? "(empty)"}".`,
|
|
444
|
-
"The element exists but its content differs. Check for whitespace, truncation,",
|
|
445
|
-
"or platform-specific text rendering differences."
|
|
446
|
-
].join("\n")
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
if (tag === "DeviceDisconnectedError") {
|
|
450
|
-
const id = error.deviceId ? ` (${error.deviceId})` : "";
|
|
451
|
-
return {
|
|
452
|
-
category: "device-disconnected",
|
|
453
|
-
suggestion: [
|
|
454
|
-
`The device${id} disconnected during the test.`,
|
|
455
|
-
"Check the physical connection or emulator/simulator stability.",
|
|
456
|
-
"Run `spana devices` to verify available devices."
|
|
457
|
-
].join("\n")
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
if (tag === "AppCrashedError") {
|
|
461
|
-
const app = error.appId ? ` (${error.appId})` : "";
|
|
462
|
-
return {
|
|
463
|
-
category: "app-crashed",
|
|
464
|
-
suggestion: [
|
|
465
|
-
`The app${app} crashed during the test.`,
|
|
466
|
-
"Check the device logs for a crash stack trace:",
|
|
467
|
-
" Android: `adb logcat -d | grep FATAL`",
|
|
468
|
-
" iOS: Check Console.app or `log show --predicate 'process == \"your-app\"'`"
|
|
469
|
-
].join("\n")
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
if (tag === "AppNotInstalledError") {
|
|
473
|
-
return {
|
|
474
|
-
category: "app-not-installed",
|
|
475
|
-
suggestion: [
|
|
476
|
-
`App "${error.appId}" is not installed on the device.`,
|
|
477
|
-
"Install it before running tests, or configure `apps.android.appPath`",
|
|
478
|
-
"/ `apps.ios.appPath` in spana.config.ts for auto-install."
|
|
479
|
-
].join("\n")
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
if (tag === "DriverError") {
|
|
483
|
-
return categorizeDynamicDriver(error, msg);
|
|
484
|
-
}
|
|
485
|
-
return void 0;
|
|
486
|
-
}
|
|
487
|
-
function categorizeDynamicDriver(error, msg) {
|
|
488
|
-
for (const rule of driverRules) {
|
|
489
|
-
if (rule.pattern && matchesPattern(msg, rule.pattern)) {
|
|
490
|
-
return {
|
|
491
|
-
category: typeof rule.category === "function" ? rule.category(msg) : rule.category,
|
|
492
|
-
suggestion: typeof rule.suggestion === "function" ? rule.suggestion(error, msg) : rule.suggestion
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return {
|
|
497
|
-
category: "driver-error",
|
|
498
|
-
suggestion: error.command ? `Driver command "${error.command}" failed. Check the device connection and driver logs.` : "A low-level driver operation failed. Check the device connection and driver logs."
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
var driverRules = [
|
|
502
|
-
{
|
|
503
|
-
pattern: "dismissKeyboard()",
|
|
504
|
-
category: "driver-error",
|
|
505
|
-
suggestion: [
|
|
506
|
-
"Keyboard dismissal failed.",
|
|
507
|
-
'On Android, try `app.dismissKeyboard({ strategy: "back" })`.',
|
|
508
|
-
"On iOS, prefer tapping a visible Done / Close control or a non-input element."
|
|
509
|
-
].join("\n")
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
pattern: "backUntilVisible()",
|
|
513
|
-
category: "driver-error",
|
|
514
|
-
suggestion: [
|
|
515
|
-
"System back navigation failed before the target screen became visible.",
|
|
516
|
-
"If this route uses app-level navigation, tap the visible back / close control instead.",
|
|
517
|
-
"This is especially common on iOS where a system back button may not exist."
|
|
518
|
-
].join("\n")
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
pattern: "Input text failed",
|
|
522
|
-
category: "driver-error",
|
|
523
|
-
suggestion: [
|
|
524
|
-
"Text input failed at the driver layer.",
|
|
525
|
-
"Make sure the field is focused first, and retry with shorter input chunks if needed.",
|
|
526
|
-
"If the keyboard is in the way, dismiss it before continuing the flow."
|
|
527
|
-
].join("\n")
|
|
528
|
-
}
|
|
529
|
-
];
|
|
530
|
-
var tagOnlyRules = [
|
|
531
|
-
{
|
|
532
|
-
tag: "TimeoutError",
|
|
533
|
-
category: "timeout",
|
|
534
|
-
suggestion: [
|
|
535
|
-
"The operation took longer than the allowed timeout.",
|
|
536
|
-
"Try increasing `defaults.waitTimeout` in spana.config.ts,",
|
|
537
|
-
"or set a per-flow timeout: `flow('name', { timeout: 30000 }, ...)`."
|
|
538
|
-
].join("\n")
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
tag: ["ConfigError", "FlowSyntaxError"],
|
|
542
|
-
category: "config-error",
|
|
543
|
-
suggestion: "Run `spana validate-config` to check your configuration."
|
|
544
|
-
}
|
|
545
|
-
];
|
|
546
|
-
var heuristicRules = [
|
|
547
|
-
{
|
|
548
|
-
pattern: /[Tt]imed out/,
|
|
549
|
-
category: "timeout",
|
|
550
|
-
suggestion: "The operation timed out. Try increasing `defaults.waitTimeout` in spana.config.ts."
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
pattern: /not found|not visible/,
|
|
554
|
-
category: (msg) => categorizeElementFailure(msg),
|
|
555
|
-
suggestion: (_error, msg) => {
|
|
556
|
-
if (msg.includes("scroll(s) toward")) {
|
|
557
|
-
return "The target stayed off-screen while scrolling. Increase `maxScrolls` / `timeout`, or reverse the scroll search direction.";
|
|
558
|
-
}
|
|
559
|
-
const category = categorizeElementFailure(msg);
|
|
560
|
-
return elementSuggestion(category, "the target selector", void 0);
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
pattern: "dismissKeyboard()",
|
|
565
|
-
category: "driver-error",
|
|
566
|
-
suggestion: 'Keyboard dismissal failed. On Android try `app.dismissKeyboard({ strategy: "back" })`; on iOS prefer an explicit Done / Close control.'
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
pattern: /ECONNREFUSED|ECONNRESET|disconnected/,
|
|
570
|
-
category: "device-disconnected",
|
|
571
|
-
suggestion: "The connection was lost. Check the device or emulator/simulator is still running."
|
|
572
|
-
}
|
|
573
|
-
];
|
|
574
|
-
function matchesPattern(msg, pattern) {
|
|
575
|
-
return typeof pattern === "string" ? msg.includes(pattern) : pattern.test(msg);
|
|
576
|
-
}
|
|
577
|
-
function matchesTag(tag, rule) {
|
|
578
|
-
if (!rule.tag) return true;
|
|
579
|
-
if (Array.isArray(rule.tag)) return tag != null && rule.tag.includes(tag);
|
|
580
|
-
return tag === rule.tag;
|
|
581
|
-
}
|
|
582
|
-
function categorize(error) {
|
|
583
|
-
const tag = error[TAG_KEY];
|
|
584
|
-
const msg = error.message ?? "";
|
|
585
|
-
const dynamic = categorizeDynamic(error, tag, msg);
|
|
586
|
-
if (dynamic) return dynamic;
|
|
587
|
-
for (const rule of tagOnlyRules) {
|
|
588
|
-
if (matchesTag(tag, rule)) {
|
|
589
|
-
return {
|
|
590
|
-
category: typeof rule.category === "function" ? rule.category(msg) : rule.category,
|
|
591
|
-
suggestion: typeof rule.suggestion === "function" ? rule.suggestion(error, msg) : rule.suggestion
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
for (const rule of heuristicRules) {
|
|
596
|
-
if (rule.pattern && matchesPattern(msg, rule.pattern)) {
|
|
597
|
-
return {
|
|
598
|
-
category: typeof rule.category === "function" ? rule.category(msg) : rule.category,
|
|
599
|
-
suggestion: typeof rule.suggestion === "function" ? rule.suggestion(error, msg) : rule.suggestion
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return { category: "unknown" };
|
|
604
|
-
}
|
|
605
|
-
function classifyError(error) {
|
|
606
|
-
const tagged = error;
|
|
607
|
-
const { category, suggestion } = categorize(tagged);
|
|
608
|
-
return {
|
|
609
|
-
message: error.message,
|
|
610
|
-
stack: error.stack,
|
|
611
|
-
category,
|
|
612
|
-
suggestion
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// src/core/engine.ts
|
|
617
|
-
import { join as join3 } from "path";
|
|
618
|
-
|
|
619
|
-
// src/report/failure-bundle.ts
|
|
620
|
-
import { writeFileSync as writeFileSync2, readFileSync, existsSync } from "fs";
|
|
621
|
-
import { join as join2, basename } from "path";
|
|
622
|
-
function levenshtein(a, b) {
|
|
623
|
-
const m = a.length;
|
|
624
|
-
const n = b.length;
|
|
625
|
-
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
626
|
-
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
627
|
-
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
628
|
-
for (let i = 1; i <= m; i++) {
|
|
629
|
-
for (let j = 1; j <= n; j++) {
|
|
630
|
-
dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return dp[m][n];
|
|
634
|
-
}
|
|
635
|
-
function extractIdentifiers(hierarchyJson) {
|
|
636
|
-
const testIDs = [];
|
|
637
|
-
const texts = [];
|
|
638
|
-
try {
|
|
639
|
-
const root = JSON.parse(hierarchyJson);
|
|
640
|
-
const queue = [root];
|
|
641
|
-
while (queue.length > 0) {
|
|
642
|
-
const node = queue.pop();
|
|
643
|
-
if (!node || typeof node !== "object") continue;
|
|
644
|
-
if (node.testID && typeof node.testID === "string") testIDs.push(node.testID);
|
|
645
|
-
if (node.text && typeof node.text === "string") texts.push(node.text);
|
|
646
|
-
if (Array.isArray(node.children)) {
|
|
647
|
-
for (const child of node.children) queue.push(child);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
} catch {
|
|
651
|
-
}
|
|
652
|
-
return { testIDs, texts };
|
|
653
|
-
}
|
|
654
|
-
function findNearbySelectors(attempted, hierarchyJson) {
|
|
655
|
-
if (!hierarchyJson) return [];
|
|
656
|
-
const { testIDs, texts } = extractIdentifiers(hierarchyJson);
|
|
657
|
-
let target;
|
|
658
|
-
let candidates;
|
|
659
|
-
if (typeof attempted === "string") {
|
|
660
|
-
target = attempted.toLowerCase();
|
|
661
|
-
candidates = [...testIDs, ...texts];
|
|
662
|
-
} else if (attempted && typeof attempted === "object") {
|
|
663
|
-
const sel = attempted;
|
|
664
|
-
if (typeof sel.testID === "string") {
|
|
665
|
-
target = sel.testID.toLowerCase();
|
|
666
|
-
candidates = testIDs;
|
|
667
|
-
} else if (typeof sel.text === "string") {
|
|
668
|
-
target = sel.text.toLowerCase();
|
|
669
|
-
candidates = texts;
|
|
670
|
-
} else if (typeof sel.accessibilityLabel === "string") {
|
|
671
|
-
target = sel.accessibilityLabel.toLowerCase();
|
|
672
|
-
candidates = [...testIDs, ...texts];
|
|
673
|
-
} else {
|
|
674
|
-
return [];
|
|
675
|
-
}
|
|
676
|
-
} else {
|
|
677
|
-
return [];
|
|
678
|
-
}
|
|
679
|
-
const scored = candidates.filter((c) => c !== target).map((c) => {
|
|
680
|
-
const cl = c.toLowerCase();
|
|
681
|
-
const substringMatch = cl.includes(target) || target.includes(cl);
|
|
682
|
-
const dist = levenshtein(target, cl);
|
|
683
|
-
return { value: c, score: substringMatch ? 0 : dist };
|
|
684
|
-
}).filter((s) => s.score <= 5).toSorted((a, b) => a.score - b.score);
|
|
685
|
-
const seen = /* @__PURE__ */ new Set();
|
|
686
|
-
const results = [];
|
|
687
|
-
for (const s of scored) {
|
|
688
|
-
if (!seen.has(s.value)) {
|
|
689
|
-
seen.add(s.value);
|
|
690
|
-
results.push(s.value);
|
|
691
|
-
if (results.length >= 5) break;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return results;
|
|
695
|
-
}
|
|
696
|
-
function buildArtifactMap(attachments) {
|
|
697
|
-
const map = {};
|
|
698
|
-
if (!attachments) return map;
|
|
699
|
-
for (const att of attachments) {
|
|
700
|
-
const filename = basename(att.path);
|
|
701
|
-
if (filename === "screenshot.png") map.screenshot = filename;
|
|
702
|
-
else if (filename === "hierarchy.json") map.hierarchy = filename;
|
|
703
|
-
else if (filename === "console-logs.json") map.consoleLogs = filename;
|
|
704
|
-
else if (filename === "js-errors.json") map.jsErrors = filename;
|
|
705
|
-
else if (filename === "network.har") map.har = filename;
|
|
706
|
-
else if (filename === "driver-logs.txt") map.driverLogs = filename;
|
|
707
|
-
}
|
|
708
|
-
return map;
|
|
709
|
-
}
|
|
710
|
-
function createFailureBundle(flowName, platform, steps, error, artifactDir, attachments, flowPath) {
|
|
711
|
-
const failedStepIndex = steps.findLastIndex((s) => s.status === "failed");
|
|
712
|
-
const failedStep = failedStepIndex >= 0 ? {
|
|
713
|
-
index: failedStepIndex,
|
|
714
|
-
command: steps[failedStepIndex].command,
|
|
715
|
-
selector: steps[failedStepIndex].selector ?? null,
|
|
716
|
-
durationMs: steps[failedStepIndex].durationMs,
|
|
717
|
-
error: steps[failedStepIndex].error
|
|
718
|
-
} : null;
|
|
719
|
-
const lastPassedIndex = failedStepIndex > 0 ? steps.findLastIndex((s, i) => i < failedStepIndex && s.status === "passed") : -1;
|
|
720
|
-
const lastPassedStep = lastPassedIndex >= 0 ? {
|
|
721
|
-
index: lastPassedIndex,
|
|
722
|
-
command: steps[lastPassedIndex].command,
|
|
723
|
-
selector: steps[lastPassedIndex].selector ?? null,
|
|
724
|
-
durationMs: steps[lastPassedIndex].durationMs
|
|
725
|
-
} : null;
|
|
726
|
-
let selectorContext;
|
|
727
|
-
if (failedStep?.selector && (error.category === "element-not-found" || error.category === "element-not-visible")) {
|
|
728
|
-
const hierarchyPath = join2(artifactDir, "hierarchy.json");
|
|
729
|
-
let hierarchyJson = null;
|
|
730
|
-
if (existsSync(hierarchyPath)) {
|
|
731
|
-
try {
|
|
732
|
-
hierarchyJson = readFileSync(hierarchyPath, "utf-8");
|
|
733
|
-
} catch {
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
const nearbyAlternatives = findNearbySelectors(failedStep.selector, hierarchyJson);
|
|
737
|
-
selectorContext = {
|
|
738
|
-
attempted: failedStep.selector,
|
|
739
|
-
nearbyAlternatives
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
const flowFile = flowPath ?? `flows/${flowName.replaceAll(" ", "-")}.flow.ts`;
|
|
743
|
-
const reproCommand = `spana test ${flowFile} --platform ${platform} --grep '${flowName}'`;
|
|
744
|
-
const bundle = {
|
|
745
|
-
schemaVersion: 1,
|
|
746
|
-
flow: flowName,
|
|
747
|
-
platform,
|
|
748
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
749
|
-
failedStep,
|
|
750
|
-
lastPassedStep,
|
|
751
|
-
error: {
|
|
752
|
-
message: error.message,
|
|
753
|
-
category: error.category,
|
|
754
|
-
suggestion: error.suggestion,
|
|
755
|
-
errorCode: error.errorCode
|
|
756
|
-
},
|
|
757
|
-
selectorContext,
|
|
758
|
-
artifacts: buildArtifactMap(attachments),
|
|
759
|
-
reproCommand,
|
|
760
|
-
durationMs: steps.reduce((sum, s) => sum + s.durationMs, 0)
|
|
761
|
-
};
|
|
762
|
-
return bundle;
|
|
763
|
-
}
|
|
764
|
-
function writeFailureBundle(bundle, artifactDir) {
|
|
765
|
-
const path = join2(artifactDir, "failure-bundle.json");
|
|
766
|
-
writeFileSync2(path, JSON.stringify(bundle, null, 2), "utf-8");
|
|
767
|
-
return path;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// src/core/engine.ts
|
|
771
|
-
async function executeFlow(flow, driver, config) {
|
|
772
|
-
const start2 = Date.now();
|
|
773
|
-
const { platform, coordinatorConfig, appId } = config;
|
|
774
|
-
const autoLaunch = flow.config.autoLaunch ?? config.autoLaunch ?? true;
|
|
775
|
-
const timeout = flow.config.timeout ?? config.flowTimeout ?? 6e4;
|
|
776
|
-
const artifactConfig = resolveArtifactConfig(config.artifactConfig, flow.config.artifacts);
|
|
777
|
-
const stepRecorder = createStepRecorder(driver, artifactConfig, flow.name, platform);
|
|
778
|
-
const launchOptions = mergeLaunchOptions(config.launchOptions, flow.config.launchOptions);
|
|
779
|
-
const flowDefaults = flow.config.defaults;
|
|
780
|
-
const mergedCoordinatorConfig = flowDefaults ? {
|
|
781
|
-
...coordinatorConfig,
|
|
782
|
-
defaults: {
|
|
783
|
-
...coordinatorConfig.defaults,
|
|
784
|
-
timeout: flowDefaults.waitTimeout ?? coordinatorConfig.defaults?.timeout,
|
|
785
|
-
pollInterval: flowDefaults.pollInterval ?? coordinatorConfig.defaults?.pollInterval,
|
|
786
|
-
settleTimeout: flowDefaults.settleTimeout ?? coordinatorConfig.defaults?.settleTimeout,
|
|
787
|
-
initialPollInterval: flowDefaults.initialPollInterval ?? coordinatorConfig.defaults?.initialPollInterval
|
|
788
|
-
},
|
|
789
|
-
waitForIdleTimeout: flowDefaults.waitForIdleTimeout ?? coordinatorConfig.waitForIdleTimeout,
|
|
790
|
-
typingDelay: flowDefaults.typingDelay ?? coordinatorConfig.typingDelay,
|
|
791
|
-
hierarchyCacheTtl: flowDefaults.hierarchyCacheTtl ?? coordinatorConfig.hierarchyCacheTtl
|
|
792
|
-
} : coordinatorConfig;
|
|
793
|
-
const app = createPromiseApp(driver, appId, mergedCoordinatorConfig, stepRecorder, {
|
|
794
|
-
platform,
|
|
795
|
-
storybook: config.storybook,
|
|
796
|
-
launchOptions
|
|
797
|
-
});
|
|
798
|
-
const flowMeta = {
|
|
799
|
-
flowFilePath: flow.sourcePath ?? "",
|
|
800
|
-
flowName: flow.name,
|
|
801
|
-
platform,
|
|
802
|
-
updateBaselines: config.updateBaselines ?? false
|
|
803
|
-
};
|
|
804
|
-
const expect = createPromiseExpect(
|
|
805
|
-
driver,
|
|
806
|
-
mergedCoordinatorConfig,
|
|
807
|
-
stepRecorder,
|
|
808
|
-
flowMeta,
|
|
809
|
-
config.visualRegression
|
|
810
|
-
);
|
|
811
|
-
const flowCtx = { app, expect, platform, updateBaselines: flowMeta.updateBaselines };
|
|
812
|
-
const sessionManager = new SessionManager();
|
|
813
|
-
const sessions = createSessions(
|
|
814
|
-
sessionManager,
|
|
815
|
-
async (opts) => {
|
|
816
|
-
const pwDriver = await Effect3.runPromise(
|
|
817
|
-
makePlaywrightDriver({
|
|
818
|
-
browser: opts.browser,
|
|
819
|
-
headless: opts.headless ?? true,
|
|
820
|
-
baseUrl: opts.baseUrl,
|
|
821
|
-
storageState: opts.storageState,
|
|
822
|
-
verboseLogging: opts.verboseLogging
|
|
823
|
-
})
|
|
824
|
-
);
|
|
825
|
-
return pwDriver;
|
|
826
|
-
},
|
|
827
|
-
{ parse: (raw) => parseWebHierarchy(raw) }
|
|
828
|
-
);
|
|
829
|
-
flowCtx.sessions = sessions;
|
|
830
|
-
const buildFailureResult = async (error) => {
|
|
831
|
-
const attachments = await captureArtifacts(
|
|
832
|
-
driver,
|
|
833
|
-
artifactConfig,
|
|
834
|
-
flow.name,
|
|
835
|
-
platform,
|
|
836
|
-
"failed"
|
|
837
|
-
);
|
|
838
|
-
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
839
|
-
return {
|
|
840
|
-
name: flow.name,
|
|
841
|
-
platform,
|
|
842
|
-
status: "failed",
|
|
843
|
-
durationMs: Date.now() - start2,
|
|
844
|
-
error: classifyError(normalized),
|
|
845
|
-
attachments,
|
|
846
|
-
steps: stepRecorder.getSteps(),
|
|
847
|
-
scenarioSteps: flowCtx.__scenarioSteps
|
|
848
|
-
};
|
|
849
|
-
};
|
|
850
|
-
if (driver.beginFlow) {
|
|
851
|
-
try {
|
|
852
|
-
await Effect3.runPromise(driver.beginFlow(flow.name));
|
|
853
|
-
} catch (error) {
|
|
854
|
-
return buildFailureResult(error);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
if (config.hooks?.beforeEach) {
|
|
858
|
-
try {
|
|
859
|
-
await config.hooks.beforeEach({ app, platform });
|
|
860
|
-
} catch (error) {
|
|
861
|
-
return buildFailureResult(error);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
let result;
|
|
865
|
-
try {
|
|
866
|
-
if (autoLaunch) {
|
|
867
|
-
await app.launch();
|
|
868
|
-
}
|
|
869
|
-
await Promise.race([
|
|
870
|
-
flow.fn(flowCtx),
|
|
871
|
-
new Promise(
|
|
872
|
-
(_, reject) => setTimeout(
|
|
873
|
-
() => reject(new Error(`Flow "${flow.name}" timed out after ${timeout}ms`)),
|
|
874
|
-
timeout
|
|
875
|
-
)
|
|
876
|
-
)
|
|
877
|
-
]);
|
|
878
|
-
const attachments = await captureArtifacts(
|
|
879
|
-
driver,
|
|
880
|
-
artifactConfig,
|
|
881
|
-
flow.name,
|
|
882
|
-
platform,
|
|
883
|
-
"passed"
|
|
884
|
-
);
|
|
885
|
-
result = {
|
|
886
|
-
name: flow.name,
|
|
887
|
-
platform,
|
|
888
|
-
status: "passed",
|
|
889
|
-
durationMs: Date.now() - start2,
|
|
890
|
-
attachments,
|
|
891
|
-
steps: stepRecorder.getSteps(),
|
|
892
|
-
scenarioSteps: flowCtx.__scenarioSteps
|
|
893
|
-
};
|
|
894
|
-
} catch (error) {
|
|
895
|
-
const attachments = await captureArtifacts(
|
|
896
|
-
driver,
|
|
897
|
-
artifactConfig,
|
|
898
|
-
flow.name,
|
|
899
|
-
platform,
|
|
900
|
-
"failed"
|
|
901
|
-
);
|
|
902
|
-
const flowError = error instanceof Error ? error : new Error(String(error));
|
|
903
|
-
result = {
|
|
904
|
-
name: flow.name,
|
|
905
|
-
platform,
|
|
906
|
-
status: "failed",
|
|
907
|
-
durationMs: Date.now() - start2,
|
|
908
|
-
error: classifyError(flowError),
|
|
909
|
-
attachments,
|
|
910
|
-
steps: stepRecorder.getSteps(),
|
|
911
|
-
scenarioSteps: flowCtx.__scenarioSteps
|
|
912
|
-
};
|
|
913
|
-
if (artifactConfig.captureOnFailure && result.error) {
|
|
914
|
-
try {
|
|
915
|
-
const artDir = join3(
|
|
916
|
-
artifactConfig.outputDir,
|
|
917
|
-
`${flow.name.replaceAll(/[^a-zA-Z0-9-_]/g, "_").replaceAll(/_+/g, "_").slice(0, 80) || "artifact"}-${platform}`
|
|
918
|
-
);
|
|
919
|
-
const bundle = createFailureBundle(
|
|
920
|
-
flow.name,
|
|
921
|
-
platform,
|
|
922
|
-
stepRecorder.getSteps(),
|
|
923
|
-
result.error,
|
|
924
|
-
artDir,
|
|
925
|
-
attachments
|
|
926
|
-
);
|
|
927
|
-
writeFailureBundle(bundle, artDir);
|
|
928
|
-
} catch {
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
if (config.debugOnFailure) {
|
|
932
|
-
await runDebugReplOnce({
|
|
933
|
-
app,
|
|
934
|
-
expect,
|
|
935
|
-
driver,
|
|
936
|
-
error: flowError,
|
|
937
|
-
flowName: flow.name,
|
|
938
|
-
platform,
|
|
939
|
-
parseHierarchy: coordinatorConfig.parse
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
try {
|
|
944
|
-
await sessionManager.disconnectAll();
|
|
945
|
-
} catch {
|
|
946
|
-
}
|
|
947
|
-
if (config.hooks?.afterEach) {
|
|
948
|
-
try {
|
|
949
|
-
await config.hooks.afterEach({ app, platform, result });
|
|
950
|
-
} catch (hookError) {
|
|
951
|
-
console.warn(
|
|
952
|
-
`afterEach hook failed: ${hookError instanceof Error ? hookError.message : hookError}`
|
|
953
|
-
);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return result;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
// src/core/parallel.ts
|
|
960
|
-
async function runParallel(config) {
|
|
961
|
-
const { workers, flows, onFlowComplete, onFlowStart, retries = 0, retryDelay = 0, bail } = config;
|
|
962
|
-
const start2 = Date.now();
|
|
963
|
-
const results = [];
|
|
964
|
-
let nextFlowIndex = 0;
|
|
965
|
-
let failureCount = 0;
|
|
966
|
-
let bailedOut = false;
|
|
967
|
-
const workerPromises = workers.map(async (worker) => {
|
|
968
|
-
const stats = { flowCount: 0, totalMs: 0 };
|
|
969
|
-
while (true) {
|
|
970
|
-
if (bail !== void 0 && failureCount >= bail) break;
|
|
971
|
-
const flowIdx = nextFlowIndex++;
|
|
972
|
-
if (flowIdx >= flows.length) break;
|
|
973
|
-
const flow = flows[flowIdx];
|
|
974
|
-
let result;
|
|
975
|
-
let attempts = 0;
|
|
976
|
-
onFlowStart?.(flow.name, worker.name);
|
|
977
|
-
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
978
|
-
if (attempt > 0 && retryDelay > 0) {
|
|
979
|
-
await new Promise((resolve4) => setTimeout(resolve4, retryDelay));
|
|
980
|
-
}
|
|
981
|
-
result = await executeFlow(flow, worker.driver, worker.engineConfig);
|
|
982
|
-
attempts++;
|
|
983
|
-
if (result.status === "passed") break;
|
|
984
|
-
}
|
|
985
|
-
if (result.status === "passed" && attempts > 1) {
|
|
986
|
-
result.flaky = true;
|
|
987
|
-
}
|
|
988
|
-
result.attempts = attempts;
|
|
989
|
-
results.push(result);
|
|
990
|
-
stats.flowCount++;
|
|
991
|
-
stats.totalMs += result.durationMs;
|
|
992
|
-
if (result.status === "failed") {
|
|
993
|
-
failureCount++;
|
|
994
|
-
}
|
|
995
|
-
onFlowComplete?.(result, worker.name);
|
|
996
|
-
}
|
|
997
|
-
return { workerId: worker.id, stats };
|
|
998
|
-
});
|
|
999
|
-
const workerResults = await Promise.all(workerPromises);
|
|
1000
|
-
if (bail !== void 0 && failureCount >= bail) {
|
|
1001
|
-
bailedOut = true;
|
|
1002
|
-
while (nextFlowIndex < flows.length) {
|
|
1003
|
-
const flow = flows[nextFlowIndex++];
|
|
1004
|
-
results.push({
|
|
1005
|
-
name: flow.name,
|
|
1006
|
-
platform: workers[0].engineConfig.platform,
|
|
1007
|
-
status: "skipped",
|
|
1008
|
-
durationMs: 0,
|
|
1009
|
-
attempts: 0
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
const workerStats = /* @__PURE__ */ new Map();
|
|
1014
|
-
for (const wr of workerResults) {
|
|
1015
|
-
workerStats.set(wr.workerId, wr.stats);
|
|
1016
|
-
}
|
|
1017
|
-
return {
|
|
1018
|
-
results,
|
|
1019
|
-
totalDurationMs: Date.now() - start2,
|
|
1020
|
-
passed: results.filter((r) => r.status === "passed").length,
|
|
1021
|
-
failed: results.filter((r) => r.status === "failed").length,
|
|
1022
|
-
skipped: results.filter((r) => r.status === "skipped").length,
|
|
1023
|
-
flaky: results.filter((r) => r.flaky === true).length,
|
|
1024
|
-
bailedOut: bailedOut || void 0,
|
|
1025
|
-
workerStats
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
54
|
// src/core/orchestrator.ts
|
|
1030
55
|
async function sleep(ms) {
|
|
1031
56
|
if (ms <= 0) return;
|
|
@@ -1080,6 +105,7 @@ async function runPlatform(flows, platformConfig, options, shouldBail, noteFailu
|
|
|
1080
105
|
retries: options?.retries ?? 0,
|
|
1081
106
|
retryDelay: options?.retryDelay ?? 0,
|
|
1082
107
|
bail: options?.bail,
|
|
108
|
+
durationHintsMs: options?.durationHintsMs,
|
|
1083
109
|
onFlowStart: (name, workerName) => {
|
|
1084
110
|
options?.onFlowStart?.(name, platform, workerName);
|
|
1085
111
|
},
|
|
@@ -1149,7 +175,7 @@ async function runPlatform(flows, platformConfig, options, shouldBail, noteFailu
|
|
|
1149
175
|
return { results };
|
|
1150
176
|
}
|
|
1151
177
|
async function orchestrate(flows, platforms, options) {
|
|
1152
|
-
const
|
|
178
|
+
const start = Date.now();
|
|
1153
179
|
const bail = options?.bail;
|
|
1154
180
|
let failureCount = 0;
|
|
1155
181
|
let bailedOut = false;
|
|
@@ -1186,7 +212,7 @@ async function orchestrate(flows, platforms, options) {
|
|
|
1186
212
|
}
|
|
1187
213
|
return {
|
|
1188
214
|
results: allResults,
|
|
1189
|
-
totalDurationMs: Date.now() -
|
|
215
|
+
totalDurationMs: Date.now() - start,
|
|
1190
216
|
passed: allResults.filter((r) => r.status === "passed").length,
|
|
1191
217
|
failed: allResults.filter((r) => r.status === "failed").length,
|
|
1192
218
|
skipped: allResults.filter((r) => r.status === "skipped").length,
|
|
@@ -1221,258 +247,8 @@ async function resolveCapabilities(config, opts) {
|
|
|
1221
247
|
return { ...launchDeviceCaps, ...configCaps, ...platformCaps, ...fileCaps, ...cliCaps };
|
|
1222
248
|
}
|
|
1223
249
|
|
|
1224
|
-
// src/runtime/local.ts
|
|
1225
|
-
import { Effect as Effect4 } from "effect";
|
|
1226
|
-
async function safeCleanup(...fns) {
|
|
1227
|
-
for (const fn of fns) {
|
|
1228
|
-
try {
|
|
1229
|
-
await fn();
|
|
1230
|
-
} catch {
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
function buildEngineConfig(appId, platform, parseFn, config, screenSize) {
|
|
1235
|
-
return {
|
|
1236
|
-
appId,
|
|
1237
|
-
platform,
|
|
1238
|
-
coordinatorConfig: {
|
|
1239
|
-
parse: parseFn,
|
|
1240
|
-
defaults: {
|
|
1241
|
-
timeout: config.defaults?.waitTimeout,
|
|
1242
|
-
pollInterval: config.defaults?.pollInterval,
|
|
1243
|
-
settleTimeout: config.defaults?.settleTimeout,
|
|
1244
|
-
initialPollInterval: config.defaults?.initialPollInterval
|
|
1245
|
-
},
|
|
1246
|
-
waitForIdleTimeout: config.defaults?.waitForIdleTimeout,
|
|
1247
|
-
typingDelay: config.defaults?.typingDelay,
|
|
1248
|
-
hierarchyCacheTtl: config.defaults?.hierarchyCacheTtl,
|
|
1249
|
-
screenWidth: screenSize?.width,
|
|
1250
|
-
screenHeight: screenSize?.height
|
|
1251
|
-
},
|
|
1252
|
-
autoLaunch: true,
|
|
1253
|
-
flowTimeout: config.defaults?.waitTimeout ? config.defaults.waitTimeout * 10 : 6e4,
|
|
1254
|
-
artifactConfig: config.artifacts,
|
|
1255
|
-
launchOptions: config.launchOptions,
|
|
1256
|
-
hooks: config.hooks,
|
|
1257
|
-
storybook: platform === "web" ? config.execution?.web?.storybook : void 0,
|
|
1258
|
-
visualRegression: config.visualRegression
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
async function buildWebRuntime(config) {
|
|
1262
|
-
const webUrl = config.apps?.web?.url ?? "http://localhost:3000";
|
|
1263
|
-
const webExecution = config.execution?.web;
|
|
1264
|
-
const driver = await Effect4.runPromise(
|
|
1265
|
-
makePlaywrightDriver({
|
|
1266
|
-
browser: webExecution?.browser,
|
|
1267
|
-
headless: webExecution?.headless ?? true,
|
|
1268
|
-
baseUrl: webUrl,
|
|
1269
|
-
storageState: webExecution?.storageState,
|
|
1270
|
-
verboseLogging: webExecution?.verboseLogging
|
|
1271
|
-
})
|
|
1272
|
-
);
|
|
1273
|
-
const deviceInfo = await Effect4.runPromise(driver.getDeviceInfo());
|
|
1274
|
-
return {
|
|
1275
|
-
runtime: {
|
|
1276
|
-
driver,
|
|
1277
|
-
cleanup: () => safeCleanup(() => Effect4.runPromise(driver.killApp(""))),
|
|
1278
|
-
metadata: {
|
|
1279
|
-
platform: "web",
|
|
1280
|
-
mode: "local"
|
|
1281
|
-
}
|
|
1282
|
-
},
|
|
1283
|
-
engineConfig: buildEngineConfig(webUrl, "web", parseWebHierarchy, config, {
|
|
1284
|
-
width: deviceInfo.screenWidth,
|
|
1285
|
-
height: deviceInfo.screenHeight
|
|
1286
|
-
})
|
|
1287
|
-
};
|
|
1288
|
-
}
|
|
1289
|
-
async function buildLocalAndroidRuntime(config, targetDevice, resolveFromConfig) {
|
|
1290
|
-
const device = targetDevice?.platform === "android" ? {
|
|
1291
|
-
serial: targetDevice.id,
|
|
1292
|
-
state: "device",
|
|
1293
|
-
type: targetDevice.type
|
|
1294
|
-
} : ensureAndroidDevice();
|
|
1295
|
-
if (!device) {
|
|
1296
|
-
console.log("No Android device/emulator available. Skipping android platform.");
|
|
1297
|
-
return null;
|
|
1298
|
-
}
|
|
1299
|
-
const packageName = config.apps?.android?.packageName ?? "";
|
|
1300
|
-
const androidAppPath = config.apps?.android?.appPath;
|
|
1301
|
-
if (androidAppPath && packageName) {
|
|
1302
|
-
try {
|
|
1303
|
-
const { adbShell, adbInstall } = await import("./android-GFW6OXPQ.js");
|
|
1304
|
-
const output = adbShell(device.serial, `pm list packages ${packageName}`);
|
|
1305
|
-
if (!output.includes(packageName)) {
|
|
1306
|
-
console.log(`Installing ${packageName} on Android device...`);
|
|
1307
|
-
adbInstall(device.serial, resolveFromConfig(androidAppPath));
|
|
1308
|
-
}
|
|
1309
|
-
} catch {
|
|
1310
|
-
console.log(`Installing ${packageName} on Android device...`);
|
|
1311
|
-
const { adbInstall } = await import("./android-GFW6OXPQ.js");
|
|
1312
|
-
adbInstall(device.serial, resolveFromConfig(androidAppPath));
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
const hostPort = allocatePort(8200);
|
|
1316
|
-
try {
|
|
1317
|
-
const conn = await setupUiAutomator2(device.serial, hostPort);
|
|
1318
|
-
const driver = await Effect4.runPromise(
|
|
1319
|
-
createUiAutomator2Driver(conn.host, conn.port, device.serial, packageName)
|
|
1320
|
-
);
|
|
1321
|
-
const deviceInfo = await Effect4.runPromise(driver.getDeviceInfo());
|
|
1322
|
-
return {
|
|
1323
|
-
runtime: {
|
|
1324
|
-
driver,
|
|
1325
|
-
cleanup: () => safeCleanup(
|
|
1326
|
-
() => Effect4.runPromise(driver.killApp("")),
|
|
1327
|
-
() => conn.cleanup?.() ?? Promise.resolve()
|
|
1328
|
-
),
|
|
1329
|
-
metadata: {
|
|
1330
|
-
platform: "android",
|
|
1331
|
-
mode: "local",
|
|
1332
|
-
deviceId: device.serial
|
|
1333
|
-
}
|
|
1334
|
-
},
|
|
1335
|
-
engineConfig: buildEngineConfig(packageName, "android", parseAndroidHierarchy, config, {
|
|
1336
|
-
width: deviceInfo.screenWidth,
|
|
1337
|
-
height: deviceInfo.screenHeight
|
|
1338
|
-
})
|
|
1339
|
-
};
|
|
1340
|
-
} catch (e) {
|
|
1341
|
-
console.log(`Android setup failed on ${device.serial}: ${e instanceof Error ? e.message : e}`);
|
|
1342
|
-
return null;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
async function buildLocalIOSRuntime(config, targetDevice, resolveFromConfig) {
|
|
1346
|
-
const bundleId = config.apps?.ios?.bundleId ?? "";
|
|
1347
|
-
const iosAppPath = config.apps?.ios?.appPath;
|
|
1348
|
-
const signing = config.apps?.ios?.signing;
|
|
1349
|
-
const snapshotMaxDepth = config.defaults?.snapshotMaxDepth ?? 100;
|
|
1350
|
-
const createIOSRuntime = async (deviceId, conn, simulatorUdid) => {
|
|
1351
|
-
const driver = await Effect4.runPromise(
|
|
1352
|
-
createWDADriver(conn.host, conn.port, bundleId, simulatorUdid, snapshotMaxDepth)
|
|
1353
|
-
);
|
|
1354
|
-
const deviceInfo = await Effect4.runPromise(driver.getDeviceInfo());
|
|
1355
|
-
return {
|
|
1356
|
-
runtime: {
|
|
1357
|
-
driver,
|
|
1358
|
-
cleanup: () => safeCleanup(
|
|
1359
|
-
() => Effect4.runPromise(driver.killApp("")),
|
|
1360
|
-
() => conn.cleanup?.() ?? Promise.resolve()
|
|
1361
|
-
),
|
|
1362
|
-
metadata: {
|
|
1363
|
-
platform: "ios",
|
|
1364
|
-
mode: "local",
|
|
1365
|
-
deviceId
|
|
1366
|
-
}
|
|
1367
|
-
},
|
|
1368
|
-
engineConfig: buildEngineConfig(bundleId, "ios", parseIOSHierarchy, config, {
|
|
1369
|
-
width: deviceInfo.screenWidth,
|
|
1370
|
-
height: deviceInfo.screenHeight
|
|
1371
|
-
})
|
|
1372
|
-
};
|
|
1373
|
-
};
|
|
1374
|
-
const connectPhysicalRuntime = async (physicalDevice2, allowSimulatorFallback) => {
|
|
1375
|
-
let conn;
|
|
1376
|
-
try {
|
|
1377
|
-
console.log(`Found physical iOS device: ${physicalDevice2.name} (${physicalDevice2.udid})`);
|
|
1378
|
-
if (iosAppPath && bundleId) {
|
|
1379
|
-
ensureAppInstalled({
|
|
1380
|
-
udid: physicalDevice2.udid,
|
|
1381
|
-
bundleId,
|
|
1382
|
-
appPath: resolveFromConfig(iosAppPath),
|
|
1383
|
-
isPhysicalDevice: true
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
if (signing?.teamId) {
|
|
1387
|
-
const { setupWDAForDevice } = await import("./installer-PVBSX7UC.js");
|
|
1388
|
-
const wdaPort2 = allocatePort(8100);
|
|
1389
|
-
conn = await setupWDAForDevice(
|
|
1390
|
-
physicalDevice2.udid,
|
|
1391
|
-
wdaPort2,
|
|
1392
|
-
signing.teamId,
|
|
1393
|
-
signing.signingIdentity
|
|
1394
|
-
);
|
|
1395
|
-
} else {
|
|
1396
|
-
conn = connectPhysicalDevice(physicalDevice2.udid);
|
|
1397
|
-
}
|
|
1398
|
-
return await createIOSRuntime(physicalDevice2.udid, conn);
|
|
1399
|
-
} catch (e) {
|
|
1400
|
-
if (conn?.cleanup) {
|
|
1401
|
-
try {
|
|
1402
|
-
await conn.cleanup();
|
|
1403
|
-
} catch (cleanupError) {
|
|
1404
|
-
console.warn(
|
|
1405
|
-
`Failed to clean up physical device tunnel: ${cleanupError instanceof Error ? cleanupError.message : cleanupError}`
|
|
1406
|
-
);
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
if (!allowSimulatorFallback) {
|
|
1410
|
-
console.log(
|
|
1411
|
-
`iOS setup failed for device ${physicalDevice2.udid}: ${e instanceof Error ? e.message : e}`
|
|
1412
|
-
);
|
|
1413
|
-
return null;
|
|
1414
|
-
}
|
|
1415
|
-
console.log(
|
|
1416
|
-
`Physical device setup failed (${physicalDevice2.name}): ${e instanceof Error ? e.message : e}. Falling back to simulator.`
|
|
1417
|
-
);
|
|
1418
|
-
return null;
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
if (targetDevice?.platform === "ios" && targetDevice.type === "simulator") {
|
|
1422
|
-
if (iosAppPath && bundleId) {
|
|
1423
|
-
ensureAppInstalled({
|
|
1424
|
-
udid: targetDevice.id,
|
|
1425
|
-
bundleId,
|
|
1426
|
-
appPath: resolveFromConfig(iosAppPath),
|
|
1427
|
-
isPhysicalDevice: false
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
const wdaPort2 = allocatePort(8100);
|
|
1431
|
-
try {
|
|
1432
|
-
const conn = await setupWDA(targetDevice.id, wdaPort2);
|
|
1433
|
-
return await createIOSRuntime(targetDevice.id, conn, targetDevice.id);
|
|
1434
|
-
} catch (e) {
|
|
1435
|
-
console.log(
|
|
1436
|
-
`iOS setup failed for device ${targetDevice.id}: ${e instanceof Error ? e.message : e}`
|
|
1437
|
-
);
|
|
1438
|
-
return null;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
if (targetDevice?.platform === "ios" && targetDevice.type === "device") {
|
|
1442
|
-
return connectPhysicalRuntime({ udid: targetDevice.id, name: targetDevice.name }, false);
|
|
1443
|
-
}
|
|
1444
|
-
const physicalDevice = firstIOSPhysicalDevice();
|
|
1445
|
-
if (physicalDevice) {
|
|
1446
|
-
const runtime = await connectPhysicalRuntime(physicalDevice, true);
|
|
1447
|
-
if (runtime) {
|
|
1448
|
-
return runtime;
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
const simulator = ensureIOSSimulator(bundleId);
|
|
1452
|
-
if (!simulator) {
|
|
1453
|
-
console.log("No iOS simulator or physical device available. Skipping ios platform.");
|
|
1454
|
-
return null;
|
|
1455
|
-
}
|
|
1456
|
-
if (iosAppPath && bundleId) {
|
|
1457
|
-
ensureAppInstalled({
|
|
1458
|
-
udid: simulator.udid,
|
|
1459
|
-
bundleId,
|
|
1460
|
-
appPath: resolveFromConfig(iosAppPath),
|
|
1461
|
-
isPhysicalDevice: false
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
const wdaPort = allocatePort(8100);
|
|
1465
|
-
try {
|
|
1466
|
-
const conn = await setupWDA(simulator.udid, wdaPort);
|
|
1467
|
-
return await createIOSRuntime(simulator.udid, conn, simulator.udid);
|
|
1468
|
-
} catch (e) {
|
|
1469
|
-
console.log(`iOS setup failed on ${simulator.name}: ${e instanceof Error ? e.message : e}`);
|
|
1470
|
-
return null;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
250
|
// src/runtime/appium.ts
|
|
1475
|
-
import { Effect as
|
|
251
|
+
import { Effect as Effect3 } from "effect";
|
|
1476
252
|
|
|
1477
253
|
// src/drivers/appium/client.ts
|
|
1478
254
|
var AppiumClient = class {
|
|
@@ -1602,7 +378,7 @@ var AppiumClient = class {
|
|
|
1602
378
|
};
|
|
1603
379
|
|
|
1604
380
|
// src/drivers/appium/android.ts
|
|
1605
|
-
import { Effect
|
|
381
|
+
import { Effect } from "effect";
|
|
1606
382
|
|
|
1607
383
|
// src/drivers/appium/window-size.ts
|
|
1608
384
|
async function getAppiumWindowSize(client) {
|
|
@@ -1624,14 +400,14 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1624
400
|
// -----------------------------------------------------------------------
|
|
1625
401
|
// Hierarchy
|
|
1626
402
|
// -----------------------------------------------------------------------
|
|
1627
|
-
dumpHierarchy: () =>
|
|
403
|
+
dumpHierarchy: () => Effect.tryPromise({
|
|
1628
404
|
try: () => client.request("GET", client.sessionPath("/source")),
|
|
1629
405
|
catch: (e) => new DriverError({ message: `Failed to get page source: ${e}` })
|
|
1630
406
|
}),
|
|
1631
407
|
// -----------------------------------------------------------------------
|
|
1632
408
|
// Coordinate-level actions
|
|
1633
409
|
// -----------------------------------------------------------------------
|
|
1634
|
-
tapAtCoordinate: (x, y) =>
|
|
410
|
+
tapAtCoordinate: (x, y) => Effect.tryPromise({
|
|
1635
411
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1636
412
|
actions: [
|
|
1637
413
|
{
|
|
@@ -1648,7 +424,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1648
424
|
}),
|
|
1649
425
|
catch: (e) => new DriverError({ message: `Tap failed: ${e}` })
|
|
1650
426
|
}),
|
|
1651
|
-
doubleTapAtCoordinate: (x, y) =>
|
|
427
|
+
doubleTapAtCoordinate: (x, y) => Effect.tryPromise({
|
|
1652
428
|
try: async () => {
|
|
1653
429
|
const tapSequence = [
|
|
1654
430
|
{
|
|
@@ -1668,7 +444,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1668
444
|
},
|
|
1669
445
|
catch: (e) => new DriverError({ message: `Double tap failed: ${e}` })
|
|
1670
446
|
}),
|
|
1671
|
-
longPressAtCoordinate: (x, y, duration) =>
|
|
447
|
+
longPressAtCoordinate: (x, y, duration) => Effect.tryPromise({
|
|
1672
448
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1673
449
|
actions: [
|
|
1674
450
|
{
|
|
@@ -1686,7 +462,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1686
462
|
}),
|
|
1687
463
|
catch: (e) => new DriverError({ message: `Long press failed: ${e}` })
|
|
1688
464
|
}),
|
|
1689
|
-
swipe: (sx, sy, ex, ey, dur) =>
|
|
465
|
+
swipe: (sx, sy, ex, ey, dur) => Effect.tryPromise({
|
|
1690
466
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1691
467
|
actions: [
|
|
1692
468
|
{
|
|
@@ -1707,7 +483,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1707
483
|
// -----------------------------------------------------------------------
|
|
1708
484
|
// Text input
|
|
1709
485
|
// -----------------------------------------------------------------------
|
|
1710
|
-
inputText: (text) =>
|
|
486
|
+
inputText: (text) => Effect.tryPromise({
|
|
1711
487
|
try: () => {
|
|
1712
488
|
const keyActions = [];
|
|
1713
489
|
for (const segment of splitGraphemes(text)) {
|
|
@@ -1726,27 +502,27 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1726
502
|
},
|
|
1727
503
|
catch: (e) => new DriverError({ message: `Input text failed: ${e}` })
|
|
1728
504
|
}),
|
|
1729
|
-
pressKey: (key) =>
|
|
505
|
+
pressKey: (key) => Effect.tryPromise({
|
|
1730
506
|
try: () => client.request("POST", client.sessionPath("/appium/device/press_keycode"), {
|
|
1731
507
|
keycode: parseInt(key, 10) || 0
|
|
1732
508
|
}),
|
|
1733
509
|
catch: (e) => new DriverError({ message: `Press key failed: ${e}` })
|
|
1734
510
|
}),
|
|
1735
|
-
hideKeyboard: () =>
|
|
511
|
+
hideKeyboard: () => Effect.tryPromise({
|
|
1736
512
|
try: () => client.request("POST", client.sessionPath("/appium/device/hide_keyboard")),
|
|
1737
513
|
catch: (e) => new DriverError({ message: `Hide keyboard failed: ${e}` })
|
|
1738
514
|
}),
|
|
1739
515
|
// -----------------------------------------------------------------------
|
|
1740
516
|
// Queries
|
|
1741
517
|
// -----------------------------------------------------------------------
|
|
1742
|
-
takeScreenshot: () =>
|
|
518
|
+
takeScreenshot: () => Effect.tryPromise({
|
|
1743
519
|
try: async () => {
|
|
1744
520
|
const base64 = await client.request("GET", client.sessionPath("/screenshot"));
|
|
1745
521
|
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
1746
522
|
},
|
|
1747
523
|
catch: (e) => new DriverError({ message: `Screenshot failed: ${e}` })
|
|
1748
524
|
}),
|
|
1749
|
-
getDeviceInfo: () =>
|
|
525
|
+
getDeviceInfo: () => Effect.tryPromise({
|
|
1750
526
|
try: async () => {
|
|
1751
527
|
const size = await getAppiumWindowSize(client);
|
|
1752
528
|
const caps = client.getSessionCaps();
|
|
@@ -1765,7 +541,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1765
541
|
// -----------------------------------------------------------------------
|
|
1766
542
|
// App lifecycle
|
|
1767
543
|
// -----------------------------------------------------------------------
|
|
1768
|
-
launchApp: (bundleId, opts) =>
|
|
544
|
+
launchApp: (bundleId, opts) => Effect.tryPromise({
|
|
1769
545
|
try: async () => {
|
|
1770
546
|
if (opts?.clearState) {
|
|
1771
547
|
try {
|
|
@@ -1801,19 +577,19 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1801
577
|
},
|
|
1802
578
|
catch: (e) => new DriverError({ message: `Launch app failed: ${e}` })
|
|
1803
579
|
}),
|
|
1804
|
-
stopApp: (bundleId) =>
|
|
580
|
+
stopApp: (bundleId) => Effect.tryPromise({
|
|
1805
581
|
try: () => client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
1806
582
|
appId: bundleId
|
|
1807
583
|
}),
|
|
1808
584
|
catch: (e) => new DriverError({ message: `Stop app failed: ${e}` })
|
|
1809
585
|
}),
|
|
1810
|
-
killApp: (bundleId) =>
|
|
586
|
+
killApp: (bundleId) => Effect.tryPromise({
|
|
1811
587
|
try: () => client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
1812
588
|
appId: bundleId
|
|
1813
589
|
}),
|
|
1814
590
|
catch: (e) => new DriverError({ message: `Kill app failed: ${e}` })
|
|
1815
591
|
}),
|
|
1816
|
-
clearAppState: (bundleId) =>
|
|
592
|
+
clearAppState: (bundleId) => Effect.tryPromise({
|
|
1817
593
|
try: async () => {
|
|
1818
594
|
try {
|
|
1819
595
|
await client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
@@ -1828,7 +604,7 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1828
604
|
// -----------------------------------------------------------------------
|
|
1829
605
|
// Navigation
|
|
1830
606
|
// -----------------------------------------------------------------------
|
|
1831
|
-
openLink: (url) =>
|
|
607
|
+
openLink: (url) => Effect.tryPromise({
|
|
1832
608
|
try: () => {
|
|
1833
609
|
const args = { url };
|
|
1834
610
|
if (defaultBundleId) args.package = defaultBundleId;
|
|
@@ -1836,14 +612,14 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1836
612
|
},
|
|
1837
613
|
catch: (e) => new DriverError({ message: `Open link failed: ${e}` })
|
|
1838
614
|
}),
|
|
1839
|
-
back: () =>
|
|
615
|
+
back: () => Effect.tryPromise({
|
|
1840
616
|
try: () => client.request("POST", client.sessionPath("/back")),
|
|
1841
617
|
catch: (e) => new DriverError({ message: `Back failed: ${e}` })
|
|
1842
618
|
}),
|
|
1843
619
|
// -----------------------------------------------------------------------
|
|
1844
620
|
// Scripting (works when switched to a WebView context)
|
|
1845
621
|
// -----------------------------------------------------------------------
|
|
1846
|
-
evaluate: (script, ...args) =>
|
|
622
|
+
evaluate: (script, ...args) => Effect.tryPromise({
|
|
1847
623
|
try: () => client.executeScript(
|
|
1848
624
|
typeof script === "function" ? `return (${script})(...arguments)` : script,
|
|
1849
625
|
args
|
|
@@ -1853,22 +629,22 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1853
629
|
// -----------------------------------------------------------------------
|
|
1854
630
|
// WebView / hybrid context switching
|
|
1855
631
|
// -----------------------------------------------------------------------
|
|
1856
|
-
getContexts: () =>
|
|
632
|
+
getContexts: () => Effect.tryPromise({
|
|
1857
633
|
try: () => client.getContexts(),
|
|
1858
634
|
catch: (e) => new DriverError({ message: `getContexts failed: ${e}` })
|
|
1859
635
|
}),
|
|
1860
|
-
getCurrentContext: () =>
|
|
636
|
+
getCurrentContext: () => Effect.tryPromise({
|
|
1861
637
|
try: () => client.getCurrentContext(),
|
|
1862
638
|
catch: (e) => new DriverError({ message: `getCurrentContext failed: ${e}` })
|
|
1863
639
|
}),
|
|
1864
|
-
setContext: (contextId) =>
|
|
640
|
+
setContext: (contextId) => Effect.tryPromise({
|
|
1865
641
|
try: () => client.setContext(contextId),
|
|
1866
642
|
catch: (e) => new DriverError({ message: `setContext failed: ${e}` })
|
|
1867
643
|
}),
|
|
1868
644
|
// -----------------------------------------------------------------------
|
|
1869
645
|
// Network conditions
|
|
1870
646
|
// -----------------------------------------------------------------------
|
|
1871
|
-
setNetworkConditions: (conditions) =>
|
|
647
|
+
setNetworkConditions: (conditions) => Effect.tryPromise({
|
|
1872
648
|
try: () => {
|
|
1873
649
|
const resolved = resolveNetworkConditions(conditions);
|
|
1874
650
|
const hasAnyValue = conditions.profile !== void 0 || conditions.offline !== void 0 || conditions.latencyMs !== void 0 || conditions.downloadThroughputKbps !== void 0 || conditions.uploadThroughputKbps !== void 0;
|
|
@@ -1889,24 +665,24 @@ function createAppiumAndroidDriver(client, defaultBundleId) {
|
|
|
1889
665
|
catch: (e) => new DriverError({ message: `setNetworkConditions failed: ${e}` })
|
|
1890
666
|
})
|
|
1891
667
|
};
|
|
1892
|
-
return
|
|
668
|
+
return Effect.succeed(service);
|
|
1893
669
|
}
|
|
1894
670
|
|
|
1895
671
|
// src/drivers/appium/ios.ts
|
|
1896
|
-
import { Effect as
|
|
672
|
+
import { Effect as Effect2 } from "effect";
|
|
1897
673
|
function createAppiumIOSDriver(client) {
|
|
1898
674
|
const service = {
|
|
1899
675
|
// -----------------------------------------------------------------------
|
|
1900
676
|
// Hierarchy
|
|
1901
677
|
// -----------------------------------------------------------------------
|
|
1902
|
-
dumpHierarchy: () =>
|
|
678
|
+
dumpHierarchy: () => Effect2.tryPromise({
|
|
1903
679
|
try: () => client.request("GET", client.sessionPath("/source")),
|
|
1904
680
|
catch: (e) => new DriverError({ message: `Failed to get page source: ${e}` })
|
|
1905
681
|
}),
|
|
1906
682
|
// -----------------------------------------------------------------------
|
|
1907
683
|
// Coordinate-level actions (W3C touch pointer actions for iOS)
|
|
1908
684
|
// -----------------------------------------------------------------------
|
|
1909
|
-
tapAtCoordinate: (x, y) =>
|
|
685
|
+
tapAtCoordinate: (x, y) => Effect2.tryPromise({
|
|
1910
686
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1911
687
|
actions: [
|
|
1912
688
|
{
|
|
@@ -1923,7 +699,7 @@ function createAppiumIOSDriver(client) {
|
|
|
1923
699
|
}),
|
|
1924
700
|
catch: (e) => new DriverError({ message: `Tap failed: ${e}` })
|
|
1925
701
|
}),
|
|
1926
|
-
doubleTapAtCoordinate: (x, y) =>
|
|
702
|
+
doubleTapAtCoordinate: (x, y) => Effect2.tryPromise({
|
|
1927
703
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1928
704
|
actions: [
|
|
1929
705
|
{
|
|
@@ -1943,7 +719,7 @@ function createAppiumIOSDriver(client) {
|
|
|
1943
719
|
}),
|
|
1944
720
|
catch: (e) => new DriverError({ message: `Double tap failed: ${e}` })
|
|
1945
721
|
}),
|
|
1946
|
-
longPressAtCoordinate: (x, y, duration) =>
|
|
722
|
+
longPressAtCoordinate: (x, y, duration) => Effect2.tryPromise({
|
|
1947
723
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1948
724
|
actions: [
|
|
1949
725
|
{
|
|
@@ -1961,7 +737,7 @@ function createAppiumIOSDriver(client) {
|
|
|
1961
737
|
}),
|
|
1962
738
|
catch: (e) => new DriverError({ message: `Long press failed: ${e}` })
|
|
1963
739
|
}),
|
|
1964
|
-
swipe: (sx, sy, ex, ey, dur) =>
|
|
740
|
+
swipe: (sx, sy, ex, ey, dur) => Effect2.tryPromise({
|
|
1965
741
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
1966
742
|
actions: [
|
|
1967
743
|
{
|
|
@@ -1982,7 +758,7 @@ function createAppiumIOSDriver(client) {
|
|
|
1982
758
|
// -----------------------------------------------------------------------
|
|
1983
759
|
// Text input
|
|
1984
760
|
// -----------------------------------------------------------------------
|
|
1985
|
-
inputText: (text) =>
|
|
761
|
+
inputText: (text) => Effect2.tryPromise({
|
|
1986
762
|
try: () => {
|
|
1987
763
|
const keyActions = [];
|
|
1988
764
|
for (const segment of splitGraphemes(text)) {
|
|
@@ -2001,7 +777,7 @@ function createAppiumIOSDriver(client) {
|
|
|
2001
777
|
},
|
|
2002
778
|
catch: (e) => new DriverError({ message: `Input text failed: ${e}` })
|
|
2003
779
|
}),
|
|
2004
|
-
pressKey: (key) =>
|
|
780
|
+
pressKey: (key) => Effect2.tryPromise({
|
|
2005
781
|
try: () => client.request("POST", client.sessionPath("/actions"), {
|
|
2006
782
|
actions: [
|
|
2007
783
|
{
|
|
@@ -2016,21 +792,21 @@ function createAppiumIOSDriver(client) {
|
|
|
2016
792
|
}),
|
|
2017
793
|
catch: (e) => new DriverError({ message: `Press key failed: ${e}` })
|
|
2018
794
|
}),
|
|
2019
|
-
hideKeyboard: () =>
|
|
795
|
+
hideKeyboard: () => Effect2.tryPromise({
|
|
2020
796
|
try: () => client.request("POST", client.sessionPath("/appium/device/hide_keyboard")),
|
|
2021
797
|
catch: (e) => new DriverError({ message: `Hide keyboard failed: ${e}` })
|
|
2022
798
|
}),
|
|
2023
799
|
// -----------------------------------------------------------------------
|
|
2024
800
|
// Queries
|
|
2025
801
|
// -----------------------------------------------------------------------
|
|
2026
|
-
takeScreenshot: () =>
|
|
802
|
+
takeScreenshot: () => Effect2.tryPromise({
|
|
2027
803
|
try: async () => {
|
|
2028
804
|
const base64 = await client.request("GET", client.sessionPath("/screenshot"));
|
|
2029
805
|
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
2030
806
|
},
|
|
2031
807
|
catch: (e) => new DriverError({ message: `Screenshot failed: ${e}` })
|
|
2032
808
|
}),
|
|
2033
|
-
getDeviceInfo: () =>
|
|
809
|
+
getDeviceInfo: () => Effect2.tryPromise({
|
|
2034
810
|
try: async () => {
|
|
2035
811
|
const size = await getAppiumWindowSize(client);
|
|
2036
812
|
const caps = client.getSessionCaps();
|
|
@@ -2049,7 +825,7 @@ function createAppiumIOSDriver(client) {
|
|
|
2049
825
|
// -----------------------------------------------------------------------
|
|
2050
826
|
// App lifecycle
|
|
2051
827
|
// -----------------------------------------------------------------------
|
|
2052
|
-
launchApp: (bundleId, opts) =>
|
|
828
|
+
launchApp: (bundleId, opts) => Effect2.tryPromise({
|
|
2053
829
|
try: async () => {
|
|
2054
830
|
const launchConfig = buildIOSLaunchConfiguration(opts);
|
|
2055
831
|
if (opts?.clearState) {
|
|
@@ -2100,19 +876,19 @@ function createAppiumIOSDriver(client) {
|
|
|
2100
876
|
},
|
|
2101
877
|
catch: (e) => new DriverError({ message: `Launch app failed: ${e}` })
|
|
2102
878
|
}),
|
|
2103
|
-
stopApp: (bundleId) =>
|
|
879
|
+
stopApp: (bundleId) => Effect2.tryPromise({
|
|
2104
880
|
try: () => client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
2105
881
|
appId: bundleId
|
|
2106
882
|
}),
|
|
2107
883
|
catch: (e) => new DriverError({ message: `Stop app failed: ${e}` })
|
|
2108
884
|
}),
|
|
2109
|
-
killApp: (bundleId) =>
|
|
885
|
+
killApp: (bundleId) => Effect2.tryPromise({
|
|
2110
886
|
try: () => client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
2111
887
|
appId: bundleId
|
|
2112
888
|
}),
|
|
2113
889
|
catch: (e) => new DriverError({ message: `Kill app failed: ${e}` })
|
|
2114
890
|
}),
|
|
2115
|
-
clearAppState: (bundleId) =>
|
|
891
|
+
clearAppState: (bundleId) => Effect2.tryPromise({
|
|
2116
892
|
try: async () => {
|
|
2117
893
|
try {
|
|
2118
894
|
await client.request("POST", client.sessionPath("/appium/device/terminate_app"), {
|
|
@@ -2129,11 +905,11 @@ function createAppiumIOSDriver(client) {
|
|
|
2129
905
|
// -----------------------------------------------------------------------
|
|
2130
906
|
// Navigation
|
|
2131
907
|
// -----------------------------------------------------------------------
|
|
2132
|
-
openLink: (url) =>
|
|
908
|
+
openLink: (url) => Effect2.tryPromise({
|
|
2133
909
|
try: () => client.request("POST", client.sessionPath("/url"), { url }),
|
|
2134
910
|
catch: (e) => new DriverError({ message: `Open link failed: ${e}` })
|
|
2135
911
|
}),
|
|
2136
|
-
back: () =>
|
|
912
|
+
back: () => Effect2.fail(
|
|
2137
913
|
new DriverError({
|
|
2138
914
|
message: "back() is not supported on iOS. Use navigation within the app or swipe gestures."
|
|
2139
915
|
})
|
|
@@ -2141,7 +917,7 @@ function createAppiumIOSDriver(client) {
|
|
|
2141
917
|
// -----------------------------------------------------------------------
|
|
2142
918
|
// Scripting (works when switched to a WebView context)
|
|
2143
919
|
// -----------------------------------------------------------------------
|
|
2144
|
-
evaluate: (script, ...args) =>
|
|
920
|
+
evaluate: (script, ...args) => Effect2.tryPromise({
|
|
2145
921
|
try: () => client.executeScript(
|
|
2146
922
|
typeof script === "function" ? `return (${script})(...arguments)` : script,
|
|
2147
923
|
args
|
|
@@ -2151,22 +927,22 @@ function createAppiumIOSDriver(client) {
|
|
|
2151
927
|
// -----------------------------------------------------------------------
|
|
2152
928
|
// WebView / hybrid context switching
|
|
2153
929
|
// -----------------------------------------------------------------------
|
|
2154
|
-
getContexts: () =>
|
|
930
|
+
getContexts: () => Effect2.tryPromise({
|
|
2155
931
|
try: () => client.getContexts(),
|
|
2156
932
|
catch: (e) => new DriverError({ message: `getContexts failed: ${e}` })
|
|
2157
933
|
}),
|
|
2158
|
-
getCurrentContext: () =>
|
|
934
|
+
getCurrentContext: () => Effect2.tryPromise({
|
|
2159
935
|
try: () => client.getCurrentContext(),
|
|
2160
936
|
catch: (e) => new DriverError({ message: `getCurrentContext failed: ${e}` })
|
|
2161
937
|
}),
|
|
2162
|
-
setContext: (contextId) =>
|
|
938
|
+
setContext: (contextId) => Effect2.tryPromise({
|
|
2163
939
|
try: () => client.setContext(contextId),
|
|
2164
940
|
catch: (e) => new DriverError({ message: `setContext failed: ${e}` })
|
|
2165
941
|
}),
|
|
2166
942
|
// -----------------------------------------------------------------------
|
|
2167
943
|
// Network conditions
|
|
2168
944
|
// -----------------------------------------------------------------------
|
|
2169
|
-
setNetworkConditions: (conditions) =>
|
|
945
|
+
setNetworkConditions: (conditions) => Effect2.tryPromise({
|
|
2170
946
|
try: () => {
|
|
2171
947
|
const resolved = resolveNetworkConditions(conditions);
|
|
2172
948
|
const hasAnyValue = conditions.profile !== void 0 || conditions.offline !== void 0 || conditions.latencyMs !== void 0 || conditions.downloadThroughputKbps !== void 0 || conditions.uploadThroughputKbps !== void 0;
|
|
@@ -2187,7 +963,7 @@ function createAppiumIOSDriver(client) {
|
|
|
2187
963
|
catch: (e) => new DriverError({ message: `setNetworkConditions failed: ${e}` })
|
|
2188
964
|
})
|
|
2189
965
|
};
|
|
2190
|
-
return
|
|
966
|
+
return Effect2.succeed(service);
|
|
2191
967
|
}
|
|
2192
968
|
|
|
2193
969
|
// src/runtime/appium.ts
|
|
@@ -2198,8 +974,8 @@ async function buildAppiumAndroidRuntime(config, appiumUrl, caps) {
|
|
|
2198
974
|
platformName: "Android",
|
|
2199
975
|
...caps
|
|
2200
976
|
});
|
|
2201
|
-
const driver = await
|
|
2202
|
-
const deviceInfo = await
|
|
977
|
+
const driver = await Effect3.runPromise(createAppiumAndroidDriver(client, appId || void 0));
|
|
978
|
+
const deviceInfo = await Effect3.runPromise(driver.getDeviceInfo());
|
|
2203
979
|
const sessionId = client.getSessionId() ?? void 0;
|
|
2204
980
|
const sessionCaps = client.getSessionCaps();
|
|
2205
981
|
const detectedProvider = detectProvider(appiumUrl);
|
|
@@ -2264,8 +1040,8 @@ async function buildAppiumIOSRuntime(config, appiumUrl, caps) {
|
|
|
2264
1040
|
} catch (e) {
|
|
2265
1041
|
console.warn(`Failed to set snapshotMaxDepth (continuing): ${e}`);
|
|
2266
1042
|
}
|
|
2267
|
-
const driver = await
|
|
2268
|
-
const deviceInfo = await
|
|
1043
|
+
const driver = await Effect3.runPromise(createAppiumIOSDriver(client));
|
|
1044
|
+
const deviceInfo = await Effect3.runPromise(driver.getDeviceInfo());
|
|
2269
1045
|
const sessionId = client.getSessionId() ?? void 0;
|
|
2270
1046
|
const sessionCaps = client.getSessionCaps();
|
|
2271
1047
|
const detectedProvider = detectProvider(appiumUrl);
|
|
@@ -2318,8 +1094,8 @@ async function buildAppiumIOSRuntime(config, appiumUrl, caps) {
|
|
|
2318
1094
|
// src/cli/iteration.ts
|
|
2319
1095
|
import { execFileSync } from "child_process";
|
|
2320
1096
|
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
2321
|
-
import { dirname, join
|
|
2322
|
-
import { mkdirSync
|
|
1097
|
+
import { dirname, join, resolve } from "path";
|
|
1098
|
+
import { mkdirSync, existsSync } from "fs";
|
|
2323
1099
|
var SCHEMA_VERSION = 1;
|
|
2324
1100
|
function buildLastRunState(options) {
|
|
2325
1101
|
const { flowDir, platforms, results, sourcePathsByFlowName } = options;
|
|
@@ -2329,7 +1105,13 @@ function buildLastRunState(options) {
|
|
|
2329
1105
|
for (const result of results) {
|
|
2330
1106
|
const passed = result.status === "passed";
|
|
2331
1107
|
const sourcePath = sourcePathsByFlowName.get(result.name);
|
|
2332
|
-
flows.push({
|
|
1108
|
+
flows.push({
|
|
1109
|
+
name: result.name,
|
|
1110
|
+
platform: result.platform,
|
|
1111
|
+
passed,
|
|
1112
|
+
durationMs: result.durationMs,
|
|
1113
|
+
sourcePath
|
|
1114
|
+
});
|
|
2333
1115
|
if (!passed) {
|
|
2334
1116
|
if (!failedFlowNames.includes(result.name)) failedFlowNames.push(result.name);
|
|
2335
1117
|
if (sourcePath && !failedSourcePaths.includes(sourcePath)) failedSourcePaths.push(sourcePath);
|
|
@@ -2354,9 +1136,19 @@ async function readLastRunState(filePath) {
|
|
|
2354
1136
|
return null;
|
|
2355
1137
|
}
|
|
2356
1138
|
}
|
|
1139
|
+
function extractDurationHints(state) {
|
|
1140
|
+
const hints = {};
|
|
1141
|
+
if (!state?.flows) return hints;
|
|
1142
|
+
for (const entry of state.flows) {
|
|
1143
|
+
if (typeof entry.durationMs === "number" && entry.durationMs > 0) {
|
|
1144
|
+
hints[entry.name] = Math.max(hints[entry.name] ?? 0, entry.durationMs);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return hints;
|
|
1148
|
+
}
|
|
2357
1149
|
async function writeLastRunState(filePath, state) {
|
|
2358
1150
|
const dir = dirname(filePath);
|
|
2359
|
-
if (!
|
|
1151
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
2360
1152
|
await writeFile(filePath, JSON.stringify(state, null, 2), "utf8");
|
|
2361
1153
|
}
|
|
2362
1154
|
function getGitChangedFiles(cwd) {
|
|
@@ -2398,7 +1190,7 @@ function selectChangedFlowPaths(options) {
|
|
|
2398
1190
|
return { mode: "none", reason: "No changed flow files detected.", flowPaths: [] };
|
|
2399
1191
|
}
|
|
2400
1192
|
function createLastRunStatePath(outputDir) {
|
|
2401
|
-
return
|
|
1193
|
+
return join(outputDir, ".spana", "last-run.json");
|
|
2402
1194
|
}
|
|
2403
1195
|
|
|
2404
1196
|
// src/cli/watch-mode.ts
|
|
@@ -2491,8 +1283,8 @@ function validateOptions(opts) {
|
|
|
2491
1283
|
}
|
|
2492
1284
|
return null;
|
|
2493
1285
|
}
|
|
2494
|
-
async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, resolveFromConfig) {
|
|
2495
|
-
const { discoverDevices, findDeviceById } = await import("./discover-
|
|
1286
|
+
async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, resolveFromConfig, prelaunchedWeb) {
|
|
1287
|
+
const { discoverDevices, findDeviceById } = await import("./discover-LHEBSUIP.js");
|
|
2496
1288
|
let allDevices;
|
|
2497
1289
|
if (opts.devices) {
|
|
2498
1290
|
allDevices = [];
|
|
@@ -2522,11 +1314,12 @@ async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, r
|
|
|
2522
1314
|
if (platform === "web") {
|
|
2523
1315
|
const webWorkers = maxWorkers ?? 1;
|
|
2524
1316
|
if (webWorkers > 1) {
|
|
2525
|
-
const
|
|
1317
|
+
const pooledResults = await buildWebRuntimePool(config, webWorkers, prelaunchedWeb);
|
|
1318
|
+
const primaryResult = pooledResults[0];
|
|
2526
1319
|
runtimes.push(primaryResult.runtime);
|
|
2527
1320
|
const additionalWorkers = [];
|
|
2528
|
-
for (let i = 1; i <
|
|
2529
|
-
const result =
|
|
1321
|
+
for (let i = 1; i < pooledResults.length; i++) {
|
|
1322
|
+
const result = pooledResults[i];
|
|
2530
1323
|
runtimes.push(result.runtime);
|
|
2531
1324
|
additionalWorkers.push({
|
|
2532
1325
|
id: `web-context-${i + 1}`,
|
|
@@ -2550,7 +1343,7 @@ async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, r
|
|
|
2550
1343
|
additionalWorkers: additionalWorkers.length > 0 ? additionalWorkers : void 0
|
|
2551
1344
|
});
|
|
2552
1345
|
} else {
|
|
2553
|
-
const result = await buildWebRuntime(config);
|
|
1346
|
+
const result = await buildWebRuntime(config, prelaunchedWeb);
|
|
2554
1347
|
runtimes.push(result.runtime);
|
|
2555
1348
|
platformConfigs.push({
|
|
2556
1349
|
platform,
|
|
@@ -2562,6 +1355,30 @@ async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, r
|
|
|
2562
1355
|
}
|
|
2563
1356
|
});
|
|
2564
1357
|
}
|
|
1358
|
+
} else if (platform === "electron") {
|
|
1359
|
+
const result = await buildElectronRuntime(config, resolveFromConfig);
|
|
1360
|
+
runtimes.push(result.runtime);
|
|
1361
|
+
platformConfigs.push({
|
|
1362
|
+
platform,
|
|
1363
|
+
driver: result.runtime.driver,
|
|
1364
|
+
engineConfig: {
|
|
1365
|
+
...result.engineConfig,
|
|
1366
|
+
debugOnFailure: opts.debugOnFailure,
|
|
1367
|
+
updateBaselines: opts.updateBaselines
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
} else if (platform === "electrobun") {
|
|
1371
|
+
const result = await buildElectrobunRuntime(config, resolveFromConfig);
|
|
1372
|
+
runtimes.push(result.runtime);
|
|
1373
|
+
platformConfigs.push({
|
|
1374
|
+
platform,
|
|
1375
|
+
driver: result.runtime.driver,
|
|
1376
|
+
engineConfig: {
|
|
1377
|
+
...result.engineConfig,
|
|
1378
|
+
debugOnFailure: opts.debugOnFailure,
|
|
1379
|
+
updateBaselines: opts.updateBaselines
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
2565
1382
|
} else if (platformDevices.length === 0) {
|
|
2566
1383
|
console.log(`No ${platform} devices found. Skipping ${platform} platform.`);
|
|
2567
1384
|
} else {
|
|
@@ -2611,7 +1428,7 @@ async function buildParallelPlatformConfigs(platforms, opts, config, runtimes, r
|
|
|
2611
1428
|
}
|
|
2612
1429
|
return platformConfigs;
|
|
2613
1430
|
}
|
|
2614
|
-
async function buildSerialPlatformConfigs(platforms, opts, config, runtimes, executionMode, appiumUrl, appiumConfig, cloudHelper, targetDevice, resolveFromConfig) {
|
|
1431
|
+
async function buildSerialPlatformConfigs(platforms, opts, config, runtimes, executionMode, appiumUrl, appiumConfig, cloudHelper, targetDevice, resolveFromConfig, prelaunchedWeb) {
|
|
2615
1432
|
const platformConfigs = [];
|
|
2616
1433
|
for (const platform of platforms) {
|
|
2617
1434
|
if (executionMode === "appium" && (platform === "android" || platform === "ios")) {
|
|
@@ -2639,7 +1456,7 @@ async function buildSerialPlatformConfigs(platforms, opts, config, runtimes, exe
|
|
|
2639
1456
|
}
|
|
2640
1457
|
});
|
|
2641
1458
|
} else if (platform === "web") {
|
|
2642
|
-
const result = await buildWebRuntime(config);
|
|
1459
|
+
const result = await buildWebRuntime(config, prelaunchedWeb);
|
|
2643
1460
|
runtimes.push(result.runtime);
|
|
2644
1461
|
platformConfigs.push({
|
|
2645
1462
|
platform,
|
|
@@ -2676,11 +1493,35 @@ async function buildSerialPlatformConfigs(platforms, opts, config, runtimes, exe
|
|
|
2676
1493
|
updateBaselines: opts.updateBaselines
|
|
2677
1494
|
}
|
|
2678
1495
|
});
|
|
1496
|
+
} else if (platform === "electron") {
|
|
1497
|
+
const result = await buildElectronRuntime(config, resolveFromConfig);
|
|
1498
|
+
runtimes.push(result.runtime);
|
|
1499
|
+
platformConfigs.push({
|
|
1500
|
+
platform,
|
|
1501
|
+
driver: result.runtime.driver,
|
|
1502
|
+
engineConfig: {
|
|
1503
|
+
...result.engineConfig,
|
|
1504
|
+
debugOnFailure: opts.debugOnFailure,
|
|
1505
|
+
updateBaselines: opts.updateBaselines
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
} else if (platform === "electrobun") {
|
|
1509
|
+
const result = await buildElectrobunRuntime(config, resolveFromConfig);
|
|
1510
|
+
runtimes.push(result.runtime);
|
|
1511
|
+
platformConfigs.push({
|
|
1512
|
+
platform,
|
|
1513
|
+
driver: result.runtime.driver,
|
|
1514
|
+
engineConfig: {
|
|
1515
|
+
...result.engineConfig,
|
|
1516
|
+
debugOnFailure: opts.debugOnFailure,
|
|
1517
|
+
updateBaselines: opts.updateBaselines
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
2679
1520
|
}
|
|
2680
1521
|
}
|
|
2681
1522
|
return platformConfigs;
|
|
2682
1523
|
}
|
|
2683
|
-
var BUILTIN_REPORTERS = /* @__PURE__ */ new Set(["console", "json", "junit", "html", "allure"]);
|
|
1524
|
+
var BUILTIN_REPORTERS = /* @__PURE__ */ new Set(["console", "json", "junit", "html", "allure", "github"]);
|
|
2684
1525
|
async function loadCustomReporter(modulePath, configDir) {
|
|
2685
1526
|
const resolvedPath = modulePath.startsWith(".") ? resolve3(configDir, modulePath) : modulePath;
|
|
2686
1527
|
let mod;
|
|
@@ -2708,15 +1549,16 @@ async function loadCustomReporter(modulePath, configDir) {
|
|
|
2708
1549
|
`Custom reporter "${modulePath}" default export must be a Reporter object or factory function, got ${typeof exported}.`
|
|
2709
1550
|
);
|
|
2710
1551
|
}
|
|
2711
|
-
async function setupReporters(reporterNames, config, resolveFromConfig, appiumUrl, opts) {
|
|
1552
|
+
async function setupReporters(reporterNames, config, resolveFromConfig, appiumUrl, opts, filterSummaries = []) {
|
|
2712
1553
|
const { createRedactor, registerUrlSecrets } = await import("./redact-U72BUBBR.js");
|
|
2713
1554
|
const redactor = createRedactor();
|
|
2714
1555
|
if (appiumUrl) registerUrlSecrets(redactor, appiumUrl);
|
|
2715
|
-
const { createConsoleReporter } = await import("./console-
|
|
1556
|
+
const { createConsoleReporter } = await import("./console-MI2XB5RG.js");
|
|
2716
1557
|
const { createJsonReporter } = await import("./json-JMRPUVY2.js");
|
|
2717
1558
|
const { createJUnitReporter } = await import("./junit-HLC62MK6.js");
|
|
2718
1559
|
const { createHtmlReporter } = await import("./html-F3X3XPSX.js");
|
|
2719
1560
|
const { createAllureReporter } = await import("./allure-RNMEYTXS.js");
|
|
1561
|
+
const { createGitHubPrReporter } = await import("./github-pr-YMWIPCCZ.js");
|
|
2720
1562
|
const resolvedOutputDir = config.artifacts?.outputDir ?? resolveFromConfig("./spana-output");
|
|
2721
1563
|
const reporters = [];
|
|
2722
1564
|
for (const name of reporterNames.split(",")) {
|
|
@@ -2736,6 +1578,9 @@ async function setupReporters(reporterNames, config, resolveFromConfig, appiumUr
|
|
|
2736
1578
|
case "allure":
|
|
2737
1579
|
reporters.push(createAllureReporter());
|
|
2738
1580
|
break;
|
|
1581
|
+
case "github":
|
|
1582
|
+
reporters.push(createGitHubPrReporter({ outputDir: resolvedOutputDir, filterSummaries }));
|
|
1583
|
+
break;
|
|
2739
1584
|
default:
|
|
2740
1585
|
reporters.push(createConsoleReporter({ quiet: opts.quiet }));
|
|
2741
1586
|
break;
|
|
@@ -2808,10 +1653,10 @@ async function resolveExecutionContext(opts) {
|
|
|
2808
1653
|
};
|
|
2809
1654
|
}
|
|
2810
1655
|
async function resolveTargetDevice(deviceId, platforms, cliPlatforms) {
|
|
2811
|
-
const { findDeviceById } = await import("./discover-
|
|
1656
|
+
const { findDeviceById } = await import("./discover-LHEBSUIP.js");
|
|
2812
1657
|
const targetDevice = findDeviceById(deviceId);
|
|
2813
1658
|
if (!targetDevice) {
|
|
2814
|
-
const { discoverDevices } = await import("./discover-
|
|
1659
|
+
const { discoverDevices } = await import("./discover-LHEBSUIP.js");
|
|
2815
1660
|
const available = discoverDevices(["web", "android", "ios"]);
|
|
2816
1661
|
console.log(`Device "${deviceId}" not found. Available devices:`);
|
|
2817
1662
|
for (const d of available) {
|
|
@@ -2889,6 +1734,34 @@ async function discoverAndFilterFlows(input) {
|
|
|
2889
1734
|
);
|
|
2890
1735
|
const allowedFlows = new Set(filteredFlows);
|
|
2891
1736
|
let filteredLoadedFlows = loadedFlows.filter((l) => allowedFlows.has(l.flow));
|
|
1737
|
+
let filterSummaries = [];
|
|
1738
|
+
if (input.changedSince && input.filters && input.filters.length > 0 && filteredLoadedFlows.length > 0) {
|
|
1739
|
+
const { applyTestFilters, buildFilterCandidates, collectGitChanges, formatFilterSummary } = await import("./filters-Q3ALKWZ5.js");
|
|
1740
|
+
try {
|
|
1741
|
+
const cwd = process.cwd();
|
|
1742
|
+
const changes = collectGitChanges(input.changedSince, cwd);
|
|
1743
|
+
const candidates = buildFilterCandidates(filteredLoadedFlows, cwd);
|
|
1744
|
+
const result = await applyTestFilters(filteredLoadedFlows, candidates, input.filters, {
|
|
1745
|
+
cwd,
|
|
1746
|
+
changes,
|
|
1747
|
+
configPath: input.configPath,
|
|
1748
|
+
platforms: input.platforms
|
|
1749
|
+
});
|
|
1750
|
+
filterSummaries = formatFilterSummary(result.reports);
|
|
1751
|
+
for (const line of filterSummaries) {
|
|
1752
|
+
console.log(line);
|
|
1753
|
+
}
|
|
1754
|
+
filteredLoadedFlows = result.kept;
|
|
1755
|
+
if (filteredLoadedFlows.length === 0) {
|
|
1756
|
+
console.log("All flows were filtered out by --changed-since filters.");
|
|
1757
|
+
return { ok: false, success: true, watchRoots };
|
|
1758
|
+
}
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
console.log(
|
|
1761
|
+
`Warning: --changed-since ${input.changedSince} failed (${err instanceof Error ? err.message : String(err)}) \u2014 failing open and running all flows.`
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
2892
1765
|
if (input.lastFailed) {
|
|
2893
1766
|
const lastRunStatePath = createLastRunStatePath(input.outputDir);
|
|
2894
1767
|
const state = await readLastRunState(lastRunStatePath);
|
|
@@ -2925,7 +1798,7 @@ async function discoverAndFilterFlows(input) {
|
|
|
2925
1798
|
`Running shard ${input.shard.current}/${input.shard.total} (${selectedFlows.length}/${filteredLoadedFlows.length} flow(s))...`
|
|
2926
1799
|
);
|
|
2927
1800
|
}
|
|
2928
|
-
return { ok: true, selectedLoadedFlows, selectedFlows, watchRoots };
|
|
1801
|
+
return { ok: true, selectedLoadedFlows, selectedFlows, watchRoots, filterSummaries };
|
|
2929
1802
|
}
|
|
2930
1803
|
function createResultHandler(reporters, redactResult, redactor, opts) {
|
|
2931
1804
|
return (r) => {
|
|
@@ -3012,19 +1885,32 @@ async function runTestCommandOnce(opts) {
|
|
|
3012
1885
|
}
|
|
3013
1886
|
const reporterNames = opts.reporter?.trim() ? opts.reporter : config.reporters && config.reporters.length > 0 ? config.reporters.join(",") : "console";
|
|
3014
1887
|
const outputDir = config.artifacts?.outputDir ?? resolveFromConfig("./spana-output");
|
|
3015
|
-
const
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
1888
|
+
const prelaunchedWeb = executionMode === "local" && platforms.includes("web") ? speculativelyPrelaunchWebBrowser(config) : void 0;
|
|
1889
|
+
const [flowResult, priorRunState] = await Promise.all([
|
|
1890
|
+
discoverAndFilterFlows({
|
|
1891
|
+
flowDir,
|
|
1892
|
+
configPath,
|
|
1893
|
+
tags: opts.tags,
|
|
1894
|
+
grep: opts.grep,
|
|
1895
|
+
platforms,
|
|
1896
|
+
shard: opts.shard,
|
|
1897
|
+
lastFailed: opts.lastFailed,
|
|
1898
|
+
changed: opts.changed,
|
|
1899
|
+
changedSince: opts.changedSince,
|
|
1900
|
+
filters: config.filters,
|
|
1901
|
+
outputDir
|
|
1902
|
+
}),
|
|
1903
|
+
readLastRunState(createLastRunStatePath(outputDir))
|
|
1904
|
+
]);
|
|
1905
|
+
if (!flowResult.ok) {
|
|
1906
|
+
if (prelaunchedWeb?.ownsBrowser) {
|
|
1907
|
+
await prelaunchedWeb.browserPromise.then((b) => b.close()).catch(() => {
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
return { success: flowResult.success, watchRoots: flowResult.watchRoots };
|
|
1911
|
+
}
|
|
1912
|
+
const { selectedLoadedFlows, selectedFlows, watchRoots, filterSummaries } = flowResult;
|
|
1913
|
+
const durationHintsMs = extractDurationHints(priorRunState);
|
|
3028
1914
|
console.log(`Running ${selectedFlows.length} flow(s) on ${platforms.join(", ")}...
|
|
3029
1915
|
`);
|
|
3030
1916
|
const runtimes = [];
|
|
@@ -3078,7 +1964,8 @@ async function runTestCommandOnce(opts) {
|
|
|
3078
1964
|
opts,
|
|
3079
1965
|
config,
|
|
3080
1966
|
runtimes,
|
|
3081
|
-
resolveFromConfig
|
|
1967
|
+
resolveFromConfig,
|
|
1968
|
+
prelaunchedWeb
|
|
3082
1969
|
)
|
|
3083
1970
|
);
|
|
3084
1971
|
} else {
|
|
@@ -3093,7 +1980,8 @@ async function runTestCommandOnce(opts) {
|
|
|
3093
1980
|
appiumConfig,
|
|
3094
1981
|
cloudHelper,
|
|
3095
1982
|
targetDevice,
|
|
3096
|
-
resolveFromConfig
|
|
1983
|
+
resolveFromConfig,
|
|
1984
|
+
prelaunchedWeb
|
|
3097
1985
|
)
|
|
3098
1986
|
);
|
|
3099
1987
|
}
|
|
@@ -3102,7 +1990,8 @@ async function runTestCommandOnce(opts) {
|
|
|
3102
1990
|
config,
|
|
3103
1991
|
resolveFromConfig,
|
|
3104
1992
|
appiumUrl,
|
|
3105
|
-
opts
|
|
1993
|
+
opts,
|
|
1994
|
+
filterSummaries
|
|
3106
1995
|
);
|
|
3107
1996
|
const totalFlowCount = selectedFlows.length * platforms.length;
|
|
3108
1997
|
for (const reporter of reporters) {
|
|
@@ -3138,6 +2027,7 @@ async function runTestCommandOnce(opts) {
|
|
|
3138
2027
|
retries,
|
|
3139
2028
|
retryDelay,
|
|
3140
2029
|
bail: opts.bail,
|
|
2030
|
+
durationHintsMs: Object.keys(durationHintsMs).length > 0 ? durationHintsMs : void 0,
|
|
3141
2031
|
parallelPlatforms: opts.parallel || config.parallelPlatforms || !!opts.workers || !!opts.devices,
|
|
3142
2032
|
onFlowStart(name, platform, workerName) {
|
|
3143
2033
|
for (const reporter of reporters) {
|
|
@@ -3229,4 +2119,4 @@ export {
|
|
|
3229
2119
|
loadCustomReporter,
|
|
3230
2120
|
runTestCommand
|
|
3231
2121
|
};
|
|
3232
|
-
//# sourceMappingURL=test-command-
|
|
2122
|
+
//# sourceMappingURL=test-command-FYOZ6QAE.js.map
|