@ihyeon/flow-qa 0.12.2 → 0.12.3
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/README.ko.md +1 -1
- package/dist/src/engine.js +7 -2
- package/dist/src/ios-simulator-tap.js +142 -0
- package/dist/src/mobile-runtime.js +3 -2
- package/docs/mobile.md +3 -1
- package/docs/releases.md +4 -0
- package/package.json +3 -2
package/README.ko.md
CHANGED
|
@@ -104,7 +104,7 @@ CLI에서는 `flow-qa reruns .flowqa/runs/<원본-실행-ID> --workspace my-qa -
|
|
|
104
104
|
|
|
105
105
|
CLI에서는 `plan flow.md --platform mobile --prompt-only`로 준비하고, `connect my-ios --platform ios --bundle-id com.example.app --device "QA iPhone"`으로 연결합니다. 예시의 앱과 기기 이름은 본인 환경으로 바꾸세요. 기존 웹 대상과 케이스도 유지됩니다. 준비 환경과 모바일 단계·검증 범위는 [모바일 가이드](docs/mobile.md)를 참고하세요.
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
iPhone 시뮬레이터의 세로 화면에서 320×480 레거시 앱에 상하 여백이 생기면, Flow QA는 요소의 탭 위치를 실제 화면 좌표로 보정합니다. 전체 화면 앱은 기존 요소 탭을 사용합니다. 탭 다음 단계에서 실제 상태 변화를 확인할 수 있습니다.
|
|
108
108
|
|
|
109
109
|
## 설계 원칙과 결과 해석
|
|
110
110
|
|
package/dist/src/engine.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { selectCases } from "./case-selection.js";
|
|
8
8
|
import { compileSuiteWithStepMap } from "./compiler.js";
|
|
9
|
-
import { acquireMobileDevice, checkMobileApp, mobileReadiness } from "./mobile-runtime.js";
|
|
9
|
+
import { acquireMobileDevice, checkMobileApp, isIosSimulatorId, mobileReadiness } from "./mobile-runtime.js";
|
|
10
10
|
import { failureReport, normalizeReport1, renderMarkdown, stoppedReport } from "./report.js";
|
|
11
11
|
import { configSchema, suiteSchema } from "./schema.js";
|
|
12
12
|
import { reportTarget, targetKind } from "./targets.js";
|
|
@@ -41,6 +41,11 @@ function generatedConfig(suite, config, targetName, agentAvailable, runId, sdkDe
|
|
|
41
41
|
lines.push(`import { mobileTools } from ${JSON.stringify(packageModule('@e2e-dev/mobile/tools'))};`);
|
|
42
42
|
lines.push(`const engine = mobile({ platform: ${JSON.stringify(target.platform)}, device: ${JSON.stringify(sdkDevice ?? target.device)}, session: ${JSON.stringify(runId)} });`);
|
|
43
43
|
}
|
|
44
|
+
const iosSimulator = mobile && target.platform === 'ios' && process.platform === 'darwin' && isIosSimulatorId(sdkDevice ?? target.device);
|
|
45
|
+
if (iosSimulator) {
|
|
46
|
+
lines.push(`import { withIosSimulatorTaps } from ${JSON.stringify(new URL(import.meta.url.endsWith('.ts') ? './ios-simulator-tap.ts' : './ios-simulator-tap.js', import.meta.url).href)};`);
|
|
47
|
+
lines.push(`const targetEngine = withIosSimulatorTaps(engine, ${JSON.stringify(runId)}, ${JSON.stringify(target.bundleId)});`);
|
|
48
|
+
}
|
|
44
49
|
if (agentAvailable)
|
|
45
50
|
lines.push(`import { createOpenAICompatible } from ${JSON.stringify(packageModule('@ai-sdk/openai-compatible'))};`);
|
|
46
51
|
const agent = config.agent;
|
|
@@ -52,7 +57,7 @@ function generatedConfig(suite, config, targetName, agentAvailable, runId, sdkDe
|
|
|
52
57
|
${agent.apiKeyEnv ? `apiKey: process.env[${JSON.stringify(agent.apiKeyEnv)}],` : ''}
|
|
53
58
|
}).chatModel(${JSON.stringify(agent.model)})${mobile ? ', tools: mobileTools(engine)' : ''} } }` : '';
|
|
54
59
|
const targetConfig = mobile
|
|
55
|
-
? `{ name: ${JSON.stringify(targetName)}, engine, app: { bundleId: ${JSON.stringify(target.bundleId)} } }`
|
|
60
|
+
? `{ name: ${JSON.stringify(targetName)}, engine: ${iosSimulator ? 'targetEngine' : 'engine'}, app: { bundleId: ${JSON.stringify(target.bundleId)} } }`
|
|
56
61
|
: `{ name: ${JSON.stringify(targetName)}, engine: web(), app: { url: ${JSON.stringify(target.url)} } }`;
|
|
57
62
|
lines.push(`export default {
|
|
58
63
|
projectId: ${JSON.stringify(suite.id)},
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { createAgentDeviceClient } from 'agent-device';
|
|
5
|
+
import { defineEngine, EngineError } from 'e2e/engine';
|
|
6
|
+
// In iPhone compatibility mode XCTest reports a 320x480 window. The ordinary
|
|
7
|
+
// snapshot clips that window at the on-display top inset but keeps node bounds
|
|
8
|
+
// in app points. Require both observations and the measured display to agree.
|
|
9
|
+
export function legacyTapTransform(app, window, display) {
|
|
10
|
+
if (window.x !== 0 || window.y !== 0 || window.width !== 320 || window.height !== 480
|
|
11
|
+
|| app.x !== 0 || app.y <= 0)
|
|
12
|
+
return;
|
|
13
|
+
const scale = display.width / window.width;
|
|
14
|
+
const top = (display.height - window.height * scale) / 2;
|
|
15
|
+
if (!Number.isFinite(top) || scale < 1 || top <= 0 || !near(top, app.y))
|
|
16
|
+
return;
|
|
17
|
+
if (near(app.width, display.width) && near(app.height, window.height * scale)) {
|
|
18
|
+
return { scale, top, window, coordinates: 'display' };
|
|
19
|
+
}
|
|
20
|
+
if (near(app.width, window.width) && near(app.y + app.height, window.height)) {
|
|
21
|
+
return { scale, top, window, coordinates: 'app' };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function toDisplay(rect, transform) {
|
|
25
|
+
const { scale, top } = transform;
|
|
26
|
+
return { x: rect.x * scale, y: top + rect.y * scale, width: rect.width * scale, height: rect.height * scale };
|
|
27
|
+
}
|
|
28
|
+
function translatedTapPoint(rect, transform) {
|
|
29
|
+
const display = transform.coordinates === 'app' ? toDisplay(rect, transform) : rect;
|
|
30
|
+
const x = display.x + display.width / 2;
|
|
31
|
+
const y = display.y + display.height / 2;
|
|
32
|
+
if (!Object.values(rect).every(Number.isFinite) || rect.width <= 0 || rect.height <= 0
|
|
33
|
+
|| x < 0 || y < transform.top || x >= transform.window.width * transform.scale
|
|
34
|
+
|| y >= transform.top + transform.window.height * transform.scale)
|
|
35
|
+
return;
|
|
36
|
+
return { x: Math.round(x), y: Math.round(y) };
|
|
37
|
+
}
|
|
38
|
+
function application(snapshot, bundleId) {
|
|
39
|
+
if (snapshot.appBundleId !== bundleId || snapshot.presentedSurface === 'presented'
|
|
40
|
+
|| (snapshot.keyboard && snapshot.keyboard.kind !== 'absent'))
|
|
41
|
+
return;
|
|
42
|
+
return snapshot.nodes.find(node => node.type === 'Application' && node.depth === 0)?.rect;
|
|
43
|
+
}
|
|
44
|
+
function near(a, b) { return Math.abs(a - b) <= 1; }
|
|
45
|
+
function sameRect(a, b) {
|
|
46
|
+
return a !== undefined && near(a.x, b.x) && near(a.y, b.y) && near(a.width, b.width) && near(a.height, b.height);
|
|
47
|
+
}
|
|
48
|
+
function stale() {
|
|
49
|
+
return new EngineError('NODE_STALE', 'The iOS tap target moved or changed before dispatch.', { retryable: true });
|
|
50
|
+
}
|
|
51
|
+
/** Keep e2e's ordinary selector tap unless this local simulator shows the legacy transform. */
|
|
52
|
+
export function withIosSimulatorTaps(engine, session, bundleId, clientFor = name => createAgentDeviceClient({ session: name, daemonLifecycle: 'attach' })) {
|
|
53
|
+
const { capabilities: _capabilities, ...hooks } = engine;
|
|
54
|
+
const locate = engine.locate;
|
|
55
|
+
const perform = engine.perform;
|
|
56
|
+
const performAt = engine.performAt;
|
|
57
|
+
let client;
|
|
58
|
+
let previous;
|
|
59
|
+
let display;
|
|
60
|
+
return defineEngine({
|
|
61
|
+
...hooks,
|
|
62
|
+
async init(info) {
|
|
63
|
+
client = clientFor(`${session}-${info.workerSlot}`);
|
|
64
|
+
display = undefined;
|
|
65
|
+
await engine.init?.(info);
|
|
66
|
+
},
|
|
67
|
+
async locate(expression, operation) {
|
|
68
|
+
const matches = await locate(expression, operation);
|
|
69
|
+
previous = matches.length === 1 ? { expression, node: matches[0] } : undefined;
|
|
70
|
+
return matches;
|
|
71
|
+
},
|
|
72
|
+
async perform(ref, action, operation) {
|
|
73
|
+
const initial = previous;
|
|
74
|
+
if (action.kind !== 'tap' || operation.origin !== 'test' || initial?.node.ref.id !== ref.id
|
|
75
|
+
|| !initial.node.rect || initial.node.states?.disabled || initial.node.states?.hidden
|
|
76
|
+
|| initial.node.role === 'switch' || initial.node.role === 'checkbox')
|
|
77
|
+
return perform(ref, action, operation);
|
|
78
|
+
const deadline = Date.now() + operation.timeoutMs;
|
|
79
|
+
const remaining = () => {
|
|
80
|
+
operation.signal.throwIfAborted();
|
|
81
|
+
const timeoutMs = deadline - Date.now();
|
|
82
|
+
if (timeoutMs <= 0)
|
|
83
|
+
throw new EngineError('OPERATION_TIMEOUT', 'iOS tap ran out of time before dispatch.', { retryable: false });
|
|
84
|
+
return { ...operation, timeoutMs };
|
|
85
|
+
};
|
|
86
|
+
const currentNode = async () => {
|
|
87
|
+
const matches = await locate(initial.expression, remaining());
|
|
88
|
+
const node = matches.length === 1 ? matches[0] : undefined;
|
|
89
|
+
if (!node || node.role !== initial.node.role || node.testId !== initial.node.testId || node.name !== initial.node.name
|
|
90
|
+
|| node.text !== initial.node.text || node.states?.disabled || node.states?.hidden)
|
|
91
|
+
throw stale();
|
|
92
|
+
return node;
|
|
93
|
+
};
|
|
94
|
+
const originalTap = async () => perform((await currentNode()).ref, action, remaining());
|
|
95
|
+
const snapshot = (raw, depth) => client.capture.snapshot({
|
|
96
|
+
raw, depth, noRecord: true, observeOnly: true, timeoutMs: remaining().timeoutMs,
|
|
97
|
+
});
|
|
98
|
+
const app = application(await snapshot(false, 1), bundleId);
|
|
99
|
+
if (!app || app.x !== 0 || app.y <= 0)
|
|
100
|
+
return originalTap();
|
|
101
|
+
const raw = await snapshot(true, 2);
|
|
102
|
+
const windows = raw.nodes.filter(node => node.type === 'Window');
|
|
103
|
+
const window = windows.length === 1 ? windows[0]?.rect : undefined;
|
|
104
|
+
if (raw.appBundleId !== bundleId || !window || window.width !== 320 || window.height !== 480) {
|
|
105
|
+
return originalTap();
|
|
106
|
+
}
|
|
107
|
+
if (!display) {
|
|
108
|
+
const directory = await mkdtemp(join(tmpdir(), 'flow-qa-ios-'));
|
|
109
|
+
try {
|
|
110
|
+
const shot = await client.capture.screenshot({ path: join(directory, 'screen.png') });
|
|
111
|
+
if (shot.displayRotation === 'portrait' && shot.logicalWidth && shot.logicalHeight) {
|
|
112
|
+
display = { width: shot.logicalWidth, height: shot.logicalHeight };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
await rm(directory, { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const transform = display && legacyTapTransform(app, window, display);
|
|
120
|
+
if (!transform)
|
|
121
|
+
return originalTap();
|
|
122
|
+
// The original locator was unique. Confirm it still has one hittable
|
|
123
|
+
// node at the same bounds and the same viewport after the geometry reads.
|
|
124
|
+
const latest = await snapshot(false);
|
|
125
|
+
const latestApp = application(latest, bundleId);
|
|
126
|
+
const latestTransform = latestApp && display && legacyTapTransform(latestApp, window, display);
|
|
127
|
+
if (!latestTransform || latest.truncated)
|
|
128
|
+
throw stale();
|
|
129
|
+
const originalRect = initial.node.rect;
|
|
130
|
+
const candidates = latest.nodes.filter(node => node.rect
|
|
131
|
+
&& (initial.node.testId ? node.identifier === initial.node.testId : node.label === initial.node.name)
|
|
132
|
+
&& (sameRect(node.rect, originalRect) || (latestTransform.coordinates === 'display'
|
|
133
|
+
? sameRect(node.rect, toDisplay(originalRect, latestTransform))
|
|
134
|
+
: sameRect(toDisplay(node.rect, latestTransform), originalRect))));
|
|
135
|
+
const node = candidates.length === 1 ? candidates[0] : undefined;
|
|
136
|
+
const point = node?.rect && translatedTapPoint(node.rect, latestTransform);
|
|
137
|
+
if (!point || !node?.hittable || node.enabled === false)
|
|
138
|
+
throw stale();
|
|
139
|
+
return performAt(point, { kind: 'tap' }, remaining());
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
@@ -5,6 +5,7 @@ const IOS_UDID = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$
|
|
|
5
5
|
const ANDROID_EMULATOR = /^emulator-\d+$/;
|
|
6
6
|
const activeDevices = new Set();
|
|
7
7
|
const execFileAsync = promisify(execFile);
|
|
8
|
+
export function isIosSimulatorId(value) { return IOS_UDID.test(value); }
|
|
8
9
|
// agent-device's --device name lookup is case-insensitive and treats _ as a space.
|
|
9
10
|
const normalizedName = (value) => value.replaceAll('_', ' ').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
10
11
|
async function localDevices(platform) {
|
|
@@ -52,7 +53,7 @@ export async function mobileReadiness(target, listDevices = localDevices) {
|
|
|
52
53
|
// The installed mobile engine recognizes only simulator UDIDs and emulator
|
|
53
54
|
// serials as IDs. Other identifiers must be passed as an unambiguous name.
|
|
54
55
|
const nativeId = target.platform === 'ios' ? selected.identifiers?.udid ?? selected.id : selected.identifiers?.serial ?? selected.id;
|
|
55
|
-
const acceptsId = target.platform === 'ios' ?
|
|
56
|
+
const acceptsId = target.platform === 'ios' ? isIosSimulatorId(nativeId) : ANDROID_EMULATOR.test(nativeId);
|
|
56
57
|
const sdkDevice = acceptsId ? nativeId : selected.name;
|
|
57
58
|
if (!sdkDevice || (!acceptsId && platformDevices.filter((device) => normalizedName(device.name) === normalizedName(selected.name)).length > 1)) {
|
|
58
59
|
return { ready: false, reason: 'Selected mobile device cannot be uniquely addressed by this runtime.' };
|
|
@@ -61,7 +62,7 @@ export async function mobileReadiness(target, listDevices = localDevices) {
|
|
|
61
62
|
}
|
|
62
63
|
/** Check only virtual devices whose installed apps can be queried without launching the app. */
|
|
63
64
|
export const checkMobileApp = async (target, sdkDevice) => {
|
|
64
|
-
if (target.platform === 'ios' &&
|
|
65
|
+
if (target.platform === 'ios' && isIosSimulatorId(sdkDevice)) {
|
|
65
66
|
try {
|
|
66
67
|
await execFileAsync('xcrun', ['simctl', 'get_app_container', sdkDevice, target.bundleId, 'app'], { timeout: 10_000, maxBuffer: 64 * 1024 });
|
|
67
68
|
return 'installed';
|
package/docs/mobile.md
CHANGED
|
@@ -36,7 +36,9 @@ For an iOS simulator, prepare Xcode, an installed simulator runtime, a booted si
|
|
|
36
36
|
|
|
37
37
|
Flow QA does not download SDKs, create or boot simulators, or install application builds. A missing or unavailable selected device blocks the run; a saved target is not evidence of a working device or app. Before a run on a booted iOS simulator or Android emulator, Flow QA also checks whether the configured app ID is installed. A confirmed missing app blocks the run with no test attempts and tells you to install it on that device. On Android emulators, the package query treats an empty response with exit code 1 as missing, matching ADB behavior. If the local app query cannot establish installation, the native engine still runs and its result remains visible; physical devices retain this engine-level check. For physical device IDs that the underlying engine resolves by name, the device name must be unique after case and whitespace normalization; ambiguous selection blocks the run. Chromium is only required for web targets.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
For deterministic `click` steps on a local portrait iPhone simulator, Flow QA corrects the coordinate offset of a legacy 320×480 app displayed with top and bottom bars. It checks the app window, simulator display, and matching hittable element before sending one tap. A full-screen app uses the standard element tap. Keep a following state assertion to confirm the effect of a tap.
|
|
40
|
+
|
|
41
|
+
Run `npm run smoke:ios-tap -- <booted-iPhone-simulator-UDID>` from the repository to build the fixture in both display modes and verify two distinct element taps. Set `FLOWQA_BIN` to an installed Flow QA executable to run the same fixture against a published package.
|
|
40
42
|
|
|
41
43
|
## Native steps
|
|
42
44
|
|
package/docs/releases.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Releases and verification
|
|
2
2
|
|
|
3
|
+
## 0.12.3 — tap the visible element in legacy iPhone simulator layouts
|
|
4
|
+
|
|
5
|
+
On a local portrait simulator, deterministic clicks now convert legacy 320×480 app coordinates to the visible position when the window, display and element geometry identify the offset. Full-screen apps retain the usual element tap. The simulator regression runs the same UIKit fixture in both modes and verifies the state after each of two taps.
|
|
6
|
+
|
|
3
7
|
## 0.12.2 — reopen nested case files and compare partial reruns
|
|
4
8
|
|
|
5
9
|
The CLI and local UI find cases in subfolders of `cases/` while keeping saved suite, source, and target checks. Case files up to 16 MiB can be opened and rerun, including suites larger than 1 MiB written by the CLI. Comparisons show the first differing authored step for common cases when the suite and target match, even when a rerun omitted other cases.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ihyeon/flow-qa",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Hyeonse Im",
|
|
6
6
|
"repository": {
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"demo:serve": "node examples/demo/server.ts",
|
|
58
58
|
"demo:smoke": "node scripts/demo-smoke.ts",
|
|
59
59
|
"smoke:ui": "node scripts/ui-i18n-smoke.mjs && node scripts/ui-comparison-smoke.mjs && node scripts/ui-selection-smoke.mjs && node scripts/ui-rerun-smoke.mjs && node scripts/ui-history-smoke.mjs && node scripts/ui-archive-comparison-smoke.mjs && node scripts/ui-report-explorer-smoke.mjs && node scripts/ui-preferences-smoke.mjs",
|
|
60
|
-
"smoke:steps": "node scripts/step-comparison-smoke.mjs"
|
|
60
|
+
"smoke:steps": "node scripts/step-comparison-smoke.mjs",
|
|
61
|
+
"smoke:ios-tap": "node scripts/ios-tap-smoke.mjs"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"@ai-sdk/openai-compatible": "3.0.53",
|