mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Fix flakey user indicator controller tests; switch them over to the deferred fulfillment.
This commit is contained in:
parent
2e57348bdd
commit
df997ad251
@ -42,7 +42,7 @@ class UserIndicatorControllerTests: XCTestCase {
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 0)
|
||||
}
|
||||
|
||||
func testChainedPresentation() {
|
||||
func testChainedPresentation() async throws {
|
||||
indicatorController.minimumDisplayDuration = 0.25
|
||||
indicatorController.nonPersistentDisplayDuration = 2.5
|
||||
|
||||
@ -52,18 +52,17 @@ class UserIndicatorControllerTests: XCTestCase {
|
||||
|
||||
XCTAssertEqual(indicatorController.activeIndicator?.id, "Third")
|
||||
|
||||
let expectation = expectation(description: "Waiting for last indicator to be dismissed")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + indicatorController.nonPersistentDisplayDuration) {
|
||||
expectation.fulfill()
|
||||
let fulfillment = deferFulfillment(indicatorController.$activeIndicator, message: "Waiting for last indicator to be dismissed") { indicator in
|
||||
indicator?.id == "Second"
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
try await fulfillment.fulfill()
|
||||
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 2)
|
||||
XCTAssertEqual(indicatorController.activeIndicator?.id, "Second")
|
||||
}
|
||||
|
||||
func testMinimumDisplayDuration() {
|
||||
func testMinimumDisplayDuration() async throws {
|
||||
indicatorController.minimumDisplayDuration = 0.25
|
||||
indicatorController.nonPersistentDisplayDuration = 2.5
|
||||
|
||||
@ -71,28 +70,26 @@ class UserIndicatorControllerTests: XCTestCase {
|
||||
indicatorController.submitIndicator(.init(id: "Second", title: ""))
|
||||
indicatorController.submitIndicator(.init(id: "Third", title: ""))
|
||||
|
||||
indicatorController.retractIndicatorWithId("Second")
|
||||
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 3)
|
||||
|
||||
let dismissalExpectation = expectation(description: "Waiting for minimum display duration to pass")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + indicatorController.minimumDisplayDuration) {
|
||||
dismissalExpectation.fulfill()
|
||||
var fulfillment = deferFulfillment(indicatorController.$activeIndicator, message: "Waiting for minimum display duration to pass") { indicator in
|
||||
indicator?.id == "First"
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
indicatorController.retractIndicatorWithId("Second")
|
||||
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 2)
|
||||
XCTAssertEqual(indicatorController.activeIndicator?.id, "Third")
|
||||
|
||||
let dismissalExpectation2 = expectation(description: "Waiting for last indicator to be dismissed")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + indicatorController.nonPersistentDisplayDuration) {
|
||||
dismissalExpectation2.fulfill()
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
try await fulfillment.fulfill()
|
||||
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 1)
|
||||
XCTAssertEqual(indicatorController.activeIndicator?.id, "First")
|
||||
|
||||
fulfillment = deferFulfillment(indicatorController.$activeIndicator, message: "Waiting for last indicator to be dismissed") { indicator in
|
||||
indicator == nil
|
||||
}
|
||||
|
||||
try await fulfillment.fulfill()
|
||||
|
||||
XCTAssertEqual(indicatorController.indicatorQueue.count, 0)
|
||||
XCTAssertNil(indicatorController.activeIndicator)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user