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 {
8888 if Self.isUITesting {
8989 foldPath(session)
9090 cameraValue(session)
91 stepKind(session)
9192 }
9293 }
9394 }
@@ -108,6 +109,16 @@ struct StepView: View {
108109 .accessibilityIdentifier("fold.path")
109110 }
110111
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
111122 /// For UI tests: the camera's eye, up and field of view, to 3 decimals.
112123 private func cameraValue(_ session: FoldSession) -> some View {
113124 let camera = session.camera
App/UITests/AccessibilityAuditTests.swift +24 −16
@@ -1,13 +1,15 @@
11import XCTest
22
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
44/// on each screen, at the default text size and at the largest accessibility size. Also checks
55/// that two-finger gestures on the paper change the view without advancing the fold or touching
66/// the diagram. XCUITest has no two-finger drag, so a pinch and a rotation stand in for it.
77final class AccessibilityAuditTests: XCTestCase {
88 static let largestText = "UICTContentSizeCategoryAccessibilityXXXL"
99 /// 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)]
1113
1214 private var sizeName = ""
1315
@@ -59,7 +61,8 @@ final class AccessibilityAuditTests: XCTestCase {
5961
6062 // MARK: - Helpers
6163
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.
6366 private func everyScreen(textSize: String?) throws {
6467 sizeName = textSize == nil ? "default" : "largest"
6568 let app = XCUIApplication()
@@ -67,21 +70,26 @@ final class AccessibilityAuditTests: XCTestCase {
6770 if let textSize { app.launchArguments += ["-UIPreferredContentSizeCategoryName", textSize] }
6871 app.launch()
6972 try audit(app, "models")
70 app.buttons["Cup"].tap()
71 let index = app.staticTexts["step.index"]
72 XCTAssertTrue(index.waitForExistence(timeout: 5))
73 while true {
74 let step = index.label
75 try audit(app, "step \(step)")
76 if app.staticTexts["diagram.caption"].label.hasPrefix("Turn over") {
77 dragAcross(app.otherElements["fold.paper"])
78 } else {
79 completeCurrentFold(app)
73 for (title, steps) in Self.models {
74 app.buttons[title].tap()
75 let index = app.staticTexts["step.index"]
76 XCTAssertTrue(index.waitForExistence(timeout: 5))
77 while true {
78 let step = index.label
79 try audit(app, "\(title) step \(step)")
80 if ["turnOver", "rotate"].contains(stepKind(app)) {
81 dragAcross(app.otherElements["fold.paper"])
82 } else {
83 completeCurrentFold(app)
84 }
85 if index.label == step { break }
8086 }
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))
8292 }
83 // The cup has six steps; stopping earlier means an advance failed.
84 XCTAssertEqual(index.label, "6")
8593 }
8694
8795 private func audit(_ app: XCUIApplication, _ name: String) throws {
App/UITests/ReorientGestureTests.swift +8 −1
@@ -64,13 +64,20 @@ final class ReorientGestureTests: XCTestCase {
6464/// Completes the current model's fold steps up to its first turn-over. The app must be launched
6565/// with `-UITesting`.
6666func advanceToFirstTurnOverStep(_ app: XCUIApplication) {
67 while !app.staticTexts["diagram.caption"].label.hasPrefix("Turn over") {
67 while stepKind(app) != "turnOver" {
6868 let step = app.staticTexts["step.index"].label
6969 completeCurrentFold(app)
7070 XCTAssertNotEqual(app.staticTexts["step.index"].label, step)
7171 }
7272}
7373
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
7481/// A rightward drag across most of the element's width, at its middle. It starts clear of the
7582/// screen's left edge, where a drag would go back in the navigation stack.
7683func dragAcross(_ element: XCUIElement) {