2021-11-19 15:40:52 +00:00
|
|
|
//
|
|
|
|
// Copyright 2021 New Vector Ltd
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
import RiotSwiftUI
|
2022-09-27 07:17:22 +00:00
|
|
|
import XCTest
|
2021-11-19 15:40:52 +00:00
|
|
|
|
2022-07-14 16:49:49 +00:00
|
|
|
class TimelinePollUITests: MockScreenTestCase {
|
2022-01-13 13:57:26 +00:00
|
|
|
func testOpenDisclosedPoll() {
|
2022-01-13 15:25:14 +00:00
|
|
|
app.goToScreenWithIdentifier(MockTimelinePollScreenState.openDisclosed.title)
|
2021-11-19 15:40:52 +00:00
|
|
|
|
|
|
|
XCTAssert(app.staticTexts["Question"].exists)
|
|
|
|
XCTAssert(app.staticTexts["20 votes cast"].exists)
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First, 10 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["First, 10 votes"].value as! String, "50%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Second, 5 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Second, 5 votes"].value as! String, "25%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Third, 15 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Third, 15 votes"].value as! String, "75%")
|
|
|
|
|
|
|
|
app.buttons["First, 10 votes"].tap()
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First, 11 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["First, 11 votes"].value as! String, "55%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Second, 4 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Second, 4 votes"].value as! String, "20%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Third, 15 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Third, 15 votes"].value as! String, "75%")
|
|
|
|
|
|
|
|
app.buttons["Third, 15 votes"].tap()
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First, 10 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["First, 10 votes"].value as! String, "50%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Second, 4 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Second, 4 votes"].value as! String, "20%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Third, 16 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Third, 16 votes"].value as! String, "80%")
|
|
|
|
}
|
|
|
|
|
2022-01-13 13:57:26 +00:00
|
|
|
func testOpenUndisclosedPoll() {
|
2022-01-13 15:25:14 +00:00
|
|
|
app.goToScreenWithIdentifier(MockTimelinePollScreenState.openUndisclosed.title)
|
2021-11-19 15:40:52 +00:00
|
|
|
|
|
|
|
XCTAssert(app.staticTexts["Question"].exists)
|
2022-01-13 13:57:26 +00:00
|
|
|
XCTAssert(app.staticTexts["20 votes cast"].exists)
|
|
|
|
|
|
|
|
XCTAssert(!app.buttons["First, 10 votes"].exists)
|
|
|
|
XCTAssert(app.buttons["First"].exists)
|
|
|
|
XCTAssertTrue((app.buttons["First"].value as! String).isEmpty)
|
|
|
|
|
|
|
|
XCTAssert(!app.buttons["Second, 5 votes"].exists)
|
|
|
|
XCTAssert(app.buttons["Second"].exists)
|
|
|
|
XCTAssertTrue((app.buttons["Second"].value as! String).isEmpty)
|
|
|
|
|
|
|
|
XCTAssert(!app.buttons["Third, 15 votes"].exists)
|
|
|
|
XCTAssert(app.buttons["Third"].exists)
|
|
|
|
XCTAssertTrue((app.buttons["Third"].value as! String).isEmpty)
|
|
|
|
|
|
|
|
app.buttons["First"].tap()
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First"].exists)
|
|
|
|
XCTAssert(app.buttons["Second"].exists)
|
|
|
|
XCTAssert(app.buttons["Third"].exists)
|
|
|
|
|
|
|
|
app.buttons["Third"].tap()
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First"].exists)
|
|
|
|
XCTAssert(app.buttons["Second"].exists)
|
|
|
|
XCTAssert(app.buttons["Third"].exists)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testClosedDisclosedPoll() {
|
2022-01-13 15:25:14 +00:00
|
|
|
app.goToScreenWithIdentifier(MockTimelinePollScreenState.closedDisclosed.title)
|
2022-01-13 13:57:26 +00:00
|
|
|
checkClosedPoll()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testClosedUndisclosedPoll() {
|
2022-01-13 15:25:14 +00:00
|
|
|
app.goToScreenWithIdentifier(MockTimelinePollScreenState.closedUndisclosed.title)
|
2022-01-13 13:57:26 +00:00
|
|
|
checkClosedPoll()
|
|
|
|
}
|
|
|
|
|
|
|
|
private func checkClosedPoll() {
|
|
|
|
XCTAssert(app.staticTexts["Question"].exists)
|
2021-11-19 15:40:52 +00:00
|
|
|
XCTAssert(app.staticTexts["Final results based on 20 votes"].exists)
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First, 10 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["First, 10 votes"].value as! String, "50%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Second, 5 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Second, 5 votes"].value as! String, "25%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Third, 15 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Third, 15 votes"].value as! String, "75%")
|
|
|
|
|
|
|
|
app.buttons["First, 10 votes"].tap()
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["First, 10 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["First, 10 votes"].value as! String, "50%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Second, 5 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Second, 5 votes"].value as! String, "25%")
|
|
|
|
|
|
|
|
XCTAssert(app.buttons["Third, 15 votes"].exists)
|
|
|
|
XCTAssertEqual(app.buttons["Third, 15 votes"].value as! String, "75%")
|
|
|
|
}
|
|
|
|
}
|