@craft-native/ios 0.0.212 → 0.0.213

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/ios",
3
- "version": "0.0.212",
3
+ "version": "0.0.213",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -87,6 +87,13 @@ final class DriverTests: XCTestCase {
87
87
  XCTAssertTrue(ok, what)
88
88
  }
89
89
 
90
+ /// testIDs are exact identifiers. Resolving a unique element with the
91
+ /// subscript scans the whole accessibility tree for ambiguous matches;
92
+ /// firstMatch can stop at the identified node, including a scrolled row.
93
+ func identified(_ id: String) -> XCUIElement {
94
+ app.descendants(matching: .any).matching(NSPredicate(format: "identifier == %@", id)).firstMatch
95
+ }
96
+
90
97
  func element(containing text: String, in target: XCUIApplication? = nil) -> XCUIElement? {
91
98
  let root = target ?? app
92
99
  let predicate = NSPredicate(format: "label CONTAINS[c] %@ OR value CONTAINS[c] %@ OR identifier == %@", text, text, text)
@@ -197,7 +204,7 @@ final class DriverTests: XCTestCase {
197
204
  switch command {
198
205
  case "ifid":
199
206
  let rest = arg.split(separator: " ", maxSplits: 1).map(String.init)
200
- if rest.count == 2, app.descendants(matching: .any)[rest[0]].waitForExistence(timeout: 3) { note("ifid \(rest[0]): shown"); run(rest[1]) }
207
+ if rest.count == 2, identified(rest[0]).waitForExistence(timeout: 3) { note("ifid \(rest[0]): shown"); run(rest[1]) }
201
208
  else { note("ifid \(rest.first ?? ""): not shown") }
202
209
  case "launch": app.launch()
203
210
  case "activate": app.activate()
@@ -261,7 +268,7 @@ final class DriverTests: XCTestCase {
261
268
  if let target = poll(10, { exact(arg) }) { press(target); note("tapexact \(arg): ok") }
262
269
  else { XCTFail("Element not found"); note("FAIL tapexact \(arg): NOT FOUND") }
263
270
  case "tapid":
264
- let target = app.descendants(matching: .any)[arg]
271
+ let target = identified(arg)
265
272
  if target.waitForExistence(timeout: 10) { press(target); note("tapid \(arg): ok") }
266
273
  else { XCTFail("Element not found"); note("FAIL tapid \(arg): NOT FOUND") }
267
274
  case "tapxy":
@@ -281,7 +288,7 @@ final class DriverTests: XCTestCase {
281
288
  case "return": app.typeText(XCUIKeyboardKey.return.rawValue); note("return")
282
289
  case "typeid":
283
290
  let idParts = arg.split(separator: " ", maxSplits: 1).map(String.init)
284
- let target = app.descendants(matching: .any)[idParts[0]]
291
+ let target = identified(idParts[0])
285
292
  if target.waitForExistence(timeout: 10) {
286
293
  target.tap()
287
294
  Thread.sleep(forTimeInterval: 0.8)
@@ -306,15 +313,15 @@ final class DriverTests: XCTestCase {
306
313
  check(poll(seconds, { exact(text) }) != nil, "expectexact \(text)")
307
314
  case "expectid":
308
315
  let (id, seconds) = split(arg)
309
- check(app.descendants(matching: .any)[id].waitForExistence(timeout: seconds), "expectid \(id)")
316
+ check(identified(id).waitForExistence(timeout: seconds), "expectid \(id)")
310
317
  case "labelid":
311
318
  let idParts = arg.split(separator: " ", maxSplits: 1).map(String.init)
312
- let target = app.descendants(matching: .any)[idParts[0]]
319
+ let target = identified(idParts[0])
313
320
  let want = idParts.count > 1 ? idParts[1] : ""
314
321
  let seen = target.waitForExistence(timeout: 5) ? target.label : "(missing)"
315
322
  check(seen == want, "labelid \(idParts[0]) \(want) (saw \(seen))")
316
323
  case "absentid":
317
- check(!app.descendants(matching: .any)[arg].exists, "absentid \(arg)")
324
+ check(!identified(arg).exists, "absentid \(arg)")
318
325
  case "absent":
319
326
  check(element(containing: arg) == nil, "absent \(arg)")
320
327
  case "tabbar":