From 3617652cdf0f681b6b1486a38b8c75df8b87f66c Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:39:53 -0500 Subject: [PATCH 01/10] Screenshots workflow: UI test against the App Review demo account A Screenshots scheme runs a UI test on the newest Pro Max simulator and saves each shot, plus its accessibility tree, as a short-lived artifact. The demo account is signed in by a hook compiled only with the SCREENSHOTS flag. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/screenshots.yml | 84 +++++++++++ config/project.yml | 22 +++ src/App/AppModel.swift | 3 + src/Auth/ScreenshotAccount.swift | 24 +++ .../ScreenshotTests.swift | 139 ++++++++++++++++++ 5 files changed, 272 insertions(+) create mode 100644 .github/workflows/screenshots.yml create mode 100644 src/Auth/ScreenshotAccount.swift create mode 100644 tests/CloudrollScreenshots/ScreenshotTests.swift diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml new file mode 100644 index 0000000..ae52bcd --- /dev/null +++ b/.github/workflows/screenshots.yml @@ -0,0 +1,84 @@ +name: Screenshots + +# App Store screenshots (6.9" iPhone, 1320 x 2868) against the App Review demo account. +# Started by hand (Actions → Screenshots → Run workflow) or by pushing to the screenshots branch. +# Needs three secrets: CLOUDROLL_DEMO_SERVER, CLOUDROLL_DEMO_LOGIN and +# CLOUDROLL_DEMO_APP_PASSWORD (an app password for the demo user, revocable in its +# Nextcloud security settings). The SCREENSHOTS flag compiles in the sign-in hook +# (src/Auth/ScreenshotAccount.swift); no other build has it. +on: + workflow_dispatch: + push: + branches: [screenshots] + +jobs: + capture: + runs-on: macos-26 + env: + CLOUDROLL_DEMO_SERVER: ${{ secrets.CLOUDROLL_DEMO_SERVER }} + CLOUDROLL_DEMO_LOGIN: ${{ secrets.CLOUDROLL_DEMO_LOGIN }} + CLOUDROLL_DEMO_APP_PASSWORD: ${{ secrets.CLOUDROLL_DEMO_APP_PASSWORD }} + steps: + - uses: actions/checkout@v4 + - name: Check secrets + run: | + for name in CLOUDROLL_DEMO_SERVER CLOUDROLL_DEMO_LOGIN CLOUDROLL_DEMO_APP_PASSWORD; do + if [ -z "${!name}" ]; then echo "Missing secret $name" >&2; exit 1; fi + done + - name: Install XcodeGen + run: brew install xcodegen + - name: Generate project + run: xcodegen generate --spec config/project.yml --project . + - name: Boot a 6.9-inch iPhone + run: | + # The newest Pro Max on the runner; its screenshots are 1320 x 2868. + DEVICE_ID=$(xcrun simctl list devices available -j \ + | jq -r '[.devices | to_entries[] | select(.key | contains("iOS")) | .value[] | select(.name | endswith("Pro Max"))] | last | .udid') + if [ -z "$DEVICE_ID" ] || [ "$DEVICE_ID" = "null" ]; then + echo "No Pro Max simulator on this runner" >&2 + xcrun simctl list devices available + exit 1 + fi + echo "DEVICE_ID=$DEVICE_ID" >> "$GITHUB_ENV" + xcrun simctl boot "$DEVICE_ID" + xcrun simctl bootstatus "$DEVICE_ID" + xcrun simctl status_bar "$DEVICE_ID" override --time 9:41 --dataNetwork wifi --wifiMode active \ + --wifiBars 3 --cellularMode active --cellularBars 4 --batteryState charged --batteryLevel 100 + xcrun simctl privacy "$DEVICE_ID" grant photos io.github.keasbeexd.cloudroll || true + - name: Add phone photos + run: | + # Unsplash photos via picsum.photos, free to use. They're dated today, so they + # sit at the top of the timeline above the demo account's server photos. + mkdir -p phone-photos + for id in 1018 1043 1050; do + curl -sfL -o "phone-photos/phone-$id.jpg" "https://picsum.photos/id/$id/1600/1200.jpg" + done + xcrun simctl addmedia "$DEVICE_ID" phone-photos/*.jpg + - name: Capture + run: | + mkdir -p "$RUNNER_TEMP/shots" + xcodebuild -project Cloudroll.xcodeproj -scheme Screenshots \ + -destination "id=$DEVICE_ID" -resultBundlePath "$RUNNER_TEMP/Screenshots.xcresult" \ + test CODE_SIGNING_ALLOWED=NO \ + SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG SCREENSHOTS' + env: + TEST_RUNNER_SCREENSHOT_DIR: ${{ runner.temp }}/shots + TEST_RUNNER_CLOUDROLL_DEMO_SERVER: ${{ secrets.CLOUDROLL_DEMO_SERVER }} + TEST_RUNNER_CLOUDROLL_DEMO_LOGIN: ${{ secrets.CLOUDROLL_DEMO_LOGIN }} + TEST_RUNNER_CLOUDROLL_DEMO_APP_PASSWORD: ${{ secrets.CLOUDROLL_DEMO_APP_PASSWORD }} + TEST_RUNNER_CLOUDROLL_DEMO_NAME: App Review + - name: Export attachments + if: always() + run: | + mkdir -p "$RUNNER_TEMP/shots/attachments" + xcrun xcresulttool export attachments --path "$RUNNER_TEMP/Screenshots.xcresult" \ + --output-path "$RUNNER_TEMP/shots/attachments" || true + ls -la "$RUNNER_TEMP/shots" "$RUNNER_TEMP/shots/attachments" + # The accessibility dumps can name the demo server, so the artifact is short-lived + # and gets deleted once downloaded. + - uses: actions/upload-artifact@v4 + if: always() + with: + name: screenshots + path: ${{ runner.temp }}/shots + retention-days: 1 diff --git a/config/project.yml b/config/project.yml index 3fd6b38..8098c58 100644 --- a/config/project.yml +++ b/config/project.yml @@ -85,3 +85,25 @@ targets: base: PRODUCT_BUNDLE_IDENTIFIER: io.github.keasbeexd.cloudroll.tests GENERATE_INFOPLIST_FILE: YES + # App Store screenshots, run only by .github/workflows/screenshots.yml (Screenshots scheme). + CloudrollScreenshots: + type: bundle.ui-testing + platform: iOS + sources: + - path: ../tests/CloudrollScreenshots + dependencies: + - target: Cloudroll + settings: + base: + PRODUCT_BUNDLE_IDENTIFIER: io.github.keasbeexd.cloudroll.screenshots + GENERATE_INFOPLIST_FILE: YES + TEST_TARGET_NAME: Cloudroll +schemes: + Screenshots: + build: + targets: + Cloudroll: all + CloudrollScreenshots: [test] + test: + config: Debug + targets: [CloudrollScreenshots] diff --git a/src/App/AppModel.swift b/src/App/AppModel.swift index 1aed4a8..343feb6 100644 --- a/src/App/AppModel.swift +++ b/src/App/AppModel.swift @@ -19,6 +19,9 @@ final class AppModel { if try AccountStore.migrateLegacy() != nil { AccountDataStore.clearLegacyLater() } + #if SCREENSHOTS + try ScreenshotAccount.installFromEnvironment() + #endif accounts = try AccountStore.load() currentID = AccountStore.currentID.flatMap { id in accounts.first { $0.id == id }?.id } ?? accounts.first?.id } catch { diff --git a/src/Auth/ScreenshotAccount.swift b/src/Auth/ScreenshotAccount.swift new file mode 100644 index 0000000..b079770 --- /dev/null +++ b/src/Auth/ScreenshotAccount.swift @@ -0,0 +1,24 @@ +#if SCREENSHOTS +import Foundation + +/// Signs in the App Review demo account for the screenshot run, which can't drive the +/// browser sheet. Only compiled with the SCREENSHOTS flag that .github/workflows/screenshots.yml +/// sets, so TestFlight and App Store builds never contain it. +enum ScreenshotAccount { + /// Fixed, so every run replaces the same Keychain item. + private static let id = UUID(uuidString: "5C2EE45A-0000-4000-8000-000000000001")! + + static func installFromEnvironment() throws { + let env = ProcessInfo.processInfo.environment + guard let serverInput = env["CLOUDROLL_DEMO_SERVER"], + let server = ServerURL.root(from: serverInput), + let login = env["CLOUDROLL_DEMO_LOGIN"], !login.isEmpty, + let password = env["CLOUDROLL_DEMO_APP_PASSWORD"], !password.isEmpty + else { return } + + let credential = Credential(server: server, loginName: login, appPassword: password) + try AccountStore.save(Account(id: id, credential: credential, displayName: env["CLOUDROLL_DEMO_NAME"])) + AccountStore.currentID = id + } +} +#endif diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift new file mode 100644 index 0000000..3bf1084 --- /dev/null +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -0,0 +1,139 @@ +import XCTest + +/// Captures the App Store screenshots against the App Review demo account. +/// Run by .github/workflows/screenshots.yml, which passes the account in through +/// TEST_RUNNER_ variables and builds the app with the SCREENSHOTS flag. +/// Each step saves a PNG and the accessibility tree, and a missing element skips that +/// shot instead of failing the run, so one run shows everything that went wrong. +final class ScreenshotTests: XCTestCase { + private let app = XCUIApplication() + private let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") + private var outputDir: URL! + private var problems: [String] = [] + + override func setUpWithError() throws { + continueAfterFailure = true + let env = ProcessInfo.processInfo.environment + outputDir = URL(fileURLWithPath: env["SCREENSHOT_DIR"] ?? NSTemporaryDirectory()) + try FileManager.default.createDirectory(at: outputDir, withIntermediateDirectories: true) + for key in ["CLOUDROLL_DEMO_SERVER", "CLOUDROLL_DEMO_LOGIN", "CLOUDROLL_DEMO_APP_PASSWORD", "CLOUDROLL_DEMO_NAME"] { + app.launchEnvironment[key] = env[key] + } + } + + func testCaptureScreenshots() throws { + app.launch() + allowPhotoAccessIfAsked() + + guard app.buttons["Cloudroll Settings"].waitForExistence(timeout: 180) else { + save("00-not-loaded") + XCTFail("The timeline never loaded") + return + } + allowPhotoAccessIfAsked() + pause(10) // thumbnails + save("01-timeline") + + // A server photo with a location, so the info panel shows the map. + if openPhoto(named: "IMG_1006") { + pause(4) + save("02-viewer") + if tap(app.buttons["Info"], "Info") { + pause(4) + save("03-info") + app.swipeDown(velocity: .fast) + pause(1) + } + closeViewer() + } + + if openPhoto(named: "IMG_2074") { + pause(5) + save("04-live-photo") + closeViewer() + } + + // Phone photos open Cloudroll's own editor. + if openPhoto(named: nil) { + pause(3) + save("05-phone-photo") + if tap(app.buttons["Edit"], "Edit") { + pause(4) + save("06-editor") + let cancel = app.buttons["Cancel"] + if cancel.exists { cancel.tap() } + pause(2) + } + closeViewer() + } + + if tap(app.buttons["Cloudroll Settings"], "Cloudroll Settings") { + pause(3) + save("07-settings") + } + + try problems.joined(separator: "\n").write(to: outputDir.appending(path: "problems.txt"), atomically: true, encoding: .utf8) + } + + // MARK: - Steps + + /// Opens a timeline photo whose web element label contains `name`, or the first one. + private func openPhoto(named name: String?) -> Bool { + let images = app.webViews.firstMatch.images + let match: XCUIElement + if let name { + match = images.matching(NSPredicate(format: "label CONTAINS[c] %@", name)).firstMatch + } else { + match = images.firstMatch + } + guard match.waitForExistence(timeout: 10), match.isHittable else { + problems.append("No hittable photo for \(name ?? "first photo")") + save("missing-\(name ?? "first")") + return false + } + match.tap() + return app.buttons["Info"].waitForExistence(timeout: 15) + } + + private func closeViewer() { + let close = app.buttons["Close"] + if close.exists { close.tap() } + pause(2) + } + + private func allowPhotoAccessIfAsked() { + let ownPrompt = app.buttons["Allow access"] + if ownPrompt.waitForExistence(timeout: 5) { ownPrompt.tap() } + for label in ["Allow Full Access", "Allow Access to All Photos", "Allow"] { + let button = springboard.buttons[label] + if button.waitForExistence(timeout: 3) { + button.tap() + break + } + } + } + + @discardableResult + private func tap(_ element: XCUIElement, _ what: String) -> Bool { + guard element.waitForExistence(timeout: 10), element.isHittable else { + problems.append("Couldn't tap \(what)") + return false + } + element.tap() + return true + } + + private func pause(_ seconds: TimeInterval) { + Thread.sleep(forTimeInterval: seconds) + } + + private func save(_ name: String) { + let shot = XCUIScreen.main.screenshot() + let attachment = XCTAttachment(screenshot: shot) + attachment.name = name + attachment.lifetime = .keepAlways + add(attachment) + try? shot.pngRepresentation.write(to: outputDir.appending(path: "\(name).png")) + try? app.debugDescription.write(to: outputDir.appending(path: "\(name).txt"), atomically: true, encoding: .utf8) + } +} From 301c281507f68131d4ef3dd6327a55423980ebc6 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:52:08 -0500 Subject: [PATCH 02/10] Roadmap: trademark check done, keeping the name [skip ci] Co-Authored-By: Claude Opus 5.5 --- docs/roadmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/roadmap.md b/docs/roadmap.md index 89fe8ac..ee03abc 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -42,7 +42,7 @@ Cloudroll is free, with every feature included. It's funded by optional donation - [ ] Register the bundle ID `io.github.keasbeexd.cloudroll` (reverse of keasbeexd.github.io, where the site lives; persisted identifiers such as the Keychain services and the PhotoKit edit format keep their `app.cloudroll` prefix) - [ ] Privacy policy (GitHub Pages) and privacy label ("Data not collected") - [ ] Screenshots generated in the simulator, store listing, a demo account for Apple's reviewers -- [ ] Trademark: check the EU/TMview result, avoid Nextcloud and Memories logos, include a "not affiliated" line +- [x] Trademark: US CLOUDROLL (CITE, reg 5056909) is cancelled, but CITE's EU mark 014736896 (figurative, classes 9/35/42) is live until 2035, plus a Greek national mark. Checked on TMview 2026-11-10; decided to keep the name and launch everywhere. No Nextcloud or Memories logos in the listing or screenshots; "not affiliated" line in the listing and README ## Phase 4: Updates From 71e779f2c479e32055d9f2d6cd81f6535fc44bcd Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:53:25 -0500 Subject: [PATCH 03/10] Run screenshots Co-Authored-By: Claude Opus 5.5 From 6ef95d7310780d446ff2c7eb7d90a0896aba0eb8 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:08:24 -0500 Subject: [PATCH 04/10] Screenshots: sign ad hoc so the app can use the Keychain Co-Authored-By: Claude Opus 5.5 --- .github/workflows/screenshots.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index ae52bcd..7f99615 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -54,12 +54,14 @@ jobs: curl -sfL -o "phone-photos/phone-$id.jpg" "https://picsum.photos/id/$id/1600/1200.jpg" done xcrun simctl addmedia "$DEVICE_ID" phone-photos/*.jpg + # Signed ad hoc ("Sign to Run Locally") rather than unsigned: the simulator only + # grants Keychain access to a signed app. - name: Capture run: | mkdir -p "$RUNNER_TEMP/shots" xcodebuild -project Cloudroll.xcodeproj -scheme Screenshots \ -destination "id=$DEVICE_ID" -resultBundlePath "$RUNNER_TEMP/Screenshots.xcresult" \ - test CODE_SIGNING_ALLOWED=NO \ + test CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=- DEVELOPMENT_TEAM= \ SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG SCREENSHOTS' env: TEST_RUNNER_SCREENSHOT_DIR: ${{ runner.temp }}/shots From 05ab1d1e6624b0acf0c037c1f10bbe71275cd396 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:33:08 -0500 Subject: [PATCH 05/10] Screenshots: time the demo server from the runner Co-Authored-By: Claude Opus 5.5 --- .github/workflows/screenshots.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 7f99615..d330394 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -25,6 +25,14 @@ jobs: for name in CLOUDROLL_DEMO_SERVER CLOUDROLL_DEMO_LOGIN CLOUDROLL_DEMO_APP_PASSWORD; do if [ -z "${!name}" ]; then echo "Missing secret $name" >&2; exit 1; fi done + # The app gives up on the server after 15 seconds; show how the runner fares. + - name: Check the demo server + run: | + for path in status.php index.php/apps/memories/api/describe index.php/apps/memories/; do + curl -s -o /dev/null -m 60 -u "$CLOUDROLL_DEMO_LOGIN:$CLOUDROLL_DEMO_APP_PASSWORD" \ + -w "$path: %{http_code} connect %{time_connect}s total %{time_total}s\n" \ + "$CLOUDROLL_DEMO_SERVER/$path" || echo "$path: curl failed ($?)" + done - name: Install XcodeGen run: brew install xcodegen - name: Generate project From b9a286c741d839e5cb11e25c773ad8b11459e8f2 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:46:43 -0500 Subject: [PATCH 06/10] Screenshots: open photos by position and swipe through the viewer The web timeline's thumbnails aren't in the accessibility tree. Also wait for the system photo prompt, which comes after the timeline loads, and retry once if the first load times out. Co-Authored-By: Claude Opus 5.5 --- .../ScreenshotTests.swift | 158 +++++++++++------- 1 file changed, 96 insertions(+), 62 deletions(-) diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift index 3bf1084..87d717f 100644 --- a/tests/CloudrollScreenshots/ScreenshotTests.swift +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -5,6 +5,11 @@ import XCTest /// TEST_RUNNER_ variables and builds the app with the SCREENSHOTS flag. /// Each step saves a PNG and the accessibility tree, and a missing element skips that /// shot instead of failing the run, so one run shows everything that went wrong. +/// +/// The timeline is a web view whose thumbnails aren't in the accessibility tree, so the +/// test opens the newest photo by position and then swipes through the native viewer, +/// whose controls it can read: "Play Live Photo" marks the Live Photo, and the info +/// sheet shows a map for photos with a location. final class ScreenshotTests: XCTestCase { private let app = XCUIApplication() private let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") @@ -21,96 +26,125 @@ final class ScreenshotTests: XCTestCase { } } + override func tearDownWithError() throws { + try problems.joined(separator: "\n").write(to: outputDir.appending(path: "problems.txt"), atomically: true, encoding: .utf8) + } + func testCaptureScreenshots() throws { app.launch() - allowPhotoAccessIfAsked() - - guard app.buttons["Cloudroll Settings"].waitForExistence(timeout: 180) else { + guard waitForTimeline() else { save("00-not-loaded") XCTFail("The timeline never loaded") return } - allowPhotoAccessIfAsked() - pause(10) // thumbnails + allowPhotoAccess() + pause(12) // the phone photos join the timeline, then thumbnails load save("01-timeline") - // A server photo with a location, so the info panel shows the map. - if openPhoto(named: "IMG_1006") { - pause(4) - save("02-viewer") - if tap(app.buttons["Info"], "Info") { - pause(4) - save("03-info") - app.swipeDown(velocity: .fast) - pause(1) - } - closeViewer() - } + guard openNewestPhoto() else { return } - if openPhoto(named: "IMG_2074") { - pause(5) - save("04-live-photo") - closeViewer() + // The newest photos are the phone's, which open Cloudroll's own editor. + if app.buttons["Edit"].exists { + pause(3) + save("02-phone-photo") + app.buttons["Edit"].tap() + pause(4) + save("03-editor") + let cancel = app.buttons["Cancel"] + if cancel.waitForExistence(timeout: 5) { cancel.tap() } + let discard = app.buttons["Discard Changes"] + if discard.waitForExistence(timeout: 2) { discard.tap() } + pause(2) + } else { + problems.append("The newest photo had no Edit button") } - // Phone photos open Cloudroll's own editor. - if openPhoto(named: nil) { - pause(3) - save("05-phone-photo") - if tap(app.buttons["Edit"], "Edit") { - pause(4) - save("06-editor") - let cancel = app.buttons["Cancel"] - if cancel.exists { cancel.tap() } + var gotLive = false + var gotLocation = false + for index in 0..<30 where !(gotLive && gotLocation) { + if index > 0 { + app.swipeLeft() + pause(3) + } + if !gotLive, app.buttons["Play Live Photo"].exists { pause(2) + save("04-live-photo") + gotLive = true + } + if !gotLocation, app.buttons["Info"].exists { + app.buttons["Info"].tap() + pause(4) + if app.maps.firstMatch.exists { + save("05-info") + gotLocation = true + } + dismissInfo() } - closeViewer() } + if !gotLive { problems.append("No Live Photo found in 30 photos") } + if !gotLocation { problems.append("No photo with a location found in 30 photos") } + if app.buttons["Close"].exists { app.buttons["Close"].tap() } + pause(2) if tap(app.buttons["Cloudroll Settings"], "Cloudroll Settings") { pause(3) - save("07-settings") + save("06-settings") } - - try problems.joined(separator: "\n").write(to: outputDir.appending(path: "problems.txt"), atomically: true, encoding: .utf8) } // MARK: - Steps - /// Opens a timeline photo whose web element label contains `name`, or the first one. - private func openPhoto(named name: String?) -> Bool { - let images = app.webViews.firstMatch.images - let match: XCUIElement - if let name { - match = images.matching(NSPredicate(format: "label CONTAINS[c] %@", name)).firstMatch - } else { - match = images.firstMatch - } - guard match.waitForExistence(timeout: 10), match.isHittable else { - problems.append("No hittable photo for \(name ?? "first photo")") - save("missing-\(name ?? "first")") - return false + /// Taps "Retry" once if the first load times out, as it occasionally does on CI. + private func waitForTimeline() -> Bool { + let settings = app.buttons["Cloudroll Settings"] + let deadline = Date().addingTimeInterval(240) + var retried = false + while Date() < deadline { + if settings.exists { return true } + if !retried, app.buttons["Retry"].exists { + save("00-retry") + app.buttons["Retry"].tap() + retried = true + } + allowPhotoAccess(wait: 0) + pause(2) } - match.tap() - return app.buttons["Info"].waitForExistence(timeout: 15) + return false } - private func closeViewer() { - let close = app.buttons["Close"] - if close.exists { close.tap() } - pause(2) + /// Cloudroll's own prompt comes first, then the system's, a little after the timeline loads. + private func allowPhotoAccess(wait: TimeInterval = 20) { + let deadline = Date().addingTimeInterval(wait) + repeat { + if app.buttons["Allow access"].exists { app.buttons["Allow access"].tap() } + for label in ["Allow Full Access", "Allow Access to All Photos"] where springboard.buttons[label].exists { + springboard.buttons[label].tap() + return + } + if wait > 0 { pause(1) } + } while Date() < deadline } - private func allowPhotoAccessIfAsked() { - let ownPrompt = app.buttons["Allow access"] - if ownPrompt.waitForExistence(timeout: 5) { ownPrompt.tap() } - for label in ["Allow Full Access", "Allow Access to All Photos", "Allow"] { - let button = springboard.buttons[label] - if button.waitForExistence(timeout: 3) { - button.tap() - break - } + /// The first thumbnail sits under the header and the first day's title. + private func openNewestPhoto() -> Bool { + let window = app.windows.firstMatch + for y in [0.22, 0.26, 0.30] { + window.coordinate(withNormalizedOffset: CGVector(dx: 0.12, dy: y)).tap() + if app.buttons["Info"].waitForExistence(timeout: 8) { return true } } + problems.append("Couldn't open the newest photo") + save("missing-viewer") + return false + } + + private func dismissInfo() { + let sheet = app.sheets.firstMatch + if sheet.exists { + sheet.swipeDown(velocity: .fast) + } else { + app.windows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.15)).tap() + } + pause(2) } @discardableResult From 9e9b21f54117edd6b75e3e2a061e163e6eb55caf Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:47:53 -0500 Subject: [PATCH 07/10] Screenshots: open the Live Photo and the located photo by position Also wait for the editor's preview before capturing it. Co-Authored-By: Claude Opus 5.5 --- .../ScreenshotTests.swift | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift index 87d717f..ac69c9f 100644 --- a/tests/CloudrollScreenshots/ScreenshotTests.swift +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -7,9 +7,8 @@ import XCTest /// shot instead of failing the run, so one run shows everything that went wrong. /// /// The timeline is a web view whose thumbnails aren't in the accessibility tree, so the -/// test opens the newest photo by position and then swipes through the native viewer, -/// whose controls it can read: "Play Live Photo" marks the Live Photo, and the info -/// sheet shows a map for photos with a location. +/// test opens photos by their place on screen and then checks the native viewer's +/// controls, which it can read: "Play Live Photo" for the Live Photo, a map in the info. final class ScreenshotTests: XCTestCase { private let app = XCUIApplication() private let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") @@ -41,54 +40,54 @@ final class ScreenshotTests: XCTestCase { pause(12) // the phone photos join the timeline, then thumbnails load save("01-timeline") - guard openNewestPhoto() else { return } - // The newest photos are the phone's, which open Cloudroll's own editor. - if app.buttons["Edit"].exists { + if openPhoto(at: CGVector(dx: 0.3, dy: 0.3), "newest phone photo") { pause(3) - save("02-phone-photo") - app.buttons["Edit"].tap() - pause(4) - save("03-editor") - let cancel = app.buttons["Cancel"] - if cancel.waitForExistence(timeout: 5) { cancel.tap() } - let discard = app.buttons["Discard Changes"] - if discard.waitForExistence(timeout: 2) { discard.tap() } - pause(2) - } else { - problems.append("The newest photo had no Edit button") + save("02-viewer") + if tap(app.buttons["Edit"], "Edit") { + waitForLoading() + save("03-editor") + if app.buttons["Cancel"].exists { app.buttons["Cancel"].tap() } + let discard = app.buttons["Discard Changes"] + if discard.waitForExistence(timeout: 2) { discard.tap() } + pause(2) + } + closeViewer() } - var gotLive = false - var gotLocation = false - for index in 0..<30 where !(gotLive && gotLocation) { - if index > 0 { - app.swipeLeft() - pause(3) - } - if !gotLive, app.buttons["Play Live Photo"].exists { - pause(2) + // The demo timeline is the same every run: the aquarium Live Photo is the only + // photo of Aug 1, and the San Clemente railway photo (with a location) leads Jul 4. + if openPhoto(at: CGVector(dx: 0.16, dy: 0.58), "Live Photo") { + pause(4) + if app.buttons["Play Live Photo"].exists { save("04-live-photo") - gotLive = true + } else { + problems.append("The Aug 1 photo isn't a Live Photo") + save("dbg-live") } - if !gotLocation, app.buttons["Info"].exists { - app.buttons["Info"].tap() - pause(4) + closeViewer() + } + + if openPhoto(at: CGVector(dx: 0.5, dy: 0.76), "photo with a location") { + pause(3) + if tap(app.buttons["Info"], "Info") { + pause(5) if app.maps.firstMatch.exists { save("05-info") - gotLocation = true + } else { + problems.append("The Jul 4 photo's info has no map") + save("dbg-info") } dismissInfo() } + closeViewer() } - if !gotLive { problems.append("No Live Photo found in 30 photos") } - if !gotLocation { problems.append("No photo with a location found in 30 photos") } - if app.buttons["Close"].exists { app.buttons["Close"].tap() } - pause(2) if tap(app.buttons["Cloudroll Settings"], "Cloudroll Settings") { pause(3) save("06-settings") + } else { + save("dbg-settings") } } @@ -125,18 +124,33 @@ final class ScreenshotTests: XCTestCase { } while Date() < deadline } - /// The first thumbnail sits under the header and the first day's title. - private func openNewestPhoto() -> Bool { - let window = app.windows.firstMatch - for y in [0.22, 0.26, 0.30] { - window.coordinate(withNormalizedOffset: CGVector(dx: 0.12, dy: y)).tap() - if app.buttons["Info"].waitForExistence(timeout: 8) { return true } - } - problems.append("Couldn't open the newest photo") - save("missing-viewer") + /// Taps a thumbnail by its place on screen; the web timeline's photos aren't in the + /// accessibility tree. + private func openPhoto(at point: CGVector, _ what: String) -> Bool { + app.windows.firstMatch.coordinate(withNormalizedOffset: point).tap() + if app.buttons["Info"].waitForExistence(timeout: 10) { return true } + problems.append("Couldn't open the \(what)") + save("dbg-open-\(what.replacingOccurrences(of: " ", with: "-"))") return false } + /// Waits for spinners to go, e.g. while the editor renders its first preview. + private func waitForLoading(timeout: TimeInterval = 30) { + let deadline = Date().addingTimeInterval(timeout) + pause(2) + while Date() < deadline, app.activityIndicators.firstMatch.exists { pause(1) } + pause(2) + } + + private func closeViewer() { + if app.buttons["Close"].exists { app.buttons["Close"].tap() } + if !app.buttons["Cloudroll Settings"].waitForExistence(timeout: 8) { + problems.append("The viewer didn't close") + save("dbg-close") + } + pause(2) + } + private func dismissInfo() { let sheet = app.sheets.firstMatch if sheet.exists { From 5391400d76f5189fe5bb76143e685970c3418462 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:59:58 -0500 Subject: [PATCH 08/10] Screenshots: wait for the Live Photo's motion, map tiles and the editor; close the info by its grabber Co-Authored-By: Claude Opus 5.5 --- .../ScreenshotTests.swift | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift index ac69c9f..696655e 100644 --- a/tests/CloudrollScreenshots/ScreenshotTests.swift +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -45,7 +45,7 @@ final class ScreenshotTests: XCTestCase { pause(3) save("02-viewer") if tap(app.buttons["Edit"], "Edit") { - waitForLoading() + waitForLoading(timeout: 90) save("03-editor") if app.buttons["Cancel"].exists { app.buttons["Cancel"].tap() } let discard = app.buttons["Discard Changes"] @@ -58,8 +58,9 @@ final class ScreenshotTests: XCTestCase { // The demo timeline is the same every run: the aquarium Live Photo is the only // photo of Aug 1, and the San Clemente railway photo (with a location) leads Jul 4. if openPhoto(at: CGVector(dx: 0.16, dy: 0.58), "Live Photo") { - pause(4) - if app.buttons["Play Live Photo"].exists { + // The motion part downloads after the photo; the button appears once it's ready. + if app.buttons["Play Live Photo"].waitForExistence(timeout: 45) { + pause(2) save("04-live-photo") } else { problems.append("The Aug 1 photo isn't a Live Photo") @@ -71,7 +72,7 @@ final class ScreenshotTests: XCTestCase { if openPhoto(at: CGVector(dx: 0.5, dy: 0.76), "photo with a location") { pause(3) if tap(app.buttons["Info"], "Info") { - pause(5) + pause(12) // map tiles if app.maps.firstMatch.exists { save("05-info") } else { @@ -152,13 +153,16 @@ final class ScreenshotTests: XCTestCase { } private func dismissInfo() { - let sheet = app.sheets.firstMatch - if sheet.exists { - sheet.swipeDown(velocity: .fast) - } else { - app.windows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.15)).tap() - } + // Drag the sheet down by its grabber, which sits near the middle of the screen + // at the medium detent. + let window = app.windows.firstMatch + window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.48)) + .press(forDuration: 0.1, thenDragTo: window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.99))) pause(2) + if !app.buttons["Close"].exists { + problems.append("The info sheet didn't close") + save("dbg-info-close") + } } @discardableResult From ef272bb06521aba0800faf5f260b48b65d138988 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 19:10:35 -0500 Subject: [PATCH 09/10] Screenshots: capture the icon picker instead of the editor and Settings The editor never finishes loading in the CI simulator, and Settings shows the demo server's address. The viewer also falls back to a swipe to close. Co-Authored-By: Claude Opus 5.5 --- .../ScreenshotTests.swift | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift index 696655e..93f44e4 100644 --- a/tests/CloudrollScreenshots/ScreenshotTests.swift +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -40,18 +40,11 @@ final class ScreenshotTests: XCTestCase { pause(12) // the phone photos join the timeline, then thumbnails load save("01-timeline") - // The newest photos are the phone's, which open Cloudroll's own editor. + // The newest photo is one of the phone's. (Cloudroll's editor never finishes + // loading in the CI simulator, so it isn't captured.) if openPhoto(at: CGVector(dx: 0.3, dy: 0.3), "newest phone photo") { pause(3) save("02-viewer") - if tap(app.buttons["Edit"], "Edit") { - waitForLoading(timeout: 90) - save("03-editor") - if app.buttons["Cancel"].exists { app.buttons["Cancel"].tap() } - let discard = app.buttons["Discard Changes"] - if discard.waitForExistence(timeout: 2) { discard.tap() } - pause(2) - } closeViewer() } @@ -61,7 +54,7 @@ final class ScreenshotTests: XCTestCase { // The motion part downloads after the photo; the button appears once it's ready. if app.buttons["Play Live Photo"].waitForExistence(timeout: 45) { pause(2) - save("04-live-photo") + save("03-live-photo") } else { problems.append("The Aug 1 photo isn't a Live Photo") save("dbg-live") @@ -74,7 +67,7 @@ final class ScreenshotTests: XCTestCase { if tap(app.buttons["Info"], "Info") { pause(12) // map tiles if app.maps.firstMatch.exists { - save("05-info") + save("04-info") } else { problems.append("The Jul 4 photo's info has no map") save("dbg-info") @@ -84,9 +77,13 @@ final class ScreenshotTests: XCTestCase { closeViewer() } + // Settings itself shows the demo server's address, so the shot is the icon picker. if tap(app.buttons["Cloudroll Settings"], "Cloudroll Settings") { - pause(3) - save("06-settings") + pause(2) + if tap(app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "App Icon")).firstMatch, "App Icon") { + pause(3) + save("05-app-icons") + } } else { save("dbg-settings") } @@ -145,6 +142,12 @@ final class ScreenshotTests: XCTestCase { private func closeViewer() { if app.buttons["Close"].exists { app.buttons["Close"].tap() } + if !app.buttons["Cloudroll Settings"].waitForExistence(timeout: 5) { + // The viewer also closes with a downward swipe. + let window = app.windows.firstMatch + window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.45)) + .press(forDuration: 0.05, thenDragTo: window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.9))) + } if !app.buttons["Cloudroll Settings"].waitForExistence(timeout: 8) { problems.append("The viewer didn't close") save("dbg-close") From acbc6f7d83f43246034db39e242baeb01b9fe770 Mon Sep 17 00:00:00 2001 From: "Marc @keasbeexd" <234014364+keasbeexd@users.noreply.github.com> Date: Tue, 10 Nov 2026 19:25:47 -0500 Subject: [PATCH 10/10] Screenshots: save Diagnostics when the Live Photo doesn't load Co-Authored-By: Claude Opus 5.5 --- tests/CloudrollScreenshots/ScreenshotTests.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/CloudrollScreenshots/ScreenshotTests.swift b/tests/CloudrollScreenshots/ScreenshotTests.swift index 93f44e4..635b007 100644 --- a/tests/CloudrollScreenshots/ScreenshotTests.swift +++ b/tests/CloudrollScreenshots/ScreenshotTests.swift @@ -48,6 +48,8 @@ final class ScreenshotTests: XCTestCase { closeViewer() } + var liveFailed = false + // The demo timeline is the same every run: the aquarium Live Photo is the only // photo of Aug 1, and the San Clemente railway photo (with a location) leads Jul 4. if openPhoto(at: CGVector(dx: 0.16, dy: 0.58), "Live Photo") { @@ -57,6 +59,7 @@ final class ScreenshotTests: XCTestCase { save("03-live-photo") } else { problems.append("The Aug 1 photo isn't a Live Photo") + liveFailed = true save("dbg-live") } closeViewer() @@ -84,6 +87,15 @@ final class ScreenshotTests: XCTestCase { pause(3) save("05-app-icons") } + // The viewer logs why a Live Photo's motion didn't load. + if liveFailed { + app.navigationBars.buttons.firstMatch.tap() + pause(1) + if tap(app.buttons.matching(NSPredicate(format: "label CONTAINS %@", "Diagnostics")).firstMatch, "Diagnostics") { + pause(2) + save("dbg-diagnostics") + } + } } else { save("dbg-settings") }