@quiesco/core 0.8.1 → 0.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ws-server.d.ts","sourceRoot":"","sources":["../../src/server/ws-server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE3H,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAGpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AASzD,yEAAyE;AACzE,qBAAa,eAAgB,SAAQ,YAAY,CAAC;IAChD,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1B,QAAQ,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;IAME,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,IAAI,EAAE,WAAW;IAP5B,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,OAAO,CAAS;gBAGL,MAAM,EAAE,SAAS,EACzB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW;IAK5B,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,iG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,EAAE,MAAM,MAAM,EAAE,OAAO,GAAE,eAAe,GAAG,IAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBxJ,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,YAAY;CAQrB"}
@@ -7,7 +7,7 @@
7
7
  * connection for the same session replaces the first (4003), e.g. after a web page reload.
8
8
  */
9
9
  import { EventEmitter } from 'node:events';
10
- import { CloseCode, ErrorCode, JsonRpcErrorCode, PROTOCOL_VERSION } from '@quiesco/protocol';
10
+ import { CloseCode, ErrorCode, HOST_TICK, HOST_TICK_MS, JsonRpcErrorCode, PROTOCOL_VERSION } from '@quiesco/protocol';
11
11
  import { WebSocketServer } from 'ws';
12
12
  import { QuiescoError } from '../errors.js';
13
13
  import { silentLogger } from '../logger.js';
@@ -19,6 +19,7 @@ export class AgentConnection extends EventEmitter {
19
19
  nextId = 1;
20
20
  pending = new Map();
21
21
  _closed = false;
22
+ ticker = null;
22
23
  constructor(socket, sessionId, info) {
23
24
  super();
24
25
  this.socket = socket;
@@ -44,8 +45,35 @@ export class AgentConnection extends EventEmitter {
44
45
  }, timeoutMs);
45
46
  this.pending.set(id, { resolve: resolve, reject, timer, method });
46
47
  this.socket.send(JSON.stringify({ jsonrpc: '2.0', id, method, params }));
48
+ this.startTicks();
47
49
  });
48
50
  }
51
+ /**
52
+ * While a call is pending, a `tick` notification every HOST_TICK_MS: the agent checks its wait for idle
53
+ * again on each one, also when the app's JS timers are paused in the background (issue #66).
54
+ */
55
+ startTicks() {
56
+ if (this.ticker !== null)
57
+ return;
58
+ this.ticker = setInterval(() => {
59
+ if (this.pending.size === 0 || this._closed) {
60
+ this.stopTicks();
61
+ return;
62
+ }
63
+ try {
64
+ this.socket.send(JSON.stringify({ jsonrpc: '2.0', method: HOST_TICK }));
65
+ }
66
+ catch {
67
+ // The socket is closing: onClosed rejects the pending calls.
68
+ }
69
+ }, HOST_TICK_MS);
70
+ this.ticker.unref?.();
71
+ }
72
+ stopTicks() {
73
+ if (this.ticker !== null)
74
+ clearInterval(this.ticker);
75
+ this.ticker = null;
76
+ }
49
77
  close(code = CloseCode.NORMAL, reason = '') {
50
78
  this.socket.close(code, reason);
51
79
  this.onClosed(code, reason);
@@ -74,6 +102,7 @@ export class AgentConnection extends EventEmitter {
74
102
  if (this._closed)
75
103
  return;
76
104
  this._closed = true;
105
+ this.stopTicks();
77
106
  for (const [, p] of this.pending) {
78
107
  clearTimeout(p.timer);
79
108
  p.reject(new QuiescoError('AGENT_DISCONNECTED', `The app disconnected while handling ${p.method} (close code ${code})`, { method: p.method, code }));
@@ -1 +1 @@
1
- {"version":3,"file":"ws-server.js","sourceRoot":"","sources":["../../src/server/ws-server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAW5C,yEAAyE;AACzE,MAAM,OAAO,eAAgB,SAAQ,YAInC;IAMmB;IACR;IACA;IAPH,MAAM,GAAG,CAAC,CAAC;IACF,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,OAAO,GAAG,KAAK,CAAC;IAExB,YACmB,MAAiB,EACzB,SAAiB,EACjB,IAAiB;QAE1B,KAAK,EAAE,CAAC;QAJS,WAAM,GAAN,MAAM,CAAW;QACzB,cAAS,GAAT,SAAS,CAAQ;QACjB,SAAI,GAAJ,IAAI,CAAa;IAG5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,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AC;CACF"}
package/dist/session.js CHANGED
@@ -177,7 +177,7 @@ export class Session {
177
177
  }
178
178
  async resetForScenario(info) {
179
179
  await this.sync.reset();
180
- await this.device.resetDeviceState(this.config.permissions ?? []);
180
+ await this.device.resetDeviceState(this.config.permissions ?? []); console.error("DBG resetDeviceState end", Date.now());
181
181
  const hard = info.tags?.includes(tagNames(this.config.tags).hardReset) === true || this.config.reset?.default === 'hard';
182
182
  if (hard || this.appState === 'terminated') {
183
183
  await this.provider.terminate();
@@ -188,7 +188,7 @@ export class Session {
188
188
  else {
189
189
  if (this.appState === 'background')
190
190
  await this.device.bringToForeground();
191
- await this.driver.reset();
191
+ console.error("DBG driver.reset start", Date.now()); await this.driver.reset(); console.error("DBG driver.reset end", Date.now());
192
192
  }
193
193
  await this.expectInitialState();
194
194
  }
@@ -9,6 +9,7 @@
9
9
  // POST /edgeSwipeBack → drag from the left edge of the screen (the interactive pop gesture)
10
10
  // GET /elements?bundleId=… → the UIKit elements of an app (the app under test, Safari, SafariViewService), from
11
11
  // one snapshot: { state, elements: [{ type, label, id, value, frame, enabled, selected }] }
12
+ // GET /appState?bundleId=… → { state } (XCUIApplication.State) without reading the app's UI
12
13
  // POST /typeText?bundleId=…&text=… → type into the focused field of that app with its keyboard (409 without one)
13
14
  // POST /quit → end the test
14
15
  import Network
@@ -104,6 +105,9 @@ final class SystemUIServer: XCTestCase {
104
105
  }
105
106
  }
106
107
  return ("200 OK", ["state": app.state.rawValue, "elements": out])
108
+ case "/appState":
109
+ guard let id = q["bundleId"], !id.isEmpty else { return ("400 Bad Request", ["error": "bundleId"]) }
110
+ return ("200 OK", ["state": XCUIApplication(bundleIdentifier: id).state.rawValue])
107
111
  case "/typeText":
108
112
  guard let id = q["bundleId"], !id.isEmpty, let text = q["text"] else { return ("400 Bad Request", ["error": "bundleId and text"]) }
109
113
  let app = XCUIApplication(bundleIdentifier: id)
@@ -124,23 +128,35 @@ final class SystemUIServer: XCTestCase {
124
128
  return [f.minX, f.minY, f.width, f.height].map { Double($0) }
125
129
  }
126
130
 
131
+ /**
132
+ * SpringBoard's alerts and its other labelled buttons (banners, Notification Center cells), from one
133
+ * snapshot (issue #65): reading the elements one by one by index fails, and ends this test, when the list
134
+ * changes in between (a notification stack expanding). The snapshot has no `isHittable`: a button counts
135
+ * when its frame is on screen.
136
+ */
127
137
  private func screen() -> [String: Any] {
128
- var alerts: [[String: Any]] = []
129
- var inAlerts = Set<String>()
130
- for a in springboard.alerts.allElementsBoundByIndex where a.exists {
131
- let texts = a.staticTexts.allElementsBoundByIndex.map { ["label": $0.label, "frame": frame($0)] as [String: Any] }
132
- let buttons = a.buttons.allElementsBoundByIndex.map { b -> [String: Any] in
133
- inAlerts.insert("\(b.label)|\(frame(b))")
134
- return ["label": b.label, "id": b.identifier, "frame": frame(b)]
135
- }
136
- alerts.append(["label": a.label, "id": a.identifier, "frame": frame(a), "texts": texts, "buttons": buttons])
138
+ guard let root = try? springboard.snapshot() else { return ["alerts": [], "others": []] }
139
+ let screenFrame = root.frame
140
+ func rect(_ f: CGRect) -> [Double] { [f.minX, f.minY, f.width, f.height].map { Double($0) } }
141
+ func onScreen(_ f: CGRect) -> Bool { f.width > 0 && f.height > 0 && (screenFrame.isEmpty || screenFrame.intersects(f)) }
142
+ func descendants(_ e: XCUIElementSnapshot, _ type: XCUIElement.ElementType) -> [XCUIElementSnapshot] {
143
+ e.children.flatMap { c in (c.elementType == type ? [c] : []) + descendants(c, type) }
137
144
  }
138
- // Banners and Notification Center cells: SpringBoard buttons with a label, outside the alerts.
145
+ var alerts: [[String: Any]] = []
139
146
  var others: [[String: Any]] = []
140
- for b in springboard.buttons.allElementsBoundByIndex where !b.label.isEmpty && b.isHittable {
141
- if inAlerts.contains("\(b.label)|\(frame(b))") { continue }
142
- others.append(["label": b.label, "id": b.identifier, "frame": frame(b)])
147
+ func walk(_ e: XCUIElementSnapshot) {
148
+ if e.elementType == .alert {
149
+ let texts = descendants(e, .staticText).map { ["label": $0.label, "frame": rect($0.frame)] as [String: Any] }
150
+ let buttons = descendants(e, .button).map { ["label": $0.label, "id": $0.identifier, "frame": rect($0.frame)] as [String: Any] }
151
+ alerts.append(["label": e.label, "id": e.identifier, "frame": rect(e.frame), "texts": texts, "buttons": buttons])
152
+ return
153
+ }
154
+ if e.elementType == .button && !e.label.isEmpty && onScreen(e.frame) {
155
+ others.append(["label": e.label, "id": e.identifier, "frame": rect(e.frame)])
156
+ }
157
+ for c in e.children { walk(c) }
143
158
  }
159
+ walk(root)
144
160
  return ["alerts": alerts, "others": others]
145
161
  }
146
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiesco/core",
3
- "version": "0.8.1",
3
+ "version": "0.9.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.8.1",
53
+ "@quiesco/protocol": "0.9.0",
54
54
  "ws": "8.22.1"
55
55
  },
56
56
  "devDependencies": {
package/src/config.ts CHANGED
@@ -147,8 +147,15 @@ export interface QuiescoConfig {
147
147
  countIntervals?: boolean;
148
148
  stableFrames?: number;
149
149
  ignoreUrls?: (RegExp | string)[];
150
- /** Disable individual trackers, e.g. `{ 'frame-stable': false }`. */
150
+ /**
151
+ * Disable individual trackers, e.g. `{ 'frame-stable': false }`, or enable `native-module` (off by
152
+ * default): `{ 'native-module': true }`.
153
+ */
151
154
  trackers?: Partial<Record<TrackerName, boolean>>;
155
+ /** `native-module` tracker: how long a pending native module call counts as busy (default 2000 ms). */
156
+ nativeCallThresholdMs?: number;
157
+ /** `native-module` tracker: calls that never count, as "Module.method" (strings match as substrings). */
158
+ ignoreNativeCalls?: (RegExp | string)[];
152
159
  /**
153
160
  * Elements whose changes never keep the app busy for the frame-stable check (they and their
154
161
  * subtrees are left out), e.g. `['logo-glow']` for a decorative animation that runs for minutes.
@@ -285,6 +292,8 @@ export function toAgentConfig(config: QuiescoConfig, gestureSlop?: GestureSlop,
285
292
  stableFrames: s.stableFrames ?? SyncDefaults.stableFrames,
286
293
  ignoreUrls: (s.ignoreUrls ?? []).map(toTextMatch),
287
294
  trackers: { ...s.trackers },
295
+ nativeCallThresholdMs: s.nativeCallThresholdMs ?? SyncDefaults.nativeCallThresholdMs,
296
+ ignoreNativeCalls: (s.ignoreNativeCalls ?? []).map(toTextMatch),
288
297
  ignoreElements: (s.ignoreElements ?? []).map(toMatcher),
289
298
  },
290
299
  logLevel: config.logLevel ?? 'warn',
package/src/device.ts CHANGED
@@ -125,6 +125,7 @@ export class DeviceApi {
125
125
  expectNotVisible: async (query: SystemQuery, opts: SystemWaitOptions = {}): Promise<void> => {
126
126
  checkSystemQuery('system.expectNotVisible', query);
127
127
  const p = this.systemProvider('system.expectNotVisible');
128
+ await this.host.provider.prepareSystemUi?.();
128
129
  const deadline = Date.now() + (opts.timeoutMs ?? SYSTEM_WAIT_MS);
129
130
  for (;;) {
130
131
  const match = (await p.systemNodes()).find((n) => matchesSystemQuery(n, query));
@@ -473,7 +474,12 @@ export class DeviceApi {
473
474
  if (this.host.appState === 'terminated') throw notRunning('openNotification');
474
475
  await p.openNotification(title, timeoutMs);
475
476
  this.host.appState = 'running';
476
- await this.waitForAppState((s) => s === 'active', true);
477
+ await this.waitForAppState((s) => s === 'active', true).catch((e: unknown) => {
478
+ // Still in the background: the next scenario's reset brings it back instead of waiting on a
479
+ // suspended app (issue #68).
480
+ this.host.appState = 'background';
481
+ throw e;
482
+ });
477
483
  await this.host.reapplyConfig();
478
484
  await this.host.waitForIdle();
479
485
  }
@@ -639,6 +645,8 @@ export class DeviceApi {
639
645
  private async findSystemNode(action: string, what: string, pick: (nodes: SystemNode[]) => SystemNode | undefined, opts: SystemWaitOptions): Promise<SystemNode> {
640
646
  const p = this.systemProvider(action);
641
647
  const timeoutMs = opts.timeoutMs ?? SYSTEM_WAIT_MS;
648
+ // Not counted: starting the system UI runner (issue #64).
649
+ await this.host.provider.prepareSystemUi?.();
642
650
  const deadline = Date.now() + timeoutMs;
643
651
  for (;;) {
644
652
  const nodes = await p.systemNodes();
@@ -153,7 +153,7 @@ export class IosSystemRunner {
153
153
  }
154
154
 
155
155
  async screen(): Promise<RunnerScreen> {
156
- return this.call(() => this.request<RunnerScreen>('GET', '/screen'));
156
+ return this.call(() => this.request<RunnerScreen>('GET', '/screen'), true);
157
157
  }
158
158
 
159
159
  async tap(x: number, y: number): Promise<void> {
@@ -162,7 +162,7 @@ export class IosSystemRunner {
162
162
 
163
163
  /** The navigation bars of the app `bundleId` (issue #4). */
164
164
  async navigationBar(bundleId: string): Promise<RunnerNavigationBar> {
165
- return this.call(() => this.request<RunnerNavigationBar>('GET', `/navigationBar?bundleId=${encodeURIComponent(bundleId)}`));
165
+ return this.call(() => this.request<RunnerNavigationBar>('GET', `/navigationBar?bundleId=${encodeURIComponent(bundleId)}`), true);
166
166
  }
167
167
 
168
168
  /**
@@ -170,7 +170,15 @@ export class IosSystemRunner {
170
170
  * the app's state (XCUIApplication.State: 1 not running … 4 in front).
171
171
  */
172
172
  async elements(bundleId: string): Promise<RunnerElements> {
173
- return this.call(() => this.request('GET', `/elements?bundleId=${encodeURIComponent(bundleId)}`));
173
+ return this.call(() => this.request('GET', `/elements?bundleId=${encodeURIComponent(bundleId)}`), true);
174
+ }
175
+
176
+ /**
177
+ * The state of the app `bundleId` alone (XCUIApplication.State: 1 not running, 2 suspended, 3 in the
178
+ * background, 4 in front), without reading its UI: openNotification confirms its tap with it (issue #68).
179
+ */
180
+ async appState(bundleId: string): Promise<number> {
181
+ return (await this.call(() => this.request<{ state: number }>('GET', `/appState?bundleId=${encodeURIComponent(bundleId)}`), true)).state;
174
182
  }
175
183
 
176
184
  /** Type into the focused field of `bundleId` through its keyboard (XCUITest typeText, issue #51). */
@@ -189,18 +197,30 @@ export class IosSystemRunner {
189
197
 
190
198
  /**
191
199
  * A request to the running runner. The runner's test can die while xcodebuild lives on (seen in parallel
192
- * runs, Phase 6.12): nothing listens on its port any more. Then the runner is restarted once.
200
+ * runs, Phase 6.12): nothing listens on its port any more. Or it dies while answering (an XCTest failure
201
+ * ends the test, issue #65): the connection is reset. Then the runner is restarted, and a request that
202
+ * only reads (`readOnly`), or one that never reached it (refused), is sent again once. A tap that may
203
+ * have happened is not repeated: it fails with what the runner printed.
193
204
  */
194
- private async call<T>(request: () => Promise<T>): Promise<T> {
205
+ private async call<T>(request: () => Promise<T>, readOnly = false): Promise<T> {
195
206
  await this.start();
196
207
  try {
197
208
  return await request();
198
209
  } catch (e) {
199
- if (!isConnectionRefused(e)) throw e;
200
- this.options.logger.warn(`the iOS system UI runner stopped answering; restarting it. Its last output:\n${this.output.slice(-1500)}`);
210
+ if (!isRunnerGone(e)) throw e;
211
+ const output = this.output.slice(-1500);
212
+ this.options.logger.warn(`the iOS system UI runner stopped answering (${describeNetworkError(e)}); restarting it. Its last output:\n${output}`);
201
213
  await this.stop();
202
214
  await this.start();
203
- return request();
215
+ if (!readOnly && !isConnectionRefused(e)) {
216
+ throw new QuiescoError('DEVICE_ERROR', `the iOS system UI runner ended while answering (${describeNetworkError(e)}); it was restarted. Its last output:\n${output}`);
217
+ }
218
+ try {
219
+ return await request();
220
+ } catch (again) {
221
+ if (!isRunnerGone(again)) throw again;
222
+ throw new QuiescoError('DEVICE_ERROR', `the iOS system UI runner stopped answering twice (${describeNetworkError(again)}). Its last output:\n${this.output.slice(-1500)}`);
223
+ }
204
224
  }
205
225
  }
206
226
 
@@ -254,6 +274,27 @@ export class IosSystemRunner {
254
274
  }
255
275
  }
256
276
 
277
+ /** The error's network code: `TypeError: fetch failed` carries it in `cause` (undici). */
278
+ function networkCode(e: unknown): string {
279
+ const cause = (e as { cause?: { code?: string } } | null)?.cause;
280
+ return cause?.code ?? '';
281
+ }
282
+
283
+ function describeNetworkError(e: unknown): string {
284
+ return networkCode(e) || String((e as Error | null)?.message ?? e);
285
+ }
286
+
287
+ /**
288
+ * The runner is not there any more: nobody listens (ECONNREFUSED) or it went away while answering
289
+ * (ECONNRESET, a closed socket; issue #65).
290
+ */
291
+ export function isRunnerGone(e: unknown): boolean {
292
+ if (isConnectionRefused(e)) return true;
293
+ const code = networkCode(e);
294
+ if (code === 'ECONNRESET' || code === 'EPIPE' || code === 'UND_ERR_SOCKET' || code === 'UND_ERR_CLOSED') return true;
295
+ return /ECONNRESET|socket hang up|other side closed/.test(String((e as Error | null)?.message ?? ''));
296
+ }
297
+
257
298
  /** fetch() to a port nobody listens on: `TypeError: fetch failed` caused by ECONNREFUSED. */
258
299
  export function isConnectionRefused(e: unknown): boolean {
259
300
  const cause = (e as { cause?: { code?: string } } | null)?.cause;
@@ -35,6 +35,7 @@ import { execCommand } from './exec.js';
35
35
  import { LogBuffer, exited, spawnProcess } from './streams.js';
36
36
  import type { ChildLike, SpawnProcess } from './streams.js';
37
37
  import { IosSystemRunner, PERMISSION_ALLOW, PERMISSION_DENY, backButton, dismissButton, screenNodes } from './ios-runner.js';
38
+ import type { RunnerScreen } from './ios-runner.js';
38
39
  import type { Permission } from './permissions.js';
39
40
  import { SERIAL_WORKER } from './provider.js';
40
41
  import type { ColorScheme, DeviceProvider, InAppControls, LaunchParams, LaunchUrlHandling, NotificationSpec, StateChange, StatusBarOptions, SystemNode, WorkerInfo } from './provider.js';
@@ -138,7 +139,7 @@ export interface IosProviderOptions {
138
139
  }
139
140
 
140
141
  /** What IosProvider uses of IosSystemRunner. */
141
- export type SystemRunnerLike = Pick<IosSystemRunner, 'running' | 'screen' | 'tap' | 'openNotificationCenter' | 'stop'> & Partial<Pick<IosSystemRunner, 'navigationBar' | 'edgeSwipeBack' | 'elements' | 'typeText'>>;
142
+ export type SystemRunnerLike = Pick<IosSystemRunner, 'running' | 'screen' | 'tap' | 'openNotificationCenter' | 'stop'> & Partial<Pick<IosSystemRunner, 'navigationBar' | 'edgeSwipeBack' | 'elements' | 'typeText' | 'appState' | 'start'>>;
142
143
 
143
144
  /** `27.0` / `iOS 27.0` / `27` → does the runtime identifier match? */
144
145
  export function runtimeMatches(runtime: string, version: string): boolean {
@@ -221,6 +222,16 @@ export function uikitNodes(elements: readonly { type: number; label: string; id:
221
222
  });
222
223
  }
223
224
 
225
+ /**
226
+ * Whether `frame` ([x, y, w, h]) looks like the "Open" button a locked device shows beside the tapped
227
+ * notification `b`: in its row, on its left, less than half its width.
228
+ */
229
+ function revealedOpen(frame: number[], b: { x1: number; x2: number; y1: number; y2: number }): boolean {
230
+ const [x = 0, y = 0, w = 0, h = 0] = frame;
231
+ const mid = y + h / 2;
232
+ return mid >= b.y1 && mid <= b.y2 && x + w / 2 < (b.x1 + b.x2) / 2 && w < (b.x2 - b.x1) / 2;
233
+ }
234
+
224
235
  /** Darwin notification state BiometricKit_Sim reads for "enrolled" (1 / 0). */
225
236
  const BIOMETRIC_ENROLLMENT = 'com.apple.BiometricKit.enrollmentChanged';
226
237
 
@@ -229,8 +240,13 @@ const BANNER_WAIT_MS = 2_000;
229
240
  const NOTIFICATION_POLL_MS = 250;
230
241
  /** openUrlFromOutside: how long SpringBoard's "Open in …?" confirmation may take to show up. */
231
242
  const OPEN_URL_CONFIRM_MS = 5_000;
232
- /** After tapping a notification: how long it may stay on screen before it is tapped again, and how often. */
243
+ /**
244
+ * After tapping a notification: how long the app may take to come to the front (or, with a runner that
245
+ * cannot tell, the notification to go away) before Quiesco looks again, and how many taps it makes.
246
+ */
233
247
  const NOTIFICATION_TAP_CONFIRM_MS = 1_500;
248
+ /** The same for a runner that reads the app's state: an app resuming from suspension may take a moment. */
249
+ const NOTIFICATION_FRONT_MS = 3_000;
234
250
  const NOTIFICATION_TAPS = 3;
235
251
 
236
252
  export class IosProvider implements DeviceProvider {
@@ -707,6 +723,11 @@ export class IosProvider implements DeviceProvider {
707
723
  * a web authentication session or Safari, and the app's own UIKit views (an inline date picker, the
708
724
  * keyboard). The app's React views are in that tree too; tapping them is a real touch all the same.
709
725
  */
726
+ /** Start the system UI runner: system UI waits start their clock after it (a cold start takes 7–15 s, issue #64). */
727
+ async prepareSystemUi(): Promise<void> {
728
+ await this.runner.start?.();
729
+ }
730
+
710
731
  async systemNodes(): Promise<SystemNode[]> {
711
732
  const runner = this.runner;
712
733
  const nodes = screenNodes(await runner.screen());
@@ -761,6 +782,7 @@ export class IosProvider implements DeviceProvider {
761
782
  * No confirmation within OPEN_URL_CONFIRM_MS (a link the system opens directly): nothing to answer.
762
783
  */
763
784
  async openUrlFromOutside(url: string): Promise<void> {
785
+ await this.prepareSystemUi();
764
786
  await this.simctl(['openurl', this.udid, url]);
765
787
  const deadline = Date.now() + OPEN_URL_CONFIRM_MS;
766
788
  for (;;) {
@@ -795,44 +817,93 @@ export class IosProvider implements DeviceProvider {
795
817
 
796
818
  /**
797
819
  * Tap the notification titled `title`: its banner while it is shown, else in Notification Center
798
- * (swiped down from the top edge). Banners read "<time>, <title>, <body>". Waits up to `timeoutMs` for it.
820
+ * (swiped down from the top edge). Banners read "<time>, <title>, <body>". Waits up to `timeoutMs` for it,
821
+ * counted once the system UI runner is up (issue #64).
822
+ *
823
+ * A tap counts once the app is in front (issue #68): a banner that slides away by itself under the tap
824
+ * also leaves the screen, but the app stays suspended. Otherwise Quiesco looks again — in Notification
825
+ * Center once the banner is gone — and taps the topmost matching notification: a first tap on a stack of
826
+ * the app's notifications only expands it (issue #65).
799
827
  */
800
828
  async openNotification(title: string, timeoutMs: number): Promise<void> {
801
- const find = async () => (await this.runner.screen()).others.find((o) => o.label.split(', ').includes(title) || o.label.includes(title));
829
+ await this.prepareSystemUi();
830
+ const runner = this.runner;
831
+ const matches = (o: { label: string }) => o.label.split(', ').includes(title) || o.label.includes(title);
832
+ let shown: RunnerScreen['others'] = [];
833
+ // The topmost one: in an expanded stack the newest notification comes first.
834
+ const find = async () => {
835
+ shown = (await runner.screen()).others;
836
+ return shown.filter(matches).sort((a, b) => (a.frame[1] ?? 0) - (b.frame[1] ?? 0))[0];
837
+ };
838
+ const appState = runner.appState?.bind(runner);
839
+ const inFront = async () => appState !== undefined && (await appState(this.bundleId).catch(() => 0)) === RUNNING_FOREGROUND;
802
840
  const start = Date.now();
803
841
  const deadline = start + timeoutMs;
804
842
  let centerOpened = false;
805
843
  let taps = 0;
806
844
  for (;;) {
807
845
  const hit = await find();
808
- if (hit !== undefined) {
809
- // The banner slides in: tap only once two reads agree on where it is, and tap again while the
810
- // notification is still on screen (a tap during the animation misses; the app then stays in the
811
- // background, suspended — batch D 2026-11-13).
846
+ if (hit !== undefined && taps < NOTIFICATION_TAPS && (taps === 0 || Date.now() <= deadline)) {
847
+ // The banner slides in, Notification Center slides down: tap only once two reads a moment apart
848
+ // agree on where it is (a tap during the animation misses; the app then stays in the background,
849
+ // suspended — batch D 2026-11-13).
850
+ await new Promise((r) => setTimeout(r, NOTIFICATION_POLL_MS));
812
851
  const again = await find();
813
852
  if (again === undefined || JSON.stringify(again.frame) !== JSON.stringify(hit.frame)) continue;
853
+ const before = new Set(shown.map((o) => o.label));
854
+ const matching = shown.filter(matches).length;
814
855
  const b = screenNodes({ alerts: [], others: [again] })[0]!.bounds;
815
- await this.runner.tap((b.x1 + b.x2) / 2, (b.y1 + b.y2) / 2);
816
- if (++taps >= NOTIFICATION_TAPS) return;
817
- const until = Date.now() + NOTIFICATION_TAP_CONFIRM_MS;
818
- while (Date.now() < until && (await find()) !== undefined) await new Promise((r) => setTimeout(r, NOTIFICATION_POLL_MS));
819
- if ((await find()) === undefined) return;
820
- this.logger.warn(`openNotification: "${title}" is still on screen after the tap; tapping it again`);
856
+ await runner.tap((b.x1 + b.x2) / 2, (b.y1 + b.y2) / 2);
857
+ taps++;
858
+ // A stack that expanded shows more matching notifications: look again right away.
859
+ const expanded = async () => (await find(), shown.filter(matches).length > matching);
860
+ if (await this.tapOpened(appState !== undefined, inFront, find, deadline, expanded)) return;
861
+ // On a locked device a tap only slides the notification to the right and shows an "Open" button on
862
+ // its left (in the device's language): a new, small button, not a notification, left in that row.
863
+ // Not one on the right ("Clear", "Options"), nor another notification.
864
+ await find();
865
+ const revealed = shown.find((o) => !before.has(o.label) && !matches(o) && !o.label.includes(', ') && revealedOpen(o.frame, b));
866
+ if (revealed !== undefined) {
867
+ const r = screenNodes({ alerts: [], others: [revealed] })[0]!.bounds;
868
+ this.logger.warn(`openNotification: tapping "${title}" showed ${JSON.stringify(revealed.label)} (a locked device); tapping it`);
869
+ await runner.tap((r.x1 + r.x2) / 2, (r.y1 + r.y2) / 2);
870
+ if (await this.tapOpened(appState !== undefined, inFront, find, deadline, async () => false)) return;
871
+ }
872
+ this.logger.warn(`openNotification: the app did not come to the front after tapping "${title}"; looking again`);
821
873
  continue;
822
874
  }
875
+ if (taps > 0 && (await inFront())) return;
823
876
  if (Date.now() > deadline) {
824
- const seen = (await this.runner.screen().catch(() => ({ alerts: [], others: [] }))).others.map((o) => JSON.stringify(o.label)).slice(0, 8);
877
+ const seen = (await runner.screen().catch(() => ({ alerts: [], others: [] }))).others.map((o) => JSON.stringify(o.label)).slice(0, 8);
878
+ if (taps > 0) {
879
+ 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'})`);
880
+ }
825
881
  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())?`);
826
882
  }
827
- // The banner goes away after a few seconds; then the notification is in Notification Center.
828
- if (!centerOpened && Date.now() > start + Math.min(BANNER_WAIT_MS, timeoutMs / 2)) {
829
- await this.runner.openNotificationCenter();
883
+ // The banner goes away after a few seconds (also after a tap that missed it); then the notification is in Notification Center.
884
+ if (!centerOpened && (taps > 0 || Date.now() > start + Math.min(BANNER_WAIT_MS, timeoutMs / 2))) {
885
+ await runner.openNotificationCenter();
830
886
  centerOpened = true;
831
887
  }
832
888
  await new Promise((r) => setTimeout(r, NOTIFICATION_POLL_MS));
833
889
  }
834
890
  }
835
891
 
892
+ /**
893
+ * Whether a notification tap opened the app: the app is in front within NOTIFICATION_FRONT_MS
894
+ * (`knowsState`), else (a runner that cannot tell) the notification went away within NOTIFICATION_TAP_CONFIRM_MS.
895
+ */
896
+ private async tapOpened(knowsState: boolean, inFront: () => Promise<boolean>, find: () => Promise<unknown>, deadline: number, expanded: () => Promise<boolean>): Promise<boolean> {
897
+ // Not past the call's deadline (but one look at least).
898
+ const until = Math.min(Date.now() + (knowsState ? NOTIFICATION_FRONT_MS : NOTIFICATION_TAP_CONFIRM_MS), Math.max(deadline, Date.now()));
899
+ for (;;) {
900
+ if (knowsState ? await inFront() : (await find()) === undefined) return true;
901
+ if (knowsState && (await expanded())) return false;
902
+ if (Date.now() >= until) return false;
903
+ await new Promise((r) => setTimeout(r, NOTIFICATION_POLL_MS));
904
+ }
905
+ }
906
+
836
907
  /** Alerts outlive the app (a relaunch keeps a permission alert up): dismiss what an earlier scenario left. */
837
908
  private async dismissLeftoverAlerts(): Promise<void> {
838
909
  if (this.runnerInstance?.running !== true) return;
@@ -178,6 +178,11 @@ export interface DeviceProvider {
178
178
  * the system brings the app to the front with it. iOS answers the system's "Open in …?" confirmation.
179
179
  */
180
180
  openUrlFromOutside?(url: string): Promise<void>;
181
+ /**
182
+ * Start what reading the system UI needs (iOS: the XCUITest runner, 7–15 s cold). The system UI waits
183
+ * start their clock after it (issue #64).
184
+ */
185
+ prepareSystemUi?(): Promise<void>;
181
186
  /** System UI on screen now that does not belong to the app (dialogs, prompts), topmost window first. */
182
187
  systemNodes?(): Promise<SystemNode[]>;
183
188
  tapSystemNode?(node: SystemNode): Promise<void>;
package/src/driver.ts CHANGED
@@ -85,7 +85,7 @@ const DIALOG: unique symbol = Symbol('dialog');
85
85
  const HOST_MARGIN_MS = 5_000;
86
86
  /** How many of a scenario's `console.error`s the driver keeps. */
87
87
  const MAX_APP_LOG_ERRORS = 50;
88
- /** Upper bound of steps of scrollToEdge / scrollToIndex in the agent (each may take the call timeout). */
88
+ /** Upper bound of steps of scrollToEdge / scrollToIndex / scrollTo in the agent (each may take the call timeout). */
89
89
  const MAX_SCROLL_STEPS = 60;
90
90
 
91
91
  export class Driver {
@@ -523,7 +523,7 @@ export class Driver {
523
523
  this.checkAppRunning(spec.type);
524
524
  const params: ParamsOf<AgentMethods['action']> = { action: spec, mode: opts.mode ?? (await this.mode()), ...syncParams(opts) };
525
525
  // Multi-step scrolls give every step the full timeout in the agent (bounded number of steps).
526
- const steps = spec.type === 'scrollToEdge' || spec.type === 'scrollToIndex' ? MAX_SCROLL_STEPS : 1;
526
+ const steps = spec.type === 'scrollToEdge' || spec.type === 'scrollToIndex' || spec.type === 'scrollTo' ? MAX_SCROLL_STEPS : 1;
527
527
  // A JS dialog the action opens (web alert / confirm / prompt) blocks the page — its scripts, the agent
528
528
  // and Playwright's input — until the test answers it: the action is done once the dialog is up.
529
529
  const dialog = this.watchDialog();