From 198f258a1201fb5ea3088b6a4257fb2436e34368 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 19 Oct 2026 16:24:37 -0700 Subject: [PATCH] test(ios): go back and pick table rows from SNOWBOUND_SCRIPT `back` pops the innermost navigation stack shown, as a compact window's Back button does, and activate: picks a table's row. Assisted-by: claude-opus-5.5 --- apps/ios/Snowbound/Script.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/ios/Snowbound/Script.swift b/apps/ios/Snowbound/Script.swift index 3149e4aff85e9b191962966931d20686a547934a..13bcd2148c32ce39a1adf35713610c62040d6293 100644 --- a/apps/ios/Snowbound/Script.swift +++ b/apps/ios/Snowbound/Script.swift @@ -21,7 +21,8 @@ extension CanvasView { /// screenshot command; `snap:a` only logs, for a simulator screenshot with the keyboard; /// `activate:Label` activates the element of any window so named, as VoiceOver would, /// opening a button's menu or picking a menu's item or a list's row (`Row/Button` for a - /// button in a row), and `audit` logs whether the format bar and tag grid name every button. + /// button in a row), `back` goes back, and `audit` logs whether the format bar and tag grid + /// name every button. func runScript() { // Only the first page shown runs it, not every page opened afterwards. guard !scriptedPage, let script = ProcessInfo.processInfo.environment["SNOWBOUND_SCRIPT"] else { return } @@ -103,6 +104,13 @@ extension CanvasView { let caret = caretRect(for: range.start) menu.presentEditMenu(with: UIEditMenuConfiguration(identifier: nil, sourcePoint: CGPoint(x: caret.midX, y: caret.minY))) case "done": _ = resignFirstResponder() + case "back": + // The innermost navigation stack shown, as its Back button pops it. + func stacks(_ controller: UIViewController) -> [UINavigationController] { + controller.children.flatMap(stacks) + [controller as? UINavigationController].compactMap { $0 } + } + let shown = Self.windows.compactMap(\.rootViewController).flatMap(stacks) + shown.first { $0.viewControllers.count > 1 && $0.viewIfLoaded?.window != nil }?.popViewController(animated: true) case "wait", "snap": break case "activate": // An alert's button, which takes no accessibility activation outside VoiceOver. @@ -144,6 +152,11 @@ extension CanvasView { list.selectItem(at: index, animated: false, scrollPosition: []) list.delegate?.collectionView?(list, didSelectItemAt: index) } + } else if let cell = found as? UITableViewCell, let table = chain.lazy.compactMap({ $0 as? UITableView }).first, + let index = table.indexPath(for: cell) + { + table.selectRow(at: index, animated: false, scrollPosition: .none) + table.delegate?.tableView?(table, didSelectRowAt: index) } else if !found.accessibilityActivate(), let control = found as? UIControl { control.sendActions(for: .primaryActionTriggered) } -- 2.54.1