Add ui tests

This commit is contained in:
Alfonso Grillo
2023-01-25 19:58:02 +01:00
parent 544c505197
commit 838bdc0629
3 changed files with 54 additions and 17 deletions
@@ -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)
}
}