@quiesco/core 0.10.0 → 0.12.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.
Files changed (43) hide show
  1. package/dist/config.d.ts +10 -3
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -0
  4. package/dist/config.js.map +1 -1
  5. package/dist/device.d.ts +5 -0
  6. package/dist/device.d.ts.map +1 -1
  7. package/dist/device.js +48 -2
  8. package/dist/device.js.map +1 -1
  9. package/dist/devices/ios-runner.d.ts +10 -1
  10. package/dist/devices/ios-runner.d.ts.map +1 -1
  11. package/dist/devices/ios-runner.js +17 -6
  12. package/dist/devices/ios-runner.js.map +1 -1
  13. package/dist/devices/ios.d.ts +18 -1
  14. package/dist/devices/ios.d.ts.map +1 -1
  15. package/dist/devices/ios.js +98 -28
  16. package/dist/devices/ios.js.map +1 -1
  17. package/dist/devices/provider.d.ts +15 -0
  18. package/dist/devices/provider.d.ts.map +1 -1
  19. package/dist/driver.d.ts.map +1 -1
  20. package/dist/driver.js +13 -3
  21. package/dist/driver.js.map +1 -1
  22. package/dist/server/ws-server.d.ts +1 -0
  23. package/dist/server/ws-server.d.ts.map +1 -1
  24. package/dist/server/ws-server.js +2 -0
  25. package/dist/server/ws-server.js.map +1 -1
  26. package/dist/session.d.ts +0 -2
  27. package/dist/session.d.ts.map +1 -1
  28. package/dist/session.js +13 -2
  29. package/dist/session.js.map +1 -1
  30. package/dist/timeline.d.ts +17 -0
  31. package/dist/timeline.d.ts.map +1 -1
  32. package/dist/timeline.js +56 -10
  33. package/dist/timeline.js.map +1 -1
  34. package/package.json +2 -2
  35. package/src/config.ts +11 -3
  36. package/src/device.ts +44 -2
  37. package/src/devices/ios-runner.ts +19 -6
  38. package/src/devices/ios.ts +108 -27
  39. package/src/devices/provider.ts +15 -0
  40. package/src/driver.ts +11 -3
  41. package/src/server/ws-server.ts +2 -0
  42. package/src/session.ts +14 -1
  43. package/src/timeline.ts +62 -10
package/dist/timeline.js CHANGED
@@ -1,10 +1,20 @@
1
+ /** Said with the native calls an action did not wait for (issue #94). */
2
+ export const NOT_COUNTED_NOTE = 'pending when the call returned, not waited for: the native-module tracker is off';
3
+ /** What a call still running when the timeline is written says (issue #84). */
4
+ export const STILL_RUNNING = 'still running when the scenario ended (the test ended it first: its timeout?)';
1
5
  export class Timeline {
2
6
  entries = [];
7
+ /** Calls not returned yet, with the steps the agent reported so far (issue #84). */
8
+ running = [];
9
+ /** Bumped by reset: a call of an earlier scenario that returns late does not land in this one. */
10
+ generation = 0;
3
11
  started = Date.now();
4
12
  name = '';
5
13
  /** Start a new scenario's timeline. */
6
14
  reset(name) {
7
15
  this.entries = [];
16
+ this.running = [];
17
+ this.generation++;
8
18
  this.started = Date.now();
9
19
  this.name = name;
10
20
  }
@@ -17,28 +27,57 @@ export class Timeline {
17
27
  /** Measure `fn` as one entry. */
18
28
  async measure(method, label, fn, timing) {
19
29
  const start = Date.now();
30
+ const running = { method, label, start, end: start, steps: [] };
31
+ this.running.push(running);
32
+ const generation = this.generation;
33
+ const add = (entry) => {
34
+ if (generation === this.generation)
35
+ this.add(entry);
36
+ };
20
37
  try {
21
38
  const r = await fn();
22
39
  const t = timing?.(r);
23
- this.add({ method, label, start, end: Date.now(), ...(t?.syncMs !== undefined ? { syncMs: t.syncMs } : {}), ...(t?.steps !== undefined && t.steps.length > 0 ? { steps: t.steps } : {}) });
40
+ add({
41
+ method,
42
+ label,
43
+ start,
44
+ end: Date.now(),
45
+ ...(t?.syncMs !== undefined ? { syncMs: t.syncMs } : {}),
46
+ ...(t?.syncBusy !== undefined && t.syncBusy.length > 0 ? { syncBusy: t.syncBusy } : {}),
47
+ ...(t?.nativeCallsNotCounted !== undefined && t.nativeCallsNotCounted.length > 0 ? { nativeCallsNotCounted: t.nativeCallsNotCounted } : {}),
48
+ ...(t?.steps !== undefined && t.steps.length > 0 ? { steps: t.steps } : {}),
49
+ });
24
50
  return r;
25
51
  }
26
52
  catch (e) {
27
53
  // A multi-step action that failed still reports its steps (issue #78).
28
54
  const steps = e?.data?.steps;
29
- this.add({ method, label, start, end: Date.now(), ...(Array.isArray(steps) && steps.length > 0 ? { steps: steps } : {}), error: e instanceof Error ? e.message : String(e) });
55
+ add({ method, label, start, end: Date.now(), ...(Array.isArray(steps) && steps.length > 0 ? { steps: steps } : {}), error: e instanceof Error ? e.message : String(e) });
30
56
  throw e;
31
57
  }
58
+ finally {
59
+ this.running = this.running.filter((r) => r !== running);
60
+ }
61
+ }
62
+ /** A step of the running call (calls to the agent run one at a time), reported before it returns (issue #84). */
63
+ step(s) {
64
+ this.running.at(-1)?.steps?.push(s);
32
65
  }
66
+ /** The calls, then those still running (ending now, with the steps so far). */
33
67
  get all() {
34
- return this.entries;
68
+ if (this.running.length === 0)
69
+ return this.entries;
70
+ const now = Date.now();
71
+ return [...this.entries, ...this.running.map(({ steps, ...r }) => ({ ...r, end: now, ...(steps !== undefined && steps.length > 0 ? { steps: [...steps] } : {}), error: STILL_RUNNING }))];
35
72
  }
36
73
  /** Chrome trace event format: complete events ("X"), sync waits nested inside their calls. */
37
74
  toTrace() {
38
75
  const us = (t) => Math.round((t - this.started) * 1000);
39
76
  const events = [{ name: 'process_name', ph: 'M', pid: 1, tid: 1, args: { name: `Quiesco: ${this.name}` } }];
40
- for (const e of this.entries) {
41
- events.push({ name: `${e.method} ${e.label}`.trim(), cat: e.method, ph: 'X', ts: us(e.start), dur: Math.max(1, us(e.end) - us(e.start)), pid: 1, tid: 1, args: e.error !== undefined ? { error: e.error } : {} });
77
+ for (const e of this.all) {
78
+ const args = { ...(e.error !== undefined ? { error: e.error } : {}), ...(e.nativeCallsNotCounted !== undefined ? { nativeCallsNotCounted: e.nativeCallsNotCounted, note: NOT_COUNTED_NOTE } : {}) };
79
+ events.push({ name: `${e.method} ${e.label}`.trim(), cat: e.method, ph: 'X', ts: us(e.start), dur: Math.max(1, us(e.end) - us(e.start)), pid: 1, tid: 1, args });
80
+ const busy = e.syncBusy !== undefined ? { busy: e.syncBusy } : {};
42
81
  if (e.steps !== undefined) {
43
82
  e.steps.forEach((s, i) => {
44
83
  const ts = us(e.start + s.atMs);
@@ -48,21 +87,27 @@ export class Timeline {
48
87
  });
49
88
  }
50
89
  else if (e.syncMs !== undefined && e.syncMs > 0) {
51
- events.push({ name: 'wait for idle', cat: 'sync', ph: 'X', ts: us(e.start), dur: Math.max(1, Math.round(e.syncMs * 1000)), pid: 1, tid: 1 });
90
+ events.push({ name: 'wait for idle', cat: 'sync', ph: 'X', ts: us(e.start), dur: Math.max(1, Math.round(e.syncMs * 1000)), pid: 1, tid: 1, args: busy });
52
91
  }
53
92
  }
54
93
  return JSON.stringify({ traceEvents: events, displayTimeUnit: 'ms' });
55
94
  }
56
95
  /** One page: a bar per call (sync wait shaded), failed calls in red with their message. */
57
96
  toHtml() {
58
- const total = Math.max(1, ...this.entries.map((e) => e.end - this.started));
59
- const rows = this.entries
97
+ const entries = this.all;
98
+ const total = Math.max(1, ...entries.map((e) => e.end - this.started));
99
+ const rows = entries
60
100
  .map((e) => {
61
101
  const left = ((e.start - this.started) / total) * 100;
62
102
  const width = Math.max(0.3, ((e.end - e.start) / total) * 100);
63
103
  const sync = e.syncMs !== undefined ? Math.min(100, (e.syncMs / Math.max(1, e.end - e.start)) * 100) : 0;
64
104
  const cls = e.error !== undefined ? 'row failed' : 'row';
65
105
  const err = e.error !== undefined ? `<div class="err">${esc(e.error)}</div>` : '';
106
+ const notes = [
107
+ ...(e.syncBusy !== undefined ? [`idle wait ended on: ${e.syncBusy.join(' | ')}`] : []),
108
+ ...(e.nativeCallsNotCounted !== undefined ? [`native calls ${NOT_COUNTED_NOTE}: ${e.nativeCallsNotCounted.join(', ')}`] : []),
109
+ ];
110
+ const why = notes.length > 0 ? `<div class="why">${notes.map(esc).join('<br>')}</div>` : '';
66
111
  const steps = (e.steps ?? [])
67
112
  .map((s, i) => {
68
113
  const sLeft = ((e.start + s.atMs - this.started) / total) * 100;
@@ -71,7 +116,7 @@ export class Timeline {
71
116
  return `<div class="row step"><div class="name">step ${i + 1} ${esc(s.label)}</div><div class="ms">${s.ms} ms (idle wait ${s.syncMs} ms)</div><div class="track"><div class="bar" style="left:${sLeft.toFixed(2)}%;width:${sWidth.toFixed(2)}%"><div class="sync" style="width:${sSync.toFixed(1)}%"></div></div></div></div>`;
72
117
  })
73
118
  .join('');
74
- return `<div class="${cls}"><div class="name">${esc(`${e.method} ${e.label}`)}</div><div class="ms">${e.end - e.start} ms${e.syncMs !== undefined ? ` (idle wait ${Math.round(e.syncMs)} ms)` : ''}</div><div class="track"><div class="bar" style="left:${left.toFixed(2)}%;width:${width.toFixed(2)}%"><div class="sync" style="width:${sync.toFixed(1)}%"></div></div></div>${err}</div>${steps}`;
119
+ return `<div class="${cls}"><div class="name">${esc(`${e.method} ${e.label}`)}</div><div class="ms">${e.end - e.start} ms${e.syncMs !== undefined ? ` (idle wait ${Math.round(e.syncMs)} ms)` : ''}</div><div class="track"><div class="bar" style="left:${left.toFixed(2)}%;width:${width.toFixed(2)}%"><div class="sync" style="width:${sync.toFixed(1)}%"></div></div></div>${why}${err}</div>${steps}`;
75
120
  })
76
121
  .join('\n');
77
122
  return `<!doctype html><html><head><meta charset="utf-8"><title>${esc(this.name)} — Quiesco timeline</title><style>
@@ -80,8 +125,9 @@ body{font:13px system-ui,sans-serif;margin:16px;color:#222}h1{font-size:16px}
80
125
  .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,monospace}.ms{color:#666;text-align:right}
81
126
  .track{position:relative;height:12px;background:#f4f4f4}.bar{position:absolute;top:0;height:12px;background:#6b8de3}.sync{height:12px;background:#b9c9f3}
82
127
  .step .name{padding-left:16px;color:#555}.step .bar{background:#9aa9cc}
128
+ .why{grid-column:1/-1;color:#666;white-space:pre-wrap;font-family:ui-monospace,monospace;font-size:12px;padding:0 0 4px 16px}
83
129
  .failed .bar{background:#d9534f}.failed .name{color:#c00}.err{grid-column:1/-1;color:#c00;white-space:pre-wrap;font-family:ui-monospace,monospace;font-size:12px;padding:4px 0 6px}
84
- </style></head><body><h1>${esc(this.name)}</h1><p>${this.entries.length} calls, ${total} ms. Light part of a bar: waiting for the app to be idle.</p>
130
+ </style></head><body><h1>${esc(this.name)}</h1><p>${entries.length} calls, ${total} ms. Light part of a bar: waiting for the app to be idle.</p>
85
131
  ${rows}
86
132
  </body></html>`;
87
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../src/timeline.ts"],"names":[],"mappings":"AA6BA,MAAM,OAAO,QAAQ;IACX,OAAO,GAAoB,EAAE,CAAC;IAC9B,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACrB,IAAI,GAAG,EAAE,CAAC;IAElB,uCAAuC;IACvC,KAAK,CAAC,IAAY;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,KAAoB;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,4DAA4D;QAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvD,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,OAAO,CAAI,MAAc,EAAE,KAAa,EAAE,EAAoB,EAAE,MAAyC;QAC7G,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CA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EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAW,CAAC,CAAC;AAC/G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiesco/core",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Quiesco host side: WebSocket server, Driver, device providers (test-runner agnostic)",
5
5
  "license": "MIT",
6
6
  "author": "h2nology",
@@ -50,7 +50,7 @@
50
50
  "ios-runner/QuiescoSystemUI.xcodeproj"
51
51
  ],
52
52
  "dependencies": {
53
- "@quiesco/protocol": "0.10.0",
53
+ "@quiesco/protocol": "0.12.0",
54
54
  "ws": "8.22.1"
55
55
  },
56
56
  "devDependencies": {
package/src/config.ts CHANGED
@@ -148,14 +148,21 @@ export interface QuiescoConfig {
148
148
  stableFrames?: number;
149
149
  ignoreUrls?: (RegExp | string)[];
150
150
  /**
151
- * Disable individual trackers, e.g. `{ 'frame-stable': false }`, or enable `native-module` (off by
152
- * default): `{ 'native-module': true }`.
151
+ * Disable individual trackers, e.g. `{ 'frame-stable': false }`. `native-module` is on when the app's
152
+ * build wraps native modules (`withQuiesco(config, { nativeModules: true })`, issue #94); turn it off
153
+ * with `{ 'native-module': false }`.
153
154
  */
154
155
  trackers?: Partial<Record<TrackerName, boolean>>;
155
156
  /** `native-module` tracker: how long a pending native module call counts as busy (default 2000 ms). */
156
157
  nativeCallThresholdMs?: number;
157
- /** `native-module` tracker: calls that never count, as "Module.method" (strings match as substrings). */
158
+ /**
159
+ * `native-module` tracker: calls that never count, as "Module.method" (strings match as substrings).
160
+ * Added to the calls that wait for the user, ignored by default (permission requests, pickers,
161
+ * authentication and share sheets, issue #93).
162
+ */
158
163
  ignoreNativeCalls?: (RegExp | string)[];
164
+ /** `native-module` tracker: `false` counts the calls that wait for the user too (default true). */
165
+ defaultIgnoreNativeCalls?: boolean;
159
166
  /**
160
167
  * Elements whose changes never keep the app busy for the frame-stable check (they and their
161
168
  * subtrees are left out), e.g. `['logo-glow']` for a decorative animation that runs for minutes.
@@ -294,6 +301,7 @@ export function toAgentConfig(config: QuiescoConfig, gestureSlop?: GestureSlop,
294
301
  trackers: { ...s.trackers },
295
302
  nativeCallThresholdMs: s.nativeCallThresholdMs ?? SyncDefaults.nativeCallThresholdMs,
296
303
  ignoreNativeCalls: (s.ignoreNativeCalls ?? []).map(toTextMatch),
304
+ ...(s.defaultIgnoreNativeCalls === false ? { defaultIgnoreNativeCalls: false } : {}),
297
305
  ignoreElements: (s.ignoreElements ?? []).map(toMatcher),
298
306
  },
299
307
  logLevel: config.logLevel ?? 'warn',
package/src/device.ts CHANGED
@@ -68,6 +68,9 @@ export interface DeviceHost {
68
68
  /** How long sendToBackground / bringToForeground wait for the app to report its new AppState. */
69
69
  const STATE_WAIT_MS = 5_000;
70
70
  const STATE_POLL_MS = 100;
71
+ /** system.tapAt waits at most this long for the system UI to stop moving (issue #87). */
72
+ const SYSTEM_SETTLE_MAX_MS = 2_000;
73
+ const sameBounds = (a: SystemNode, b: SystemNode): boolean => a.bounds.x1 === b.bounds.x1 && a.bounds.y1 === b.bounds.y1 && a.bounds.x2 === b.bounds.x2 && a.bounds.y2 === b.bounds.y2;
71
74
 
72
75
  /** How long a device-state change may take to reach the app (it is read back from the app). */
73
76
  const SETTLE_MS = 8_000;
@@ -162,6 +165,7 @@ export class DeviceApi {
162
165
  if (typeof point !== 'object' || point === null || !Number.isFinite(point.x) || !Number.isFinite(point.y)) throw new TypeError('system.tapAt({ x, y }) needs numbers');
163
166
  const p = this.host.provider;
164
167
  if (p.tapSystemPoint === undefined) throw notSupported('system.tapAt', p.platform, SYSTEM_UI_HINT[p.platform]);
168
+ await this.systemUiSettled(point);
165
169
  await p.tapSystemPoint(point.x, point.y);
166
170
  if (this.host.appState === 'running') await this.host.waitForIdle();
167
171
  },
@@ -641,6 +645,30 @@ export class DeviceApi {
641
645
  return { systemNodes: () => p.systemNodes!(), tapSystemNode: (n) => p.tapSystemNode!(n) };
642
646
  }
643
647
 
648
+ /**
649
+ * Before a touch at a point (system.tapAt): on a platform whose system UI animates in (issue #87), until
650
+ * two reads systemUiSettleMs apart show the same system UI, for at most SYSTEM_SETTLE_MAX_MS.
651
+ */
652
+ private async systemUiSettled(point: { x: number; y: number }): Promise<void> {
653
+ const p = this.host.provider;
654
+ const settleMs = p.systemUiSettleMs;
655
+ if (settleMs === undefined || p.systemNodes === undefined) return;
656
+ // The system UI over the point (iOS: SpringBoard's), not an app's element tree.
657
+ const here: SystemNode = { text: '', id: '', bounds: { x1: point.x, y1: point.y, x2: point.x, y2: point.y } };
658
+ const read = p.systemNodeReread === undefined ? () => p.systemNodes!() : p.systemNodeReread(here);
659
+ if (read === null) return;
660
+ await p.prepareSystemUi?.();
661
+ const shape = async () => JSON.stringify((await read()).map((n) => [n.text, n.id, n.bounds]));
662
+ const until = Date.now() + SYSTEM_SETTLE_MAX_MS;
663
+ let before = await shape();
664
+ while (Date.now() < until) {
665
+ await new Promise((r) => setTimeout(r, settleMs));
666
+ const now = await shape();
667
+ if (now === before) return;
668
+ before = now;
669
+ }
670
+ }
671
+
644
672
  /** Poll the system UI until a node matches (each listing may take a while: uiautomator dumps take ~2 s). */
645
673
  private async findSystemNode(action: string, what: string, pick: (nodes: SystemNode[]) => SystemNode | undefined, opts: SystemWaitOptions): Promise<SystemNode> {
646
674
  const p = this.systemProvider(action);
@@ -648,10 +676,24 @@ export class DeviceApi {
648
676
  // Not counted: starting the system UI runner (issue #64).
649
677
  await this.host.provider.prepareSystemUi?.();
650
678
  const deadline = Date.now() + timeoutMs;
679
+ const settleMs = this.host.provider.systemUiSettleMs;
651
680
  for (;;) {
652
- const nodes = await p.systemNodes();
681
+ let nodes = await p.systemNodes();
653
682
  const node = pick(nodes);
654
- if (node !== undefined) return node;
683
+ if (node !== undefined && settleMs === undefined) return node;
684
+ if (node !== undefined) {
685
+ // Still animating in, a touch is lost (issue #87): only once two reads agree on where it is. One
686
+ // that keeps moving until the deadline is acted on all the same.
687
+ const provider = this.host.provider;
688
+ const reread = provider.systemNodeReread === undefined ? () => p.systemNodes() : provider.systemNodeReread(node);
689
+ if (reread === null) return node;
690
+ await new Promise((r) => setTimeout(r, settleMs));
691
+ nodes = await reread();
692
+ const again = pick(nodes);
693
+ if (again !== undefined && (sameBounds(again, node) || Date.now() >= deadline)) return again;
694
+ this.host.logger.debug(`${action}: ${what} is still moving (${JSON.stringify(node.bounds)} → ${JSON.stringify(again?.bounds ?? null)}); looking again`);
695
+ continue;
696
+ }
655
697
  if (Date.now() >= deadline) {
656
698
  const seen = seenTexts(nodes);
657
699
  throw new QuiescoError('ELEMENT_NOT_FOUND', `${action}: no system UI matching ${what} within ${timeoutMs}ms (on screen outside the app: ${seen.map((t) => JSON.stringify(t)).join(', ') || 'nothing'})`, {
@@ -82,12 +82,25 @@ export function screenNodes(screen: RunnerScreen): SystemNode[] {
82
82
  return out;
83
83
  }
84
84
 
85
- /** The button that dismisses a leftover alert with the least effect: cancel, deny, else the first one. */
86
- export function dismissButton(alert: RunnerScreen['alerts'][number]): { frame: number[] } | undefined {
87
- const nodes = screenNodes({ alerts: [alert], others: [] });
88
- const pick = nodes.find((n) => /cancel/i.test(n.id)) ?? nodes.find((n) => n.id === PERMISSION_DENY);
89
- if (pick !== undefined) return { frame: [pick.bounds.x1, pick.bounds.y1, pick.bounds.x2 - pick.bounds.x1, pick.bounds.y2 - pick.bounds.y1] };
90
- return alert.buttons[0];
85
+ /** A system permission alert: no identifiers at all, two or three buttons (see screenNodes). */
86
+ export function isPermissionAlert(alert: RunnerScreen['alerts'][number]): boolean {
87
+ return alert.id === '' && alert.buttons.every((b) => b.id === '') && (alert.buttons.length === 2 || alert.buttons.length === 3);
88
+ }
89
+
90
+ /** `"<title>" [<button>, <button>]`, for messages. */
91
+ export function describeAlert(alert: RunnerScreen['alerts'][number]): string {
92
+ return `${JSON.stringify(alert.label)} [${alert.buttons.map((b) => b.label).join(', ')}]`;
93
+ }
94
+
95
+ /**
96
+ * The button that dismisses a leftover alert with the least effect: cancel, else the first one, with
97
+ * its label. None for a permission alert (issue #86): its "Don't Allow" leaves a denied permission
98
+ * (notifications: until the app is reinstalled), its "Allow" a grant the test did not ask for.
99
+ */
100
+ export function dismissButton(alert: RunnerScreen['alerts'][number]): { frame: number[]; label: string } | undefined {
101
+ if (isPermissionAlert(alert)) return undefined;
102
+ const cancel = alert.buttons.find((b) => /cancel/i.test(b.id));
103
+ return cancel ?? alert.buttons[0];
91
104
  }
92
105
 
93
106
  /** Where the runner sources are: <package>/ios-runner (from dist/devices or src/devices). */
@@ -36,7 +36,7 @@ import type { Exec } from './exec.js';
36
36
  import { execCommand } from './exec.js';
37
37
  import { LogBuffer, exited, spawnProcess } from './streams.js';
38
38
  import type { ChildLike, SpawnProcess } from './streams.js';
39
- import { IosSystemRunner, PERMISSION_ALLOW, PERMISSION_DENY, backButton, dismissButton, screenNodes } from './ios-runner.js';
39
+ import { IosSystemRunner, PERMISSION_ALLOW, PERMISSION_DENY, backButton, describeAlert, dismissButton, isPermissionAlert, screenNodes } from './ios-runner.js';
40
40
  import type { RunnerScreen } from './ios-runner.js';
41
41
  import type { Permission } from './permissions.js';
42
42
  import { SERIAL_WORKER } from './provider.js';
@@ -208,9 +208,14 @@ export function logTime(ms: number): string {
208
208
 
209
209
  /**
210
210
  * Apps whose UI system.* sees when they are in front (issue #51): the page of a web authentication session
211
- * (ASWebAuthenticationSession, SFSafariViewController) and Safari.
211
+ * (ASWebAuthenticationSession, SFSafariViewController), Safari, and the Face ID / passcode prompt (issue #92:
212
+ * the first prompt after the simulator boots is only in LocalAuthenticationUIService's tree, not in
213
+ * SpringBoard's).
212
214
  */
213
- const OTHER_APPS = ['com.apple.SafariViewService', 'com.apple.mobilesafari'];
215
+ const LOCAL_AUTH_UI = 'com.apple.LocalAuthenticationUIService';
216
+ const OTHER_APPS = ['com.apple.SafariViewService', 'com.apple.mobilesafari', LOCAL_AUTH_UI];
217
+ /** Apps whose element tree reads fast enough (15–55 ms) to read again for the settle check (issue #87). */
218
+ const QUICK_TREES: ReadonlySet<string> = new Set([LOCAL_AUTH_UI]);
214
219
  /** XCUIApplication.State.runningForeground. */
215
220
  const RUNNING_FOREGROUND = 4;
216
221
  /** XCUIElement.ElementType values left out: the application, windows, scroll bars (no one taps them). */
@@ -229,7 +234,7 @@ export function uikitNodes(elements: readonly { type: number; label: string; id:
229
234
  }
230
235
 
231
236
  /**
232
- * Whether `frame` ([x, y, w, h]) looks like the "Open" button a locked device shows beside the tapped
237
+ * Whether `frame` ([x, y, w, h]) looks like the "Open" button a locked device (or iOS 27 Notification Center, #82) shows beside the tapped
233
238
  * notification `b`: in its row, on its left, less than half its width.
234
239
  */
235
240
  function revealedOpen(frame: number[], b: { x1: number; x2: number; y1: number; y2: number }): boolean {
@@ -241,9 +246,16 @@ function revealedOpen(frame: number[], b: { x1: number; x2: number; y1: number;
241
246
  /** Darwin notification state BiometricKit_Sim reads for "enrolled" (1 / 0). */
242
247
  const BIOMETRIC_ENROLLMENT = 'com.apple.BiometricKit.enrollmentChanged';
243
248
 
244
- /** openNotification: after BANNER_WAIT_MS (at most half the timeout) without a banner, it looks in Notification Center. */
245
- const BANNER_WAIT_MS = 2_000;
249
+ /**
250
+ * openNotification: after BANNER_WAIT_MS (at most half the timeout) without a banner, it looks in
251
+ * Notification Center. Long enough for a notification scheduled a few seconds ahead to show as a banner:
252
+ * opened earlier, Notification Center receives it, and on iOS 27 a tap on a notification that just
253
+ * arrived there does nothing (2 s: 1 run in 4 failed once the runner was warm, issue #82).
254
+ */
255
+ const BANNER_WAIT_MS = 5_000;
246
256
  const NOTIFICATION_POLL_MS = 250;
257
+ /** System UI slides in for ~430–615 ms: two reads this far apart must agree before a touch (issue #87). */
258
+ const SYSTEM_UI_SETTLE_MS = 250;
247
259
  /** openUrlFromOutside: how long SpringBoard's "Open in …?" confirmation may take to show up. */
248
260
  const OPEN_URL_CONFIRM_MS = 5_000;
249
261
  /**
@@ -272,6 +284,8 @@ export class IosProvider implements DeviceProvider {
272
284
  private readonly logger: Logger;
273
285
  /** XCUITest runner for SpringBoard's UI, started on first use (Phase 6.7 batch C). */
274
286
  private runnerInstance: SystemRunnerLike | null = null;
287
+ /** A runner start in progress: a warm-up (sendToBackground) and a system UI call share it. */
288
+ private runnerStarting: Promise<void> | null = null;
275
289
  /** Phase 6.9 artifacts: the running recorder and log stream. */
276
290
  private recorder: { child: ChildLike; file: string } | null = null;
277
291
  private logStream: ChildLike | null = null;
@@ -489,6 +503,9 @@ export class IosProvider implements DeviceProvider {
489
503
  }
490
504
 
491
505
  async sendToBackground(app: InAppControls): Promise<void> {
506
+ // What follows is often openNotification: a runner that starts only then (7–15 s cold) misses the
507
+ // banner (issue #82). Started in the background; a failure shows up when the runner is used.
508
+ this.startRunner().catch((e: unknown) => this.logger.debug(`warming up the iOS system UI runner failed: ${(e as Error).message}`));
492
509
  if (await app.suspend().catch(() => false)) return;
493
510
  // No @quiesco/native (or an older one): another app in front puts ours in the background too.
494
511
  this.logger.debug('sendToBackground: the app cannot suspend itself; opening the Settings app instead');
@@ -731,9 +748,18 @@ export class IosProvider implements DeviceProvider {
731
748
  */
732
749
  /** Start the system UI runner: system UI waits start their clock after it (a cold start takes 7–15 s, issue #64). */
733
750
  async prepareSystemUi(): Promise<void> {
734
- await this.runner.start?.();
751
+ await this.startRunner();
752
+ }
753
+
754
+ private startRunner(): Promise<void> {
755
+ this.runnerStarting ??= (async () => this.runner.start?.())().finally(() => {
756
+ this.runnerStarting = null;
757
+ });
758
+ return this.runnerStarting;
735
759
  }
736
760
 
761
+ readonly systemUiSettleMs = SYSTEM_UI_SETTLE_MS;
762
+
737
763
  async systemNodes(): Promise<SystemNode[]> {
738
764
  const runner = this.runner;
739
765
  const nodes = screenNodes(await runner.screen());
@@ -745,6 +771,22 @@ export class IosProvider implements DeviceProvider {
745
771
  return nodes;
746
772
  }
747
773
 
774
+ /**
775
+ * SpringBoard's UI (alerts, the Face ID prompt, banners) slides in: read it again. Not a node of an app's
776
+ * element tree: a read of that takes seconds (18 s with a web page in it), the animation is over by then.
777
+ * The Face ID prompt's own app is the exception (issue #92): its tree is small and reads in 15–55 ms.
778
+ */
779
+ systemNodeReread(node: SystemNode): (() => Promise<SystemNode[]>) | null {
780
+ const app = node.app;
781
+ if (app === undefined) return async () => screenNodes(await this.runner.screen());
782
+ const elements = this.runner.elements?.bind(this.runner);
783
+ if (!QUICK_TREES.has(app) || elements === undefined) return null;
784
+ return async () => {
785
+ const tree = await elements(app);
786
+ return tree.state === RUNNING_FOREGROUND ? uikitNodes(tree.elements, app) : [];
787
+ };
788
+ }
789
+
748
790
  async tapSystemNode(node: SystemNode): Promise<void> {
749
791
  await this.runner.tap((node.bounds.x1 + node.bounds.x2) / 2, (node.bounds.y1 + node.bounds.y2) / 2);
750
792
  }
@@ -863,28 +905,26 @@ export class IosProvider implements DeviceProvider {
863
905
  taps++;
864
906
  // A stack that expanded shows more matching notifications: look again right away.
865
907
  const expanded = async () => (await find(), shown.filter(matches).length > matching);
866
- if (await this.tapOpened(appState !== undefined, inFront, find, deadline, expanded)) return;
867
- // On a locked device a tap only slides the notification to the right and shows an "Open" button on
868
- // its left (in the device's language): a new, small button, not a notification, left in that row.
869
- // Not one on the right ("Clear", "Options"), nor another notification.
870
- await find();
871
- const revealed = shown.find((o) => !before.has(o.label) && !matches(o) && !o.label.includes(', ') && revealedOpen(o.frame, b));
872
- if (revealed !== undefined) {
873
- const r = screenNodes({ alerts: [], others: [revealed] })[0]!.bounds;
874
- this.logger.warn(`openNotification: tapping "${title}" showed ${JSON.stringify(revealed.label)} (a locked device); tapping it`);
875
- await runner.tap((r.x1 + r.x2) / 2, (r.y1 + r.y2) / 2);
876
- if (await this.tapOpened(appState !== undefined, inFront, find, deadline, async () => false)) return;
877
- }
908
+ // On a locked device, and in Notification Center on iOS 27 (the Cover Sheet), a tap may only slide
909
+ // the notification to the right and show an "Open" button on its left (in the device's language),
910
+ // withdrawn ~3 s later (issue #82): a new, small button, not a notification, left in that row. Not
911
+ // one on the right ("Clear", "Options"), nor another notification. Read from the last `find`.
912
+ const revealed = () => shown.find((o) => !before.has(o.label) && !matches(o) && !o.label.includes(', ') && revealedOpen(o.frame, b));
913
+ if (await this.tapOpened(appState !== undefined, inFront, find, deadline, expanded, revealed, title)) return;
878
914
  this.logger.warn(`openNotification: the app did not come to the front after tapping "${title}"; looking again`);
879
915
  continue;
880
916
  }
881
917
  if (taps > 0 && (await inFront())) return;
882
918
  if (Date.now() > deadline) {
883
- const seen = (await runner.screen().catch(() => ({ alerts: [], others: [] }))).others.map((o) => JSON.stringify(o.label)).slice(0, 8);
919
+ const screen = await runner.screen().catch((): RunnerScreen => ({ alerts: [], others: [] }));
920
+ // A system alert is often the reason (issue #85: the permission prompt, so nothing was scheduled).
921
+ const alerts = screen.alerts.length === 0 ? '' : `; a system alert is up: ${screen.alerts.map(describeAlert).join(', ')}`;
922
+ const seen = `${screen.others.map((o) => JSON.stringify(o.label)).slice(0, 8).join(', ') || 'nothing'}${alerts}`;
884
923
  if (taps > 0) {
885
- throw new QuiescoError('DEVICE_ERROR', `openNotification: tapped "${title}" ${taps} time(s), but the app did not come to the front within ${timeoutMs}ms (seen: ${seen.join(', ') || 'nothing'})`);
924
+ throw new QuiescoError('DEVICE_ERROR', `openNotification: tapped "${title}" ${taps} time(s), but the app did not come to the front within ${timeoutMs}ms (seen: ${seen})`);
886
925
  }
887
- throw new QuiescoError('DEVICE_ERROR', `openNotification: no notification "${title}" in a banner or Notification Center within ${timeoutMs}ms (seen: ${seen.join(', ') || 'nothing'}). Can the app show notifications (system.allowPermission())?`);
926
+ const hint = screen.alerts.some(isPermissionAlert) ? 'Answer the permission alert first (system.allowPermission())' : 'Can the app show notifications (system.allowPermission())?';
927
+ throw new QuiescoError('DEVICE_ERROR', `openNotification: no notification "${title}" in a banner or Notification Center within ${timeoutMs}ms (seen: ${seen}). ${hint}`);
888
928
  }
889
929
  // The banner goes away after a few seconds (also after a tap that missed it); then the notification is in Notification Center.
890
930
  if (!centerOpened && (taps > 0 || Date.now() > start + Math.min(BANNER_WAIT_MS, timeoutMs / 2))) {
@@ -898,27 +938,62 @@ export class IosProvider implements DeviceProvider {
898
938
  /**
899
939
  * Whether a notification tap opened the app: the app is in front within NOTIFICATION_FRONT_MS
900
940
  * (`knowsState`), else (a runner that cannot tell) the notification went away within NOTIFICATION_TAP_CONFIRM_MS.
941
+ * An "Open" button the tap revealed (`revealed`, read after each look) is tapped as soon as two looks
942
+ * agree on where it is, and the wait starts again (issue #82: it is withdrawn ~3 s later).
901
943
  */
902
- private async tapOpened(knowsState: boolean, inFront: () => Promise<boolean>, find: () => Promise<unknown>, deadline: number, expanded: () => Promise<boolean>): Promise<boolean> {
944
+ private async tapOpened(
945
+ knowsState: boolean,
946
+ inFront: () => Promise<boolean>,
947
+ find: () => Promise<unknown>,
948
+ deadline: number,
949
+ expanded: () => Promise<boolean>,
950
+ revealed: () => RunnerScreen['others'][number] | undefined,
951
+ title: string,
952
+ ): Promise<boolean> {
903
953
  // Not past the call's deadline (but one look at least).
904
- const until = Math.min(Date.now() + (knowsState ? NOTIFICATION_FRONT_MS : NOTIFICATION_TAP_CONFIRM_MS), Math.max(deadline, Date.now()));
954
+ const waitUntil = () => Math.min(Date.now() + (knowsState ? NOTIFICATION_FRONT_MS : NOTIFICATION_TAP_CONFIRM_MS), Math.max(deadline, Date.now()));
955
+ let until = waitUntil();
956
+ let openAt: string | undefined;
957
+ let openTapped = false;
905
958
  for (;;) {
906
959
  if (knowsState ? await inFront() : (await find()) === undefined) return true;
907
960
  if (knowsState && (await expanded())) return false;
961
+ const open = openTapped ? undefined : revealed();
962
+ const at = open === undefined ? undefined : JSON.stringify(open.frame);
963
+ if (open !== undefined && at === openAt) {
964
+ const r = screenNodes({ alerts: [], others: [open] })[0]!.bounds;
965
+ this.logger.warn(`openNotification: tapping "${title}" showed ${JSON.stringify(open.label)} (Notification Center on iOS 27, or a locked device); tapping it`);
966
+ await this.runner.tap((r.x1 + r.x2) / 2, (r.y1 + r.y2) / 2);
967
+ openTapped = true;
968
+ until = waitUntil();
969
+ continue;
970
+ }
971
+ openAt = at;
908
972
  if (Date.now() >= until) return false;
909
973
  await new Promise((r) => setTimeout(r, NOTIFICATION_POLL_MS));
910
974
  }
911
975
  }
912
976
 
913
- /** Alerts outlive the app (a relaunch keeps a permission alert up): dismiss what an earlier scenario left. */
977
+ /**
978
+ * Alerts outlive the app (a relaunch keeps a permission alert up): dismiss what an earlier scenario left.
979
+ * Not a permission alert (issue #86): either answer sticks (a denied notification permission only goes
980
+ * away with a reinstall), so the scenario fails, saying which alert is up.
981
+ */
914
982
  private async dismissLeftoverAlerts(): Promise<void> {
915
983
  if (this.runnerInstance?.running !== true) return;
916
984
  for (let i = 0; i < 3; i++) {
917
985
  const alert = (await this.runner.screen().catch(() => null))?.alerts[0];
918
986
  if (alert === undefined) return;
987
+ if (isPermissionAlert(alert)) {
988
+ const message =
989
+ `a system permission alert left by the previous scenario is still up: ${describeAlert(alert)}. Quiesco does not answer it for you ` +
990
+ `(on iOS "Don't Allow" for notifications sticks until the app is reinstalled). Answer it in the scenario that brings it up ` +
991
+ `(app.device.system.allowPermission() / denyPermission()), or grant the permission before the app starts (config \`permissions\`)`;
992
+ throw new QuiescoError('RESET_FAILED', message, { step: 'system alert', message });
993
+ }
919
994
  const button = dismissButton(alert);
920
995
  if (button === undefined) return;
921
- this.logger.warn(`dismissing a system alert left by the previous scenario: ${JSON.stringify(alert.label)}`);
996
+ this.logger.warn(`dismissing a system alert left by the previous scenario: ${describeAlert(alert)}; tapping ${JSON.stringify(button.label)}`);
922
997
  const [x = 0, y = 0, w = 0, h = 0] = button.frame;
923
998
  await this.runner.tap(x + w / 2, y + h / 2).catch(() => undefined);
924
999
  }
@@ -936,7 +1011,7 @@ export class IosProvider implements DeviceProvider {
936
1011
  if (alert === undefined) break;
937
1012
  const button = dismissButton(alert);
938
1013
  if (button === undefined) break;
939
- this.logger.warn(`dismissing a system alert covering the app: ${JSON.stringify(alert.label)}`);
1014
+ this.logger.warn(`dismissing a system alert covering the app: ${describeAlert(alert)}; tapping ${JSON.stringify(button.label)}`);
940
1015
  const [x = 0, y = 0, w = 0, h = 0] = button.frame;
941
1016
  await this.runner.tap(x + w / 2, y + h / 2).catch(() => undefined);
942
1017
  closed.push(alert.label);
@@ -944,6 +1019,12 @@ export class IosProvider implements DeviceProvider {
944
1019
  return closed;
945
1020
  }
946
1021
 
1022
+ async unansweredSystemAlert(): Promise<string | undefined> {
1023
+ const alert = (await this.runner.screen().catch(() => null))?.alerts.find(isPermissionAlert);
1024
+ if (alert === undefined) return undefined;
1025
+ return `A system permission alert is up over the app: ${describeAlert(alert)}. Quiesco does not answer it for you: answer it in the scenario (app.device.system.allowPermission() / denyPermission())`;
1026
+ }
1027
+
947
1028
  async resetDeviceState(app: InAppControls): Promise<StateChange> {
948
1029
  await this.dismissLeftoverAlerts();
949
1030
  for (const [what, value] of this.changed) {
@@ -193,6 +193,21 @@ export interface DeviceProvider {
193
193
  prepareSystemUi?(): Promise<void>;
194
194
  /** System UI on screen now that does not belong to the app (dialogs, prompts), topmost window first. */
195
195
  systemNodes?(): Promise<SystemNode[]>;
196
+ /**
197
+ * System UI slides or fades in here and a touch during that animation is lost (iOS, issue #87): system
198
+ * taps, types and expectVisible act on a match only once two reads this many ms apart agree on where it is.
199
+ */
200
+ readonly systemUiSettleMs?: number;
201
+ /**
202
+ * The settle check's second read (issue #87): only the part of the system UI `node` came from, or null
203
+ * for none (act on it now). Without this method: systemNodes().
204
+ */
205
+ systemNodeReread?(node: SystemNode): (() => Promise<SystemNode[]>) | null;
206
+ /**
207
+ * A system alert over the app that dismissSystemAlerts leaves up (iOS: a permission alert, issue #86),
208
+ * described for an error message; undefined when there is none.
209
+ */
210
+ unansweredSystemAlert?(): Promise<string | undefined>;
196
211
  tapSystemNode?(node: SystemNode): Promise<void>;
197
212
  /**
198
213
  * Tap the field `node` and type `text` into it with the device's input (issues #51): iOS through the