mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
d087a62d1d
* fix: improve maestro tab target swipes * fix: stop replay suites on pending timeout cleanup * fix: tighten maestro compat support plumbing * fix: resolve ios simulator url open targets * fix: speed up Android Maestro snapshots * fix: resolve android snapshot ci regressions * perf: reduce android snapshot helper overhead * docs: record persistent helper session architecture * chore: address snapshot session review * perf: add persistent Android snapshot helper session * fix: stabilize Android replay interactions * fix: stabilize Maestro visibility resolution * refactor: simplify Android keyboard parsing
87 lines
2.2 KiB
JavaScript
87 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
import { execFileSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const binPath = path.join(repoRoot, 'bin', 'agent-device.mjs');
|
|
|
|
const options = {
|
|
platform: 'ios',
|
|
session: 'test-app-maestro',
|
|
flowDir: path.join(repoRoot, 'examples', 'test-app', 'maestro'),
|
|
openTarget: '',
|
|
close: false,
|
|
passthrough: [],
|
|
};
|
|
|
|
for (let index = 2; index < process.argv.length; index += 1) {
|
|
const arg = process.argv[index];
|
|
if (arg === '--') {
|
|
options.passthrough.push(...process.argv.slice(index + 1));
|
|
break;
|
|
}
|
|
if (arg === '--platform' && process.argv[index + 1]) {
|
|
options.platform = process.argv[index + 1];
|
|
index += 1;
|
|
continue;
|
|
}
|
|
if (arg === '--session' && process.argv[index + 1]) {
|
|
options.session = process.argv[index + 1];
|
|
index += 1;
|
|
continue;
|
|
}
|
|
if (arg === '--flow-dir' && process.argv[index + 1]) {
|
|
options.flowDir = path.resolve(process.argv[index + 1]);
|
|
index += 1;
|
|
continue;
|
|
}
|
|
if (arg === '--open' && process.argv[index + 1]) {
|
|
options.openTarget = process.argv[index + 1];
|
|
index += 1;
|
|
continue;
|
|
}
|
|
if (arg === '--close') {
|
|
options.close = true;
|
|
continue;
|
|
}
|
|
options.passthrough.push(arg);
|
|
}
|
|
|
|
const flows = fs
|
|
.readdirSync(options.flowDir)
|
|
.filter((entry) => entry.endsWith('.yaml') || entry.endsWith('.yml'))
|
|
.sort()
|
|
.map((entry) => path.join(options.flowDir, entry));
|
|
|
|
if (flows.length === 0) {
|
|
console.error(`No Maestro flows found in ${options.flowDir}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
function runAgentDevice(args) {
|
|
execFileSync(process.execPath, [binPath, '--session', options.session, ...args], {
|
|
cwd: repoRoot,
|
|
stdio: 'inherit',
|
|
});
|
|
}
|
|
|
|
if (options.openTarget) {
|
|
runAgentDevice(['open', options.openTarget, '--platform', options.platform, ...options.passthrough]);
|
|
runAgentDevice(['wait', 'Agent Device Tester', '30000', '--platform', options.platform, ...options.passthrough]);
|
|
}
|
|
|
|
runAgentDevice([
|
|
'test',
|
|
options.flowDir,
|
|
'--maestro',
|
|
'--platform',
|
|
options.platform,
|
|
...options.passthrough,
|
|
]);
|
|
|
|
if (options.close) {
|
|
runAgentDevice(['close']);
|
|
}
|