Commit e2a036a3de

e2a036a3dead43adde73d36fa73ebf9ab7755d0e

parent: 1dac505ef5

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-22 19:08 UTC

Audit every step of every model; recognise reorient steps by kind

Ref #7

Layout: unified · split

App/Sources/StepView.swift +11
@@ -88,6 +88,7 @@ struct StepView: View {
88 if Self.isUITesting { 88 if Self.isUITesting {
89 foldPath(session) 89 foldPath(session)
90 cameraValue(session) 90 cameraValue(session)
91 stepKind(session)
91 } 92 }
92 } 93 }
93 } 94 }
@@ -108,6 +109,16 @@ struct StepView: View {
108 .accessibilityIdentifier("fold.path") 109 .accessibilityIdentifier("fold.path")
109 } 110 }
110 111
112 /// For UI tests: the step's kind, as in `krz:step`.
113 private func stepKind(_ session: FoldSession) -> some View {
114 Color.clear
115 .frame(width: 1, height: 1)
116 .allowsHitTesting(false)
117 .accessibilityElement()
118 .accessibilityValue(session.step.kind.rawValue)
119 .accessibilityIdentifier("step.kind")
120 }
121
111 /// For UI tests: the camera's eye, up and field of view, to 3 decimals. 122 /// For UI tests: the camera's eye, up and field of view, to 3 decimals.
112 private func cameraValue(_ session: FoldSession) -> some View { 123 private func cameraValue(_ session: FoldSession) -> some View {
113 let camera = session.camera 124 let camera = session.camera
App/UITests/AccessibilityAuditTests.swift +24 −16
@@ -1,13 +1,15 @@
1import XCTest 1import XCTest
2 2
3/// Opens every step of the cup by the labels VoiceOver sees and runs Xcode's accessibility audit 3/// Opens every step of every model by the labels VoiceOver sees and runs Xcode's accessibility audit
4/// on each screen, at the default text size and at the largest accessibility size. Also checks 4/// on each screen, at the default text size and at the largest accessibility size. Also checks
5/// that two-finger gestures on the paper change the view without advancing the fold or touching 5/// that two-finger gestures on the paper change the view without advancing the fold or touching
6/// the diagram. XCUITest has no two-finger drag, so a pinch and a rotation stand in for it. 6/// the diagram. XCUITest has no two-finger drag, so a pinch and a rotation stand in for it.
7final class AccessibilityAuditTests: XCTestCase { 7final class AccessibilityAuditTests: XCTestCase {
8 static let largestText = "UICTContentSizeCategoryAccessibilityXXXL" 8 static let largestText = "UICTContentSizeCategoryAccessibilityXXXL"
9 /// Elements that exist only under `-UITesting`. 9 /// Elements that exist only under `-UITesting`.
10 static let testHooks: Set<String> = ["fold.path", "paper.camera"] 10 static let testHooks: Set<String> = ["fold.path", "paper.camera", "step.kind"]
11 /// Every model in the list, by title, with its number of steps.
12 static let models = [("Cup", 6), ("Box", 12)]
11 13
12 private var sizeName = "" 14 private var sizeName = ""
13 15
@@ -59,7 +61,8 @@ final class AccessibilityAuditTests: XCTestCase {
59 61
60 // MARK: - Helpers 62 // MARK: - Helpers
61 63
62 /// The model list, then every step of the cup, each advanced by the user's own drag. 64 /// The model list, then every step of every model, each advanced by the user's own drag: a
65 /// reorient drag on a turn-over or rotate step, the fold drag otherwise.
63 private func everyScreen(textSize: String?) throws { 66 private func everyScreen(textSize: String?) throws {
64 sizeName = textSize == nil ? "default" : "largest" 67 sizeName = textSize == nil ? "default" : "largest"
65 let app = XCUIApplication() 68 let app = XCUIApplication()
@@ -67,21 +70,26 @@ final class AccessibilityAuditTests: XCTestCase {
67 if let textSize { app.launchArguments += ["-UIPreferredContentSizeCategoryName", textSize] } 70 if let textSize { app.launchArguments += ["-UIPreferredContentSizeCategoryName", textSize] }
68 app.launch() 71 app.launch()
69 try audit(app, "models") 72 try audit(app, "models")
70 app.buttons["Cup"].tap() 73 for (title, steps) in Self.models {
71 let index = app.staticTexts["step.index"] 74 app.buttons[title].tap()
72 XCTAssertTrue(index.waitForExistence(timeout: 5)) 75 let index = app.staticTexts["step.index"]
73 while true { 76 XCTAssertTrue(index.waitForExistence(timeout: 5))
74 let step = index.label 77 while true {
75 try audit(app, "step \(step)") 78 let step = index.label
76 if app.staticTexts["diagram.caption"].label.hasPrefix("Turn over") { 79 try audit(app, "\(title) step \(step)")
77 dragAcross(app.otherElements["fold.paper"]) 80 if ["turnOver", "rotate"].contains(stepKind(app)) {
78 } else { 81 dragAcross(app.otherElements["fold.paper"])
79 completeCurrentFold(app) 82 } else {
83 completeCurrentFold(app)
84 }
85 if index.label == step { break }
80 } 86 }
81 if index.label == step { break } 87 // Stopping before the last step means an advance failed.
88 XCTAssertEqual(index.label, "\(steps)", title)
89 try audit(app, "\(title) finished")
90 app.navigationBars.buttons.firstMatch.tap()
91 XCTAssertTrue(app.buttons[title].waitForExistence(timeout: 5))
82 } 92 }
83 // The cup has six steps; stopping earlier means an advance failed.
84 XCTAssertEqual(index.label, "6")
85 } 93 }
86 94
87 private func audit(_ app: XCUIApplication, _ name: String) throws { 95 private func audit(_ app: XCUIApplication, _ name: String) throws {
App/UITests/ReorientGestureTests.swift +8 −1
@@ -64,13 +64,20 @@ final class ReorientGestureTests: XCTestCase {
64/// Completes the current model's fold steps up to its first turn-over. The app must be launched 64/// Completes the current model's fold steps up to its first turn-over. The app must be launched
65/// with `-UITesting`. 65/// with `-UITesting`.
66func advanceToFirstTurnOverStep(_ app: XCUIApplication) { 66func advanceToFirstTurnOverStep(_ app: XCUIApplication) {
67 while !app.staticTexts["diagram.caption"].label.hasPrefix("Turn over") { 67 while stepKind(app) != "turnOver" {
68 let step = app.staticTexts["step.index"].label 68 let step = app.staticTexts["step.index"].label
69 completeCurrentFold(app) 69 completeCurrentFold(app)
70 XCTAssertNotEqual(app.staticTexts["step.index"].label, step) 70 XCTAssertNotEqual(app.staticTexts["step.index"].label, step)
71 } 71 }
72} 72}
73 73
74/// The current step's kind, as in `krz:step`. The app must be launched with `-UITesting`.
75func stepKind(_ app: XCUIApplication) -> String {
76 let kind = app.descendants(matching: .any)["step.kind"]
77 XCTAssertTrue(kind.waitForExistence(timeout: 5))
78 return kind.value as? String ?? ""
79}
80
74/// A rightward drag across most of the element's width, at its middle. It starts clear of the 81/// A rightward drag across most of the element's width, at its middle. It starts clear of the
75/// screen's left edge, where a drag would go back in the navigation stack. 82/// screen's left edge, where a drag would go back in the navigation stack.
76func dragAcross(_ element: XCUIElement) { 83func dragAcross(_ element: XCUIElement) {