Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `sim-use viewer` now renders snapshots for rotated iOS Simulator windows; the Viewer API accepts the orientation suffix in `describe-ui` outline headers when extracting screen dimensions.
- Four E2E suites (KeyTests, KeyComboTests, KeySequenceTests, StreamVideoTests) still invoked the pre-0.5.x top-level verb forms and had failed ever since the five iOS-only verbs moved under the `ios` namespace; they now call `sim-use ios <verb>`.
- KeyComboTests' Cmd+A test asserted a cleared text field reads nil/empty — an empty `UITextField` exposes its placeholder as the accessibility value, so the assertion could never pass. It now accepts the placeholder form.

Expand Down
10 changes: 5 additions & 5 deletions Sources/SimUse/Viewer/ViewerAPIHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ struct ViewerAPIHandlers {

private func parseAppLine(_ line: String) -> [String: Any]? {
// Match `App: <label> WxH` where W and H are integers and
// `<label>` may contain spaces. The label captures lazily so
// a label like "Notes Folder" doesn't swallow the trailing
// " WxH".
let pattern = #"^App:\s+(.*?)\s+(\d+)x(\d+)\s*$"#
// `<label>` may contain spaces. iOS outlines append the current
// device orientation when rotated, e.g. ` (landscape-right)`;
// accept that suffix while keeping appLabel to the app name.
let pattern = #"^App:\s+(.*?)\s+(\d+)x(\d+)(?:\s+\([^)]+\))?\s*$"#
guard let regex = try? NSRegularExpression(pattern: pattern) else { return nil }
let range = NSRange(line.startIndex..., in: line)
guard let match = regex.firstMatch(in: line, range: range),
Expand Down Expand Up @@ -351,4 +351,4 @@ private enum APIError: Error, CustomStringConvertible {
return "sim-use exited \(status): \(message)"
}
}
}
}
19 changes: 19 additions & 0 deletions Tests/ViewerAPIHandlersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,23 @@ struct ViewerAPIHandlersTests {
#expect(devices.count == 1)
#expect(devices.first?["deviceId"] as? String == "ABC")
}

@Test("snapshot: rotated iOS outline still carries screen dimensions")
func snapshotParsesRotatedScreenLine() async throws {
let envelope = """
{"ok":true,"data":{"platform":"ios","outline":"App: SampleApp 874x402 (landscape-right)\\n\\n[Top y<120]\\n","entries":[],"lists":[]}}
"""
let (handlers, cleanup) = try makeHandlers(stdout: envelope, exitCode: 0)
defer { cleanup() }

let response = await handlers.snapshot(getRequest(query: ["deviceId": "TEST-UDID"]))

#expect(response.status == 200)
let body = try jsonBody(response)
#expect(body["ok"] as? Bool == true)
let screen = try #require(body["screen"] as? [String: Any])
#expect(screen["appLabel"] as? String == "SampleApp")
#expect(screen["width"] as? Int == 874)
#expect(screen["height"] as? Int == 402)
}
}
Loading