mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Add ui tests
This commit is contained in:
@@ -25,8 +25,8 @@ enum MockPollHistoryScreenState: MockScreenState, CaseIterable {
|
||||
// with specific, minimal associated data that will allow you
|
||||
// mock that screen.
|
||||
case active
|
||||
case activeNoMoreContent
|
||||
case past
|
||||
case activeNoMoreContent
|
||||
case contentLoading
|
||||
case empty
|
||||
case emptyLoading
|
||||
|
||||
@@ -24,6 +24,7 @@ final class PollHistoryUITests: MockScreenTestCase {
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let selectedSegment = app.buttons[VectorL10n.pollHistoryActiveSegmentTitle]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
let winningOption = app.staticTexts["PollListData.winningOption"]
|
||||
|
||||
XCTAssertEqual(title, VectorL10n.pollHistoryTitle)
|
||||
@@ -31,6 +32,7 @@ final class PollHistoryUITests: MockScreenTestCase {
|
||||
XCTAssertFalse(emptyText.exists)
|
||||
XCTAssertTrue(selectedSegment.exists)
|
||||
XCTAssertEqual(selectedSegment.value as? String, VectorL10n.accessibilitySelected)
|
||||
XCTAssertTrue(loadMoreButton.exists)
|
||||
XCTAssertFalse(winningOption.exists)
|
||||
}
|
||||
|
||||
@@ -40,6 +42,7 @@ final class PollHistoryUITests: MockScreenTestCase {
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let selectedSegment = app.buttons[VectorL10n.pollHistoryPastSegmentTitle]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
let winningOption = app.buttons["PollAnswerOption0"]
|
||||
|
||||
XCTAssertEqual(title, VectorL10n.pollHistoryTitle)
|
||||
@@ -47,33 +50,66 @@ final class PollHistoryUITests: MockScreenTestCase {
|
||||
XCTAssertFalse(emptyText.exists)
|
||||
XCTAssertTrue(selectedSegment.exists)
|
||||
XCTAssertEqual(selectedSegment.value as? String, VectorL10n.accessibilitySelected)
|
||||
XCTAssertTrue(loadMoreButton.exists)
|
||||
XCTAssertTrue(winningOption.exists)
|
||||
}
|
||||
|
||||
func testPastPollHistoryIsEmpty() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.pastEmpty.title)
|
||||
func testActivePollHistoryHasContentAndCantLoadMore() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.activeNoMoreContent.title)
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
|
||||
XCTAssertTrue(items.exists)
|
||||
XCTAssertFalse(emptyText.exists)
|
||||
XCTAssertFalse(loadMoreButton.exists)
|
||||
}
|
||||
|
||||
func testActivePollHistoryHasContentAndCanLoadMore() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.contentLoading.title)
|
||||
let title = app.navigationBars.firstMatch.identifier
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let selectedSegment = app.buttons[VectorL10n.pollHistoryPastSegmentTitle]
|
||||
let winningOption = app.staticTexts["PollListData.winningOption"]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
|
||||
XCTAssertEqual(title, VectorL10n.pollHistoryTitle)
|
||||
XCTAssertFalse(items.exists)
|
||||
XCTAssertTrue(emptyText.exists)
|
||||
XCTAssertTrue(selectedSegment.exists)
|
||||
XCTAssertEqual(selectedSegment.value as? String, VectorL10n.accessibilitySelected)
|
||||
XCTAssertFalse(winningOption.exists)
|
||||
XCTAssertTrue(items.exists)
|
||||
XCTAssertFalse(emptyText.exists)
|
||||
XCTAssertTrue(loadMoreButton.exists)
|
||||
XCTAssertFalse(loadMoreButton.isEnabled)
|
||||
}
|
||||
|
||||
func testLoaderIsShowing() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.loading.title)
|
||||
let title = app.navigationBars.firstMatch.identifier
|
||||
let loadingText = app.staticTexts["PollHistory.loadingText"]
|
||||
func testActivePollHistoryEmptyAndCanLoadMore() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.empty.title)
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
|
||||
XCTAssertEqual(title, VectorL10n.pollHistoryTitle)
|
||||
XCTAssertFalse(items.exists)
|
||||
XCTAssertTrue(loadingText.exists)
|
||||
XCTAssertTrue(emptyText.exists)
|
||||
XCTAssertTrue(loadMoreButton.exists)
|
||||
XCTAssertTrue(loadMoreButton.isEnabled)
|
||||
}
|
||||
|
||||
func testActivePollHistoryEmptyAndLoading() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.emptyLoading.title)
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
|
||||
XCTAssertFalse(items.exists)
|
||||
XCTAssertTrue(emptyText.exists)
|
||||
XCTAssertTrue(loadMoreButton.exists)
|
||||
XCTAssertFalse(loadMoreButton.isEnabled)
|
||||
}
|
||||
|
||||
func testActivePollHistoryEmptyAndCantLoadMore() {
|
||||
app.goToScreenWithIdentifier(MockPollHistoryScreenState.emptyNoMoreContent.title)
|
||||
let emptyText = app.staticTexts["PollHistory.emptyText"]
|
||||
let items = app.staticTexts["PollListItem.title"]
|
||||
let loadMoreButton = app.buttons["PollHistory.loadMore"]
|
||||
|
||||
XCTAssertFalse(items.exists)
|
||||
XCTAssertTrue(emptyText.exists)
|
||||
XCTAssertFalse(loadMoreButton.exists)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ struct PollHistory: View {
|
||||
Text(VectorL10n.pollHistoryLoadMore)
|
||||
.font(theme.fonts.body)
|
||||
}
|
||||
.accessibilityIdentifier("PollHistory.loadMore")
|
||||
.disabled(viewModel.viewState.isLoading)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user