mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Add utility to run UI tests for Screen states, add screen states for template and finish unit test.
This commit is contained in:
+24
-22
@@ -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 it’s 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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,12 +38,12 @@ class TemplateUserProfileViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(viewModel.viewState.presence, Constants.presenceInitialValue)
|
||||
}
|
||||
|
||||
func testFirstPresenceRecieved() throws {
|
||||
func testFirstPresenceReceived() throws {
|
||||
let presencePublisher = viewModel.$viewState.map(\.presence).removeDuplicates().collect(1).first()
|
||||
XCTAssertEqual(try xcAwait(presencePublisher), [Constants.presenceInitialValue])
|
||||
}
|
||||
|
||||
func testPresenceUpdatesRecieved() throws {
|
||||
func testPresenceUpdatesReceived() throws {
|
||||
let presencePublisher = viewModel.$viewState.map(\.presence).removeDuplicates().collect(3).first()
|
||||
let newPresenceValue1: TemplateUserProfilePresence = .online
|
||||
let newPresenceValue2: TemplateUserProfilePresence = .idle
|
||||
|
||||
Reference in New Issue
Block a user