@aarwitz/tapp 0.35.7 → 0.35.9

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.
@@ -66,6 +66,40 @@ function targetCandidates(scope, target) {
66
66
  ];
67
67
  }
68
68
 
69
+ // TM-1077: a file input for `upload:`. Visibility-agnostic on purpose — a file
70
+ // picker is routinely a real <input type=file> hidden behind a styled label or
71
+ // button (opacity/position, never display:none, which browsers refuse to let
72
+ // choose a file at all), and Playwright's setInputFiles works on it either way.
73
+ // locateWebElement's firstVisible() would skip it, so this never calls it.
74
+ async function locateFileInput(page, target) {
75
+ const candidates = [
76
+ page.getByTestId(target),
77
+ page.locator(cssId(target)),
78
+ page.getByLabel(target, { exact: true }),
79
+ page.getByLabel(target),
80
+ ];
81
+ for (const locator of candidates) {
82
+ try {
83
+ const first = locator.first();
84
+ if ((await first.count()) === 0) continue;
85
+ const tag = await first.evaluate((el) => el.tagName).catch(() => "");
86
+ if (tag === "INPUT") {
87
+ const type = (await first.getAttribute("type").catch(() => "")) || "";
88
+ if (!type || type.toLowerCase() === "file") return first;
89
+ continue;
90
+ }
91
+ // A styled label/button that wraps the real input rather than being it.
92
+ const inner = first.locator("input[type=file]").first();
93
+ if ((await inner.count()) > 0) return inner;
94
+ } catch { /* try the next candidate */ }
95
+ }
96
+ // Last resort: the page's one file input, when the target names it (id, name,
97
+ // aria-label, nearby text) in a way none of the semantic locators matched.
98
+ const only = page.locator("input[type=file]");
99
+ if ((await only.count().catch(() => 0)) === 1) return only.first();
100
+ return null;
101
+ }
102
+
69
103
  export async function locateWebElement(page, target) {
70
104
  const top = await firstVisible(targetCandidates(page, target));
71
105
  if (top) return top;
@@ -203,7 +237,7 @@ export function distillPlaywrightFailure(message) {
203
237
  return `${firstLine} — ${reason}`;
204
238
  }
205
239
 
206
- export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout = DEFAULT_TIMEOUT, stepScreenshotDir = "" }) {
240
+ export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout = DEFAULT_TIMEOUT, stepScreenshotDir = "", flowDir = "" }) {
207
241
  const raw = normalizeFlowStep(step);
208
242
  const action = raw.action;
209
243
  const target = substituteFlowValue(raw.target, vars);
@@ -349,6 +383,22 @@ export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout
349
383
  }
350
384
  } else if (action === "back") {
351
385
  await page.goBack({ waitUntil: "domcontentloaded" });
386
+ } else if (action === "open_url") {
387
+ // A journey starting from an email link ("tap the sign-in link in your receipt") is just a
388
+ // navigation on web — the one-time part of the link substitutes like any other target.
389
+ await page.goto(target, { waitUntil: "domcontentloaded" });
390
+ } else if (action === "upload") {
391
+ // TM-1077: an admin "Import contacts" page (and certificate/newsletter uploads) starts
392
+ // with choosing a local file — the only way to replay that journey as a committed Flow
393
+ // from the start. The path is relative to the Flow file, not wherever `tapp run` happened
394
+ // to be invoked from, so a Flow stays correct wherever it's checked out.
395
+ const filePath = substituteFlowValue(String(raw.params.file ?? ""), vars);
396
+ if (!filePath) throw new Error("upload needs {field, file}");
397
+ const resolved = path.isAbsolute(filePath) ? filePath : path.resolve(flowDir || process.cwd(), filePath);
398
+ if (!fs.existsSync(resolved)) throw new Error(`upload file not found: ${resolved}`);
399
+ const input = await locateFileInput(page, target);
400
+ if (!input) throw new Error(`could not find a file picker for ‘${target}’`);
401
+ await input.setInputFiles(resolved);
352
402
  } else if (action === "wait_for") {
353
403
  if (!await waitForScreen(page, target, timeout)) throw new Error(`‘${target}’ never appeared within ${timeout}ms${await visibleLabelsHint(page)}`);
354
404
  } else if (action === "wait") {
@@ -418,14 +468,17 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
418
468
  const declaredUrl = flow.url || (/^https?:\/\//i.test(flow.app || "") ? flow.app : "");
419
469
  const startUrl = urlIsFallback ? resolveGateFlowUrl(declaredUrl, url) : (url || declaredUrl);
420
470
  if (!startUrl) throw new Error("Web Flow needs `url:` (or an http(s) `app:` value)");
471
+ // TM-1077: an `upload:` step's file path is relative to the Flow file (stamped
472
+ // on it by loadFlowFile), not the directory `tapp run` happened to be invoked from.
473
+ const flowDir = flow.sourcePath ? path.dirname(flow.sourcePath) : process.cwd();
421
474
  if (logPath) fs.rmSync(logPath, { force: true });
422
475
  const setup = flow.setup || [];
423
476
  const teardown = flow.teardown || [];
424
477
  const loggedFlow = { ...flow, steps: [...setup, ...flow.steps, ...teardown] };
425
478
  const log = new FlowLog({ logPath, flow: loggedFlow });
426
479
  const pw = playwright || await loadPlaywright();
427
- const { webBrowserLaunchOptions } = await import("./web-explorer.js");
428
- const browser = await pw.chromium.launch(webBrowserLaunchOptions());
480
+ const { webBrowserLaunchOptions, launchWebBrowser } = await import("./web-explorer.js");
481
+ const browser = await launchWebBrowser(pw.chromium, webBrowserLaunchOptions());
429
482
  const contextOptions = webContextOptions({ device, viewport, devices: pw.devices });
430
483
  // Without an explicit size Playwright fits the recording into 800px, so a replay filmed at a
431
484
  // desktop viewport came out small and soft however large the window was. Film at the size the
@@ -470,7 +523,7 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
470
523
  emit({action:"origin",target:"connected app",status:"fail",detail:"The workflow left the connected app origin. Authorize a supported sign-in route before continuing."});
471
524
  break;
472
525
  }
473
- const outcome = await executeWebFlowStep({ page, step, vars, defaultTimeout: timeout, stepScreenshotDir: screenshotDir });
526
+ const outcome = await executeWebFlowStep({ page, step, vars, defaultTimeout: timeout, stepScreenshotDir: screenshotDir, flowDir });
474
527
  emit(outcome);
475
528
  if (outcome.status === "fail" && screenshotDir) {
476
529
  fs.mkdirSync(screenshotDir, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.35.7",
3
+ "version": "0.35.9",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",
@@ -98,7 +98,7 @@
98
98
  "mobile"
99
99
  ],
100
100
  "scripts": {
101
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/flow-variables.test.js tests/flow-recording.test.js tests/sim-recorder.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-run-reading.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/platforms.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
101
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/flow-variables.test.js tests/flow-recording.test.js tests/sim-recorder.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/engines.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/macos-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-run-reading.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/platforms.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
102
102
  "test:browser-journey": "node --test tests/browser-journey.test.js",
103
103
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
104
104
  }
@@ -374,7 +374,7 @@ xcrun simctl install "$UDID" "$APP_PATH" || { echo "❌ simctl install failed
374
374
  # ── Autonomous exploration (quick-capture builds the harness itself if needed).
375
375
  # --actions 0 = flows-only: the reviewed suites are the whole deterministic surface. No
376
376
  # explorer touches the app — the point, for targets wired to production backends (#11).
377
- CAPTURE_ROOT="${TAPP_HOME:-$ROOT}/captures"
377
+ CAPTURE_ROOT="${TAPP_HOME:-$HOME/.tapp}/captures" # never the repository (TM-651)
378
378
  mkdir -p "$CAPTURE_ROOT"
379
379
  CAPTURE_DIR="$(mktemp -d "$CAPTURE_ROOT/ci.XXXXXX")"
380
380
  MARKERS=""
@@ -18,16 +18,16 @@ PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
18
18
  # TAPP_CAPTURE_DIR selects one exact run directory (used by CI so a failed run can never
19
19
  # accidentally reuse stale markers). TAPP_HOME redirects all writable output otherwise —
20
20
  # set by the `tapp` CLI when running as an installed npm package, where the package dir
21
- # must stay read-only. Unset (repo dev flow), everything lands in the repo as before.
22
- TAPP_RUNTIME_HOME="${TAPP_HOME:-}"
21
+ # must stay read-only. Unset (a run from a source checkout), evidence still goes to
22
+ # ~/.tapp/captures like everywhere else in Tapp (TM-651): never into the repository,
23
+ # where the evidence clearing-out (evidence-retention.js) never looks.
24
+ TAPP_RUNTIME_HOME="${TAPP_HOME:-$HOME/.tapp}"
23
25
  if [[ -n "${TAPP_CAPTURE_DIR:-}" ]]; then
24
26
  CAPTURE_DIR="$TAPP_CAPTURE_DIR"
25
- elif [[ -n "$TAPP_RUNTIME_HOME" ]]; then
26
- CAPTURE_DIR="$TAPP_RUNTIME_HOME/captures/ios-$(date +%Y%m%d-%H%M%S)"
27
27
  else
28
- CAPTURE_DIR="$PROJECT_ROOT/captures/ios-$(date +%Y%m%d-%H%M%S)"
28
+ CAPTURE_DIR="$TAPP_RUNTIME_HOME/captures/ios-$(date +%Y%m%d-%H%M%S)"
29
29
  fi
30
- if [[ -n "$TAPP_RUNTIME_HOME" ]]; then
30
+ if [[ -n "${TAPP_HOME:-}" ]]; then
31
31
  HARNESS_DERIVED="$TAPP_RUNTIME_HOME/harness-derived"
32
32
  else
33
33
  HARNESS_DERIVED="/tmp/tapp-harness-derived"
@@ -104,24 +104,44 @@ ensure_harness_built() {
104
104
  fi
105
105
  echo "Preparing harness for $sim_name (source, simulator, or Xcode cache changed)..." >&2
106
106
  local src_fp=$(harness_fingerprint)
107
- mkdir -p "$HARNESS_DERIVED/Build/Products"
108
- rm -f "$marker"
109
- # Xcode leaves old SDK descriptors beside the new one. Only the descriptor emitted by
110
- # this successful build may become current; never select an arbitrary directory entry.
111
- find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f -delete
112
- xcodebuild build-for-testing \
113
- -project "$HARNESS_PROJECT" \
114
- -scheme OCQAHarnessUITests \
115
- -destination "platform=iOS Simulator,id=$UDID" \
116
- -derivedDataPath "$HARNESS_DERIVED" \
117
- 2>&1 | tail -5 >&2
118
- local products=()
119
- while IFS= read -r product; do products+=("$product"); done < <(find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f)
120
- if [[ ${#products[@]} -ne 1 ]]; then
121
- echo "ERROR: Harness build produced ${#products[@]} test descriptors; no cache was selected." >&2
122
- return 1
123
- fi
124
- printf '%s\n%s\n%s\n' "$udid" "$src_fp" "$(basename "${products[0]}")" > "$marker"
107
+ # TM-973: a build-for-testing into ~/.tapp/harness-derived has failed with
108
+ # errors that only show up under disk/memory pressure ("disk I/O error" on
109
+ # XCBuildData/build.db) — an identical build into a FRESH derived-data
110
+ # folder succeeds. One retry from a clean folder recovers from that, and
111
+ # the full log (not just xcodebuild's own tail) names what actually failed
112
+ # when both attempts fail, instead of a bare "(5 failures)".
113
+ local log_dir; log_dir="$(dirname "$HARNESS_DERIVED")"
114
+ mkdir -p "$log_dir"
115
+ local build_log build_rc attempt products
116
+ for attempt in 1 2; do
117
+ mkdir -p "$HARNESS_DERIVED/Build/Products"
118
+ rm -f "$marker"
119
+ # Xcode leaves old SDK descriptors beside the new one. Only the descriptor emitted by
120
+ # this successful build may become current; never select an arbitrary directory entry.
121
+ find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f -delete
122
+ build_log="$log_dir/harness-build-attempt-$attempt.log"
123
+ build_rc=0
124
+ xcodebuild build-for-testing \
125
+ -project "$HARNESS_PROJECT" \
126
+ -scheme OCQAHarnessUITests \
127
+ -destination "platform=iOS Simulator,id=$UDID" \
128
+ -derivedDataPath "$HARNESS_DERIVED" \
129
+ > "$build_log" 2>&1 || build_rc=$?
130
+ tail -5 "$build_log" >&2
131
+ products=()
132
+ while IFS= read -r product; do products+=("$product"); done < <(find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f 2>/dev/null)
133
+ if [[ $build_rc -eq 0 && ${#products[@]} -eq 1 ]]; then
134
+ printf '%s\n%s\n%s\n' "$udid" "$src_fp" "$(basename "${products[0]}")" > "$marker"
135
+ return 0
136
+ fi
137
+ if [[ $attempt -eq 1 ]]; then
138
+ echo "Harness build failed (exit $build_rc, ${#products[@]} test descriptor(s)); deleting $HARNESS_DERIVED and retrying once into a clean folder..." >&2
139
+ rm -rf "$HARNESS_DERIVED"
140
+ fi
141
+ done
142
+ echo "ERROR: Harness build failed twice (exit $build_rc, ${#products[@]} test descriptor(s) produced). Full log: $build_log" >&2
143
+ grep -i "error:" "$build_log" >&2 || tail -20 "$build_log" >&2
144
+ return 1
125
145
  }
126
146
 
127
147
  run_harness_test() {