Skip to content

Commit

Permalink
#101 Add some localization checks to UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailgulek committed Jun 29, 2022
1 parent 4422e26 commit e3b3839
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct SplashScreen: View {
Text(ElementL10n.loginSplashSubmit)
}
.buttonStyle(.elementAction(.xLarge))
.accessibilityIdentifier("getStartedButton")
}
.padding(.horizontal, 16)
.readableFrame()
Expand Down
42 changes: 22 additions & 20 deletions UITests/Sources/BugReportUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,8 @@ class BugReportUITests: XCTestCase {
let app = Application.launch()
app.goToScreenWithIdentifier(.bugReport)

XCTAssert(app.navigationBars["Bug report"].exists)
XCTAssert(app.staticTexts["reportBugDescription"].exists)
XCTAssert(app.staticTexts["sendLogsDescription"].exists)
XCTAssert(app.textViews["reportTextView"].exists)
let sendingLogsToggle = app.switches["sendLogsToggle"]
XCTAssert(sendingLogsToggle.exists)
XCTAssert(sendingLogsToggle.isOn)
XCTAssert(app.staticTexts["sendLogsText"].exists)
let sendButton = app.buttons["sendButton"]
XCTAssert(sendButton.exists)
XCTAssertFalse(sendButton.isEnabled)
verifyInitialStateComponents(in: app)

XCTAssertFalse(app.images["screenshotImage"].exists)
XCTAssertFalse(app.buttons["removeScreenshotButton"].exists)
}
Expand Down Expand Up @@ -68,20 +59,31 @@ class BugReportUITests: XCTestCase {
let app = Application.launch()
app.goToScreenWithIdentifier(.bugReportWithScreenshot)

XCTAssert(app.navigationBars["Bug report"].exists)
XCTAssert(app.staticTexts["reportBugDescription"].exists)
XCTAssert(app.staticTexts["sendLogsDescription"].exists)
verifyInitialStateComponents(in: app)

XCTAssert(app.images["screenshotImage"].exists)
XCTAssert(app.buttons["removeScreenshotButton"].exists)
}

func verifyInitialStateComponents(in app: XCUIApplication) {
XCTAssert(app.navigationBars[ElementL10n.titleActivityBugReport].exists)
let descLabel = app.staticTexts["reportBugDescription"]
XCTAssert(descLabel.exists)
XCTAssertEqual(descLabel.label, ElementL10n.sendBugReportDescription)
let sendLogsDescLabel = app.staticTexts["sendLogsDescription"]
XCTAssert(sendLogsDescLabel.exists)
XCTAssertEqual(sendLogsDescLabel.label, ElementL10n.sendBugReportLogsDescription)
XCTAssert(app.textViews["reportTextView"].exists)
let sendingLogsToggle = app.switches["sendLogsToggle"]
XCTAssert(sendingLogsToggle.exists)
XCTAssert(sendingLogsToggle.isOn)
XCTAssert(app.staticTexts["sendLogsText"].exists)
let sendLogsToggle = app.switches["sendLogsToggle"]
XCTAssert(sendLogsToggle.exists)
XCTAssert(sendLogsToggle.isOn)
let sendLogsLabel = app.staticTexts["sendLogsText"]
XCTAssert(sendLogsLabel.exists)
XCTAssertEqual(sendLogsLabel.label, ElementL10n.sendBugReportIncludeLogs)
let sendButton = app.buttons["sendButton"]
XCTAssert(sendButton.exists)
XCTAssertEqual(sendButton.label, ElementL10n.actionSend)
XCTAssertFalse(sendButton.isEnabled)
XCTAssert(app.images["screenshotImage"].exists)
XCTAssert(app.buttons["removeScreenshotButton"].exists)
}

}
Expand Down
6 changes: 6 additions & 0 deletions UITests/Sources/LoginScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class LoginScreenUITests: XCTestCase {
func validateServerDescriptionIsVisible(for state: String) {
let descriptionLabel = app.staticTexts["serverDescriptionText"]
XCTAssertTrue(descriptionLabel.exists, "The server description should be shown for \(state).")
XCTAssertEqual(descriptionLabel.label, ElementL10n.authenticationServerInfoMatrixDescription)
}

/// Checks that the server description label is hidden.
Expand All @@ -89,6 +90,7 @@ class LoginScreenUITests: XCTestCase {
XCTAssertTrue(usernameTextField.exists, "Username input should be shown for \(state).")
XCTAssertTrue(passwordTextField.exists, "Password input should be shown for \(state).")
XCTAssertTrue(nextButton.exists, "The next button should be shown for \(state).")
XCTAssertEqual(nextButton.label, ElementL10n.loginSignupSubmit)
}

/// Checks that the username and password text fields are hidden along with the next button.
Expand All @@ -107,19 +109,22 @@ class LoginScreenUITests: XCTestCase {
let nextButton = app.buttons["nextButton"]
XCTAssertTrue(nextButton.exists, "The next button should be shown.")
XCTAssertFalse(nextButton.isEnabled, "The next button should be disabled for \(state).")
XCTAssertEqual(nextButton.label, ElementL10n.loginSignupSubmit)
}

/// Checks that the next button is shown and is enabled.
func validateNextButtonIsEnabled(for state: String) {
let nextButton = app.buttons["nextButton"]
XCTAssertTrue(nextButton.exists, "The next button should be shown.")
XCTAssertTrue(nextButton.isEnabled, "The next button should be enabled for \(state).")
XCTAssertEqual(nextButton.label, ElementL10n.loginSignupSubmit)
}

/// Checks that the OIDC button is shown on the screen.
func validateOIDCButtonIsShown(for state: String) {
let oidcButton = app.buttons["oidcButton"]
XCTAssertTrue(oidcButton.exists, "The OIDC button should be shown for \(state).")
XCTAssertEqual(oidcButton.label, ElementL10n.loginContinue)
}

/// Checks that the OIDC button is not shown on the screen.
Expand All @@ -132,6 +137,7 @@ class LoginScreenUITests: XCTestCase {
func validateUnsupportedServerTextIsShown(for state: String) {
let unsupportedText = app.staticTexts["unsupportedServerText"]
XCTAssertTrue(unsupportedText.exists, "The unsupported homeserver text should be shown for \(state).")
XCTAssertEqual(unsupportedText.label, ElementL10n.autodiscoverWellKnownError)
}

/// Checks that the unsupported homeserver text is not shown on the screen.
Expand Down
16 changes: 12 additions & 4 deletions UITests/Sources/SettingsUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ class SettingsUITests: XCTestCase {
let app = Application.launch()
app.goToScreenWithIdentifier(.settings)

XCTAssert(app.navigationBars["Settings"].exists)
XCTAssert(app.buttons["reportBugButton"].exists)
XCTAssert(app.navigationBars[ElementL10n.settings].exists)
let reportBugButton = app.buttons["reportBugButton"]
XCTAssert(reportBugButton.exists)
XCTAssertEqual(reportBugButton.label, ElementL10n.sendBugReport)
XCTAssertEqual(app.buttons["crashButton"].exists, BuildSettings.settingsCrashButtonVisible)
XCTAssertEqual(app.buttons["timelineStylePicker"].exists, BuildSettings.settingsShowTimelineStyle)
XCTAssert(app.buttons["logoutButton"].exists)
let timelineStylePicker = app.buttons["timelineStylePicker"]
XCTAssertEqual(timelineStylePicker.exists, BuildSettings.settingsShowTimelineStyle)
if BuildSettings.settingsShowTimelineStyle {
XCTAssertEqual(timelineStylePicker.staticTexts.firstMatch.label, ElementL10n.settingsTimelineStyle)
}
let logoutButton = app.buttons["logoutButton"]
XCTAssert(logoutButton.exists)
XCTAssertEqual(logoutButton.label, ElementL10n.logout)
}

}
3 changes: 2 additions & 1 deletion UITests/Sources/SplashScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class SplashScreenUITests: XCTestCase {
let app = Application.launch()
app.goToScreenWithIdentifier(.splash)

let getStartedButton = app.buttons["Get started"]
let getStartedButton = app.buttons["getStartedButton"]
XCTAssertTrue(getStartedButton.exists, "The primary action button should be shown.")
XCTAssertEqual(getStartedButton.label, ElementL10n.loginSplashSubmit)
}

func testSwipingBetweenPages() async throws {
Expand Down

0 comments on commit e3b3839

Please sign in to comment.