chore: add domain and update guide for the snapshot UITest

This commit is contained in:
CMK 2022-03-04 01:39:34 +08:00
parent 633d1ae62a
commit 9c92f290a5
2 changed files with 22 additions and 4 deletions

View File

@ -39,6 +39,8 @@ TEST_RUNNER_email='<Email>' \
-scheme 'Mastodon - Snapshot' \ -scheme 'Mastodon - Snapshot' \
-sdk iphonesimulator \ -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max' \ -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' \ -testPlan 'AppStoreSnapshotTestPlan' \
-only-testing:MastodonUITests/MastodonUISnapshotTests/testSignInAccount -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 #### Take and extract snapshots
```zsh ```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 # take snapshots
TEST_RUNNER_username_snapshot='Gargron' \ TEST_RUNNER_domain='<domain.com>' \
TEST_RUNNER_username_snapshot='username@domain.com' \
xcodebuild \ xcodebuild \
test \ test \
-derivedDataPath '~/Downloads/MastodonBuild/Derived' \ -derivedDataPath '~/Downloads/MastodonBuild/Derived' \
@ -57,6 +65,8 @@ TEST_RUNNER_username_snapshot='Gargron' \
-scheme 'Mastodon - Snapshot' \ -scheme 'Mastodon - Snapshot' \
-sdk iphonesimulator \ -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max' \ -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' \ -testPlan 'AppStoreSnapshotTestPlan' \
-only-testing:MastodonUITests/MastodonUISnapshotTests/testSnapshot -only-testing:MastodonUITests/MastodonUISnapshotTests/testSnapshot

View File

@ -197,16 +197,24 @@ extension MastodonUISnapshotTests {
// Please check the Documentation/Snapshot.md and run this test case in the command line // Please check the Documentation/Snapshot.md and run this test case in the command line
func testSignInAccount() async throws { func testSignInAccount() async throws {
guard let domain = ProcessInfo.processInfo.environment["domain"] else {
fatalError("env 'domain' missing")
}
guard let email = ProcessInfo.processInfo.environment["email"] else { guard let email = ProcessInfo.processInfo.environment["email"] else {
fatalError("env 'email' missing") fatalError("env 'email' missing")
} }
guard let password = ProcessInfo.processInfo.environment["password"] else { guard let password = ProcessInfo.processInfo.environment["password"] else {
fatalError("env 'password' missing") fatalError("env 'password' missing")
} }
try await signInApplication(email: email, password: password) try await signInApplication(
domain: domain,
email: email,
password: password
)
} }
func signInApplication( func signInApplication(
domain: String,
email: String, email: String,
password: String password: String
) async throws { ) async throws {
@ -238,14 +246,14 @@ extension MastodonUISnapshotTests {
domainTextField.tap() domainTextField.tap()
// Skip system keyboard swipe input guide // Skip system keyboard swipe input guide
skipKeyboardSwipeInputGuide(app: app) skipKeyboardSwipeInputGuide(app: app)
domainTextField.typeText("mastodon.social") domainTextField.typeText(domain)
XCUIApplication().keyboards.buttons["Done"].firstMatch.tap() XCUIApplication().keyboards.buttons["Done"].firstMatch.tap()
// wait searching // wait searching
try await Task.sleep(nanoseconds: .second * 3) try await Task.sleep(nanoseconds: .second * 3)
// tap server // 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)) XCTAssert(cell.waitForExistence(timeout: 5))
cell.tap() cell.tap()