Add utility to run UI tests for Screen states, add screen states for template and finish unit test.

This commit is contained in:
David Langley
2021-09-10 16:43:31 +01:00
parent 59a54654b1
commit 4fb59260d4
15 changed files with 332 additions and 148 deletions
@@ -15,33 +15,35 @@
//
import XCTest
@testable import RiotSwiftUI
import RiotSwiftUI
@available(iOS 14.0, *)
class TestUserProfileUITests: XCTestCase {
let app = XCUIApplication()
class TestUserProfileUITests: MockScreenTest {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
app.launch()
// In UI tests its important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
override class var screenType: MockScreenState.Type {
return MockTemplateProfileUserScreenState.self
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
func testTemplateUserProfileScreen() throws {
guard let screenState = screenState as? MockTemplateProfileUserScreenState else { fatalError("no screen") }
switch screenState {
case .presence(let presence):
testTemplateUserProfilePresence(presence: presence)
case .longDisplayName(let name):
testTemplateUserProfileLongName(name: name)
}
}
func testUserContentTextDisplayed() throws {
let userContentText = app.staticTexts["More great user content!"]
XCTAssert(userContentText.exists)
func testTemplateUserProfilePresence(presence: TemplateUserProfilePresence) {
let presenceText = app.staticTexts["presenceText"]
XCTAssert(presenceText.exists)
XCTAssert(presenceText.label == presence.title)
}
func testTemplateUserProfileLongName(name: String) {
let displayNameText = app.staticTexts["displayNameText"]
XCTAssert(displayNameText.exists)
XCTAssert(displayNameText.label == name)
}
}