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' \
-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='<domain.com>' \
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

View File

@ -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()