@ihyeon/flow-qa 0.12.1 → 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 +4 -0
- package/README.md +2 -0
- package/dist/src/cli.js +11 -7
- package/dist/src/engine.js +7 -2
- package/dist/src/i18n.js +1 -0
- package/dist/src/ios-simulator-tap.js +142 -0
- package/dist/src/mobile-runtime.js +3 -2
- package/dist/src/saved-suites.js +59 -0
- package/dist/src/ui/server.js +23 -8
- package/dist/src/workspace.js +28 -2
- package/docs/mobile.md +4 -0
- package/docs/releases.md +8 -0
- package/docs/ui.md +1 -1
- package/package.json +3 -2
package/README.ko.md
CHANGED
|
@@ -86,6 +86,8 @@ CLI에서는 `flow-qa reruns .flowqa/runs/<원본-실행-ID> --workspace my-qa -
|
|
|
86
86
|
|
|
87
87
|
`flow-qa rerun .flowqa/runs/<원본-실행-ID> --workspace my-qa --lang ko`를 실행하면 원본에서 실패·실행 오류가 난 케이스만 원래 등록한 대상에 다시 실행합니다. 새 보고서에 원본 실행 ID가 남으므로 `reruns`와 `compare`에서 결과 변화를 볼 수 있습니다. 실패·오류 케이스가 없으면 새 실행을 만들지 않고 안내와 함께 정상 종료합니다. 저장된 케이스·원본 플로우·대상이 바뀌었다면 실행 전에 중단합니다. 각 케이스에는 독립적인 시작 상태가 필요합니다.
|
|
88
88
|
|
|
89
|
+
재실행할 케이스 JSON은 `cases/checkout/refunds.json`처럼 작업 공간의 `cases/` 아래에 저장하세요. CLI와 UI 케이스 보관함은 최대 16 MiB의 파일을 읽을 수 있습니다. 전체 실행과 부분 재실행의 명세 해시와 대상이 같으면 `compare`는 두 보고서에 있는 케이스의 단계 차이를 보여 주고 미선택 케이스를 미포함으로 표시합니다.
|
|
90
|
+
|
|
89
91
|
`0.8.0`부터 **상세 보고서**에서 케이스·오류 내용을 검색하고 상태별로 좁히거나 **실패·오류만** 볼 수 있습니다. **시도 2회 이상만 보기**(0.8.7)를 켜면 여러 번 시도한 케이스만 표시합니다. 표시 건수와 보고서 전체 케이스 수를 구분하며, Markdown·JSON 다운로드와 실패·오류 재실행 준비는 보고서 전체 범위를 유지합니다. 필터에 맞는 ID만 화면 순서대로 저장하려면 **표시된 케이스 ID 다운로드**(0.8.6)를 선택하세요. 자세한 동작은 [보고서 케이스 탐색](docs/ui.md#explore-cases-in-a-report)을 참고하세요.
|
|
90
92
|
|
|
91
93
|
## 실행 결과 비교
|
|
@@ -102,6 +104,8 @@ CLI에서는 `flow-qa reruns .flowqa/runs/<원본-실행-ID> --workspace my-qa -
|
|
|
102
104
|
|
|
103
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)를 참고하세요.
|
|
104
106
|
|
|
107
|
+
iPhone 시뮬레이터의 세로 화면에서 320×480 레거시 앱에 상하 여백이 생기면, Flow QA는 요소의 탭 위치를 실제 화면 좌표로 보정합니다. 전체 화면 앱은 기존 요소 탭을 사용합니다. 탭 다음 단계에서 실제 상태 변화를 확인할 수 있습니다.
|
|
108
|
+
|
|
105
109
|
## 설계 원칙과 결과 해석
|
|
106
110
|
|
|
107
111
|
- 케이스는 요구사항 ID와 명시적인 assertion을 가집니다. `open`, `click`, `fill`, `act`, `assertVisible`, `assertText`, `assertUrl`, `assertAgent` 등 허용된 단계만 스키마로 검증해 컴파일합니다. 모델 응답의 임의 JavaScript나 shell 명령은 실행하지 않습니다.
|
package/README.md
CHANGED
|
@@ -86,6 +86,8 @@ Direct reruns are ordered by their saved finish and start times. Add `--dry-run`
|
|
|
86
86
|
|
|
87
87
|
Run `flow-qa rerun .flowqa/runs/<original-run-id> --workspace my-qa` to execute only its failed and errored cases against the original registered target. The new report records the original run ID, so `reruns` and `compare` can show what changed. A report with no failed or errored cases prints a message and exits successfully without creating another run. If the saved cases, source flow, or target changed, the command stops before starting a run. Each case must establish its own starting state.
|
|
88
88
|
|
|
89
|
+
Keep rerunnable case JSON in the workspace's `cases/` tree, for example `cases/checkout/refunds.json`. CLI commands and the UI case library accept case files up to 16 MiB. When a full run and a partial rerun have the same suite hash and target, `compare` includes authored-step differences for cases recorded in both reports and marks unselected cases as `not included`.
|
|
90
|
+
|
|
89
91
|
From `0.8.0`, **Detailed report** supports case/error-text search, status filters, and **Failed/error only**. Use **At least 2 attempts** (0.8.7) to see only cases with multiple recorded attempts. Counts distinguish displayed matches from all recorded cases. Markdown/JSON downloads and failed/error preparation retain the full report scope. To save just the filtered IDs in the displayed order, choose **Download visible case IDs** (0.8.6). See [report case exploration](docs/ui.md#explore-cases-in-a-report).
|
|
90
92
|
|
|
91
93
|
## Compare recorded runs
|
package/dist/src/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolve, dirname, basename, join } from 'node:path';
|
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
7
|
import { localeFromEnv, localized, localizeProductMessage } from "./i18n.js";
|
|
8
|
-
import { configSchema, idSchema, modelSchema,
|
|
8
|
+
import { configSchema, idSchema, modelSchema, targetSchema } from "./schema.js";
|
|
9
9
|
import { initWorkspace, readConfig, readSuite, sha256, verifySuiteSource, withConfigLock, writeConfig, writeJSON } from "./workspace.js";
|
|
10
10
|
import { buildPlanningPrompt, planFlow } from "./planner.js";
|
|
11
11
|
import { compileSuite } from "./compiler.js";
|
|
@@ -13,6 +13,7 @@ import { CaseSelectionError, isReportSelectionValid, selectCases } from "./case-
|
|
|
13
13
|
import { runSuite } from "./engine.js";
|
|
14
14
|
import { MAX_SAVED_REPORT_BYTES, RUN_ID, parseArchivedReportEnvelope, renderSavedMarkdown } from "./report.js";
|
|
15
15
|
import { prepareRerunSelection } from "./rerun.js";
|
|
16
|
+
import { savedCaseFilePath, savedCaseFiles } from "./saved-suites.js";
|
|
16
17
|
import { registrationTarget, sameReportTarget, targetLabel } from "./targets.js";
|
|
17
18
|
import { compareCaseSteps } from "./step-comparison.js";
|
|
18
19
|
import { createAgentHandoff, reviewAgentHandoff } from "./agent-handoff.js";
|
|
@@ -429,11 +430,12 @@ export async function main(args) {
|
|
|
429
430
|
const casesRoot = await safeWorkspaceDirectory(canonicalWorkspace, ['cases']);
|
|
430
431
|
const matches = [];
|
|
431
432
|
const flowRoots = [join(canonicalWorkspace, 'flows'), join(workspace, 'flows')];
|
|
432
|
-
for (const file of
|
|
433
|
-
if (!SAFE_CASE_NAME.test(file) || file.includes('..') || !file.endsWith('.json'))
|
|
434
|
-
continue;
|
|
433
|
+
for await (const file of savedCaseFiles(casesRoot)) {
|
|
435
434
|
try {
|
|
436
|
-
const
|
|
435
|
+
const path = await savedCaseFilePath(casesRoot, file);
|
|
436
|
+
if (!path)
|
|
437
|
+
continue;
|
|
438
|
+
const suite = await readSuite(path, true);
|
|
437
439
|
savedFlowName(suite, flowRoots);
|
|
438
440
|
if (suite.id === previous.suiteId)
|
|
439
441
|
matches.push({ file, suite });
|
|
@@ -528,7 +530,9 @@ export async function main(args) {
|
|
|
528
530
|
throw new Error(localized(locale, 'A comparison needs two different runs.', '서로 다른 두 실행을 선택해야 합니다.'));
|
|
529
531
|
}
|
|
530
532
|
const sameSelection = JSON.stringify(before.cases.map((item) => item.id).sort()) === JSON.stringify(after.cases.map((item) => item.id).sort());
|
|
531
|
-
const
|
|
533
|
+
const sameSuiteAndTarget = before.suiteId === after.suiteId && Boolean(before.suiteHash.trim())
|
|
534
|
+
&& before.suiteHash === after.suiteHash && sameReportTarget(before.target, after.target);
|
|
535
|
+
const comparable = sameSuiteAndTarget && sameSelection;
|
|
532
536
|
console.log(comparable ? localized(locale, 'Comparing the same suite, target and case selection (check external data state separately)', '동일 명세·대상·케이스 범위 비교 (외부 데이터 상태는 별도 확인)') : localized(locale, 'Suite, target or case selection differs; no direct regression verdict is made.', '명세·대상 또는 케이스 범위가 달라 직접적인 회귀 판정은 하지 않습니다.'));
|
|
533
537
|
if (before.selection || after.selection)
|
|
534
538
|
console.log(localized(locale, 'This comparison includes selected cases only; omitted cases were not evaluated.', '이 비교에는 선택 실행이 포함되어 있습니다. 미선택 케이스는 검증되지 않았습니다.'));
|
|
@@ -538,7 +542,7 @@ export async function main(args) {
|
|
|
538
542
|
const baselineCase = previous.get(id);
|
|
539
543
|
const currentCase = current.get(id);
|
|
540
544
|
console.log(`${safeText(id)}: ${safeText(baselineCase?.status ?? localized(locale, 'not included', '미포함'))} → ${safeText(currentCase?.status ?? localized(locale, 'not included', '미포함'))}`);
|
|
541
|
-
if (!
|
|
545
|
+
if (!sameSuiteAndTarget || !baselineCase || !currentCase)
|
|
542
546
|
continue;
|
|
543
547
|
const steps = compareCaseSteps(baselineCase, currentCase, true);
|
|
544
548
|
if (steps.availability !== 'compared')
|
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)},
|
package/dist/src/i18n.js
CHANGED
|
@@ -51,6 +51,7 @@ const koreanMessages = {
|
|
|
51
51
|
'Only JSON requests are supported.': 'JSON 요청만 사용할 수 있습니다.',
|
|
52
52
|
'The request body is too large.': '요청 본문이 너무 큽니다.',
|
|
53
53
|
'The saved case file is too large.': '저장할 케이스 파일이 너무 큽니다.',
|
|
54
|
+
'The case file exceeds the 16 MiB limit.': '케이스 파일은 최대 16 MiB까지 지원합니다.',
|
|
54
55
|
'Invalid workspace path.': '작업 공간 경로가 올바르지 않습니다.',
|
|
55
56
|
'Could not read the Flow QA configuration.': 'Flow QA 설정을 읽을 수 없습니다.',
|
|
56
57
|
'Invalid configuration file path.': '설정 파일 경로가 올바르지 않습니다.',
|
|
@@ -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';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { lstat, readdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const CASE_PATH_PART = /^[\p{L}\p{N}][\p{L}\p{N}\p{M}._ -]{0,159}$/u;
|
|
4
|
+
function isCasePathPart(part) {
|
|
5
|
+
return CASE_PATH_PART.test(part) && !part.includes('..') && !/[. ]$/.test(part);
|
|
6
|
+
}
|
|
7
|
+
export function isSavedCaseFile(file) {
|
|
8
|
+
return file.endsWith('.json') && file.split('/').every(isCasePathPart);
|
|
9
|
+
}
|
|
10
|
+
async function regularCaseEntry(path, directory) {
|
|
11
|
+
try {
|
|
12
|
+
const info = await lstat(path);
|
|
13
|
+
return (directory ? info.isDirectory() : info.isFile()) && await realpath(path) === path;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error.code === 'ENOENT')
|
|
17
|
+
return false;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Resolve only local regular entries beneath a verified cases directory. */
|
|
22
|
+
export async function savedCaseFilePath(root, file) {
|
|
23
|
+
if (!isSavedCaseFile(file))
|
|
24
|
+
return undefined;
|
|
25
|
+
const parts = file.split('/');
|
|
26
|
+
const name = parts.pop();
|
|
27
|
+
let directory = root;
|
|
28
|
+
for (const part of parts) {
|
|
29
|
+
directory = join(directory, part);
|
|
30
|
+
if (!await regularCaseEntry(directory, true))
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const path = join(directory, name);
|
|
34
|
+
return await regularCaseEntry(path, false) ? path : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Use forward slashes in the CLI and UI library on every platform. */
|
|
37
|
+
export async function* savedCaseFiles(root, prefix = '') {
|
|
38
|
+
const directory = join(root, prefix);
|
|
39
|
+
let entries;
|
|
40
|
+
try {
|
|
41
|
+
if (!await regularCaseEntry(directory, true))
|
|
42
|
+
return;
|
|
43
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (prefix && ['ENOENT', 'ENOTDIR', 'EACCES', 'EPERM'].includes(error.code ?? ''))
|
|
47
|
+
return;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
for (const item of entries) {
|
|
51
|
+
if (!isCasePathPart(item.name))
|
|
52
|
+
continue;
|
|
53
|
+
const file = prefix ? `${prefix}/${item.name}` : item.name;
|
|
54
|
+
if (item.isDirectory())
|
|
55
|
+
yield* savedCaseFiles(root, file);
|
|
56
|
+
if (item.isFile() && file.endsWith('.json'))
|
|
57
|
+
yield file;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/dist/src/ui/server.js
CHANGED
|
@@ -22,14 +22,14 @@ import { EvidenceError, readEvidence } from "./evidence.js";
|
|
|
22
22
|
import { buildPlanningPrompt, planFlow, PlannerError } from "../planner.js";
|
|
23
23
|
import { MAX_SAVED_REPORT_BYTES, RUN_ID, parseArchivedReportEnvelope, renderSavedMarkdown } from "../report.js";
|
|
24
24
|
import { prepareRerunSelection } from "../rerun.js";
|
|
25
|
+
import { isSavedCaseFile, savedCaseFilePath, savedCaseFiles } from "../saved-suites.js";
|
|
25
26
|
import { compareReports, ComparisonError, renderComparisonMarkdown } from "../run-comparison.js";
|
|
26
27
|
import { configSchema, idSchema, modelSchema, suiteSchema, targetSchema } from "../schema.js";
|
|
27
28
|
import { registrationTarget, targetFingerprint } from "../targets.js";
|
|
28
|
-
import { CONFIG_FILE, sha256, withConfigLock } from "../workspace.js";
|
|
29
|
+
import { CONFIG_FILE, MAX_SUITE_BYTES, readSuiteText, sha256, SuiteSizeError, withConfigLock } from "../workspace.js";
|
|
29
30
|
const MAX_BODY = 256 * 1024;
|
|
30
31
|
const MAX_FLOW = 128 * 1024;
|
|
31
32
|
const MAX_CONFIG = 256 * 1024;
|
|
32
|
-
const MAX_SUITE = 1024 * 1024; // Includes indentation added when saving validated request data.
|
|
33
33
|
const MAX_REPORT = MAX_SAVED_REPORT_BYTES;
|
|
34
34
|
const MAX_STATIC = 4 * 1024 * 1024;
|
|
35
35
|
const PLAN_TIMEOUT_MS = 65_000;
|
|
@@ -381,12 +381,28 @@ export async function startUIServer(options) {
|
|
|
381
381
|
}
|
|
382
382
|
return compileSuite(suite, target);
|
|
383
383
|
}
|
|
384
|
+
async function savedSuite(root, file) {
|
|
385
|
+
if (!isSavedCaseFile(file))
|
|
386
|
+
invalid('Invalid file name.');
|
|
387
|
+
const entry = await savedCaseFilePath(root, file);
|
|
388
|
+
if (!entry)
|
|
389
|
+
notFound();
|
|
390
|
+
try {
|
|
391
|
+
return parse(suiteSchema, jsonObject(await readSuiteText(entry, true)));
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if (error instanceof SuiteSizeError)
|
|
395
|
+
throw new HTTPError(413, error.message);
|
|
396
|
+
if (error.code === 'ENOENT')
|
|
397
|
+
notFound();
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
384
401
|
async function getSuite(file, verify = false, targetName) {
|
|
385
|
-
safeBasename(file, '.json');
|
|
386
402
|
const root = await directory(['cases']);
|
|
387
403
|
if (!root)
|
|
388
404
|
notFound();
|
|
389
|
-
const suite =
|
|
405
|
+
const suite = await savedSuite(root, file);
|
|
390
406
|
const flow = await readSource(suite, verify);
|
|
391
407
|
return { suite, suiteHash: sha256(JSON.stringify(suite)), script: await compileForTarget(suite, targetName), ...(flow === undefined ? {} : { flow }) };
|
|
392
408
|
}
|
|
@@ -394,11 +410,10 @@ export async function startUIServer(options) {
|
|
|
394
410
|
const root = await directory(['cases']);
|
|
395
411
|
if (!root)
|
|
396
412
|
return [];
|
|
397
|
-
const files = (await readdir(root)).filter((name) => FILE_NAME.test(name) && !name.includes('..') && name.endsWith('.json'));
|
|
398
413
|
const summaries = [];
|
|
399
|
-
for (const file of
|
|
414
|
+
for await (const file of savedCaseFiles(root)) {
|
|
400
415
|
try {
|
|
401
|
-
const suite =
|
|
416
|
+
const suite = await savedSuite(root, file);
|
|
402
417
|
sourceName(suite, workspaceFlowRoots);
|
|
403
418
|
summaries.push({ file, id: suite.id, title: suite.title, caseCount: suite.cases.length,
|
|
404
419
|
questionCount: suite.cases.reduce((count, testCase) => count + testCase.questions.length, 0) });
|
|
@@ -835,7 +850,7 @@ export async function startUIServer(options) {
|
|
|
835
850
|
? suiteSchema.parse({ ...inputSuite, source: { file: `flows/${source.file}`, sha256: sha256(source.flow) } })
|
|
836
851
|
: inputSuite;
|
|
837
852
|
const content = `${JSON.stringify(suite, null, 2)}\n`;
|
|
838
|
-
if (Buffer.byteLength(content) >
|
|
853
|
+
if (Buffer.byteLength(content) > MAX_SUITE_BYTES)
|
|
839
854
|
throw new HTTPError(413, 'The saved case file is too large.');
|
|
840
855
|
const casesRoot = await directory(['cases'], true);
|
|
841
856
|
if (!casesRoot)
|
package/dist/src/workspace.js
CHANGED
|
@@ -5,6 +5,8 @@ import { createHash, randomUUID } from 'node:crypto';
|
|
|
5
5
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
6
|
import { configSchema, suiteSchema } from "./schema.js";
|
|
7
7
|
export const CONFIG_FILE = 'flowqa.config.json';
|
|
8
|
+
export const MAX_SUITE_BYTES = 16 * 1024 * 1024;
|
|
9
|
+
export const SUITE_SIZE_MESSAGE = 'The case file exceeds the 16 MiB limit.';
|
|
8
10
|
const localConfigWriters = new Map();
|
|
9
11
|
/** Serialize read-modify-write changes from CLI processes and the local UI. */
|
|
10
12
|
export async function withConfigLock(workspace, change, allowSymlink = true) {
|
|
@@ -99,8 +101,32 @@ export async function readConfig(workspace) {
|
|
|
99
101
|
throw error;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
+
export class SuiteSizeError extends Error {
|
|
105
|
+
constructor() { super(SUITE_SIZE_MESSAGE); }
|
|
106
|
+
}
|
|
107
|
+
export async function readSuiteText(path, noFollow = false) {
|
|
108
|
+
const flags = constants.O_RDONLY | (noFollow && process.platform !== 'win32' ? constants.O_NOFOLLOW : 0);
|
|
109
|
+
const handle = await open(path, flags);
|
|
110
|
+
try {
|
|
111
|
+
const info = await handle.stat();
|
|
112
|
+
if (!info.isFile())
|
|
113
|
+
throw new Error('Invalid case file.');
|
|
114
|
+
if (info.size > MAX_SUITE_BYTES)
|
|
115
|
+
throw new SuiteSizeError();
|
|
116
|
+
const chunks = [];
|
|
117
|
+
for await (const chunk of handle.createReadStream({ autoClose: false, end: MAX_SUITE_BYTES }))
|
|
118
|
+
chunks.push(chunk);
|
|
119
|
+
const content = Buffer.concat(chunks);
|
|
120
|
+
if (content.length > MAX_SUITE_BYTES)
|
|
121
|
+
throw new SuiteSizeError();
|
|
122
|
+
return content.toString('utf8');
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await handle.close();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export async function readSuite(path, noFollow = false) {
|
|
129
|
+
return suiteSchema.parse(JSON.parse(await readSuiteText(path, noFollow)));
|
|
104
130
|
}
|
|
105
131
|
export async function writeJSON(path, data, exclusive = false) {
|
|
106
132
|
await mkdir(dirname(path), { recursive: true });
|
package/docs/mobile.md
CHANGED
|
@@ -36,6 +36,10 @@ 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
|
+
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.
|
|
42
|
+
|
|
39
43
|
## Native steps
|
|
40
44
|
|
|
41
45
|
| Step | Behavior |
|
package/docs/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
7
|
+
## 0.12.2 — reopen nested case files and compare partial reruns
|
|
8
|
+
|
|
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.
|
|
10
|
+
|
|
3
11
|
## 0.12.1 — keep run history stable when an archive changes
|
|
4
12
|
|
|
5
13
|
The local UI orders saved runs by the report's recorded finish time and start time. Adding a note or copying an archive leaves the order and pagination unchanged. Undated reports remain available at the end of the list.
|
package/docs/ui.md
CHANGED
|
@@ -62,7 +62,7 @@ From version `0.2.8`, **Expand all cases** and **Collapse all cases** control th
|
|
|
62
62
|
|
|
63
63
|
### Search saved cases
|
|
64
64
|
|
|
65
|
-
From version `0.2.6`, **Case library** filters saved suites as you type in **Search saved suites**. Search matches part of a title, suite ID, or file
|
|
65
|
+
From version `0.2.6`, **Case library** filters saved suites as you type in **Search saved suites**. Search matches part of a title, suite ID, or file path, ignores letter case and surrounding whitespace, and supports Korean text. Clear the field to show all suites. The query stays while navigating, changing language, or receiving updated saved cases; it resets when the page reloads. From `0.12.2`, the library includes subfolders of `cases/` and opens saved case JSON files up to 16 MiB. The separate browser import form has the request limits described below.
|
|
66
66
|
|
|
67
67
|
### Filter run history
|
|
68
68
|
|
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",
|