From 9c92f290a5ce84aa244ca86a12cbfffadf537700 Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 4 Mar 2022 01:39:34 +0800 Subject: [PATCH] chore: add domain and update guide for the snapshot UITest --- Documentation/Snapshot.md | 12 +++++++++++- MastodonUITests/MastodonUISnapshotTests.swift | 14 +++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Documentation/Snapshot.md b/Documentation/Snapshot.md index 9f20abbd3..5d794923b 100644 --- a/Documentation/Snapshot.md +++ b/Documentation/Snapshot.md @@ -39,6 +39,8 @@ TEST_RUNNER_email='' \ -scheme 'Mastodon - Snapshot' \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max' \ + -destination 'platform=iOS Simulator,name=iPhone 8 Plus' \ + -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation)' \ -testPlan 'AppStoreSnapshotTestPlan' \ -only-testing:MastodonUITests/MastodonUISnapshotTests/testSignInAccount ``` @@ -48,8 +50,14 @@ UITest may running silent. Open the Simulator.app to make the device display. #### Take and extract snapshots ```zsh +# setup magic status bar +xcrun simctl status_bar 'iPhone 13 Pro Max' override --time "9:41" --batteryState charged --batteryLevel 100 +xcrun simctl status_bar 'iPhone 8 Plus' override --time "9:41" --batteryState charged --batteryLevel 100 +xcrun simctl status_bar 'iPad Pro (12.9-inch) (5th generation)' override --time "9:41" --batteryState charged --batteryLevel 100 + # take snapshots -TEST_RUNNER_username_snapshot='Gargron' \ +TEST_RUNNER_domain='' \ + TEST_RUNNER_username_snapshot='username@domain.com' \ xcodebuild \ test \ -derivedDataPath '~/Downloads/MastodonBuild/Derived' \ @@ -57,6 +65,8 @@ TEST_RUNNER_username_snapshot='Gargron' \ -scheme 'Mastodon - Snapshot' \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max' \ + -destination 'platform=iOS Simulator,name=iPhone 8 Plus' \ + -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation)' \ -testPlan 'AppStoreSnapshotTestPlan' \ -only-testing:MastodonUITests/MastodonUISnapshotTests/testSnapshot diff --git a/MastodonUITests/MastodonUISnapshotTests.swift b/MastodonUITests/MastodonUISnapshotTests.swift index 9c237808b..cf2206b66 100644 --- a/MastodonUITests/MastodonUISnapshotTests.swift +++ b/MastodonUITests/MastodonUISnapshotTests.swift @@ -197,16 +197,24 @@ extension MastodonUISnapshotTests { // Please check the Documentation/Snapshot.md and run this test case in the command line func testSignInAccount() async throws { + guard let domain = ProcessInfo.processInfo.environment["domain"] else { + fatalError("env 'domain' missing") + } guard let email = ProcessInfo.processInfo.environment["email"] else { fatalError("env 'email' missing") } guard let password = ProcessInfo.processInfo.environment["password"] else { fatalError("env 'password' missing") } - try await signInApplication(email: email, password: password) + try await signInApplication( + domain: domain, + email: email, + password: password + ) } func signInApplication( + domain: String, email: String, password: String ) async throws { @@ -238,14 +246,14 @@ extension MastodonUISnapshotTests { domainTextField.tap() // Skip system keyboard swipe input guide skipKeyboardSwipeInputGuide(app: app) - domainTextField.typeText("mastodon.social") + domainTextField.typeText(domain) XCUIApplication().keyboards.buttons["Done"].firstMatch.tap() // wait searching try await Task.sleep(nanoseconds: .second * 3) // tap server - let cell = app.cells.containing(.staticText, identifier: "mastodon.social").firstMatch + let cell = app.cells.containing(.staticText, identifier: domain).firstMatch XCTAssert(cell.waitForExistence(timeout: 5)) cell.tap()