mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 20:39:24 +00:00
Start fixing flakey tests ❄️ (#3329)
* Wait longer on authentication flow tests. * Move default perceptualPrecision value into the snapshot preferences. * Delay snapshots *before* setting up the test. * Reset the simulators on GitHub before running? * Remove a test that is now handled by Rust. * Fix a test that was yielding.
This commit is contained in:
@@ -113,11 +113,11 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(viewModel.state.suggestions, suggestions)
|
||||
}
|
||||
|
||||
func testSuggestionTrigger() async {
|
||||
func testSuggestionTrigger() async throws {
|
||||
let deferred = deferFulfillment(wysiwygViewModel.$attributedContent) { $0.plainText == "#not_implemented_yay" }
|
||||
wysiwygViewModel.setMarkdownContent("@test")
|
||||
wysiwygViewModel.setMarkdownContent("#not_implemented_yay")
|
||||
|
||||
await Task.yield()
|
||||
try await deferred.fulfill()
|
||||
|
||||
// The first one is nil because when initialised the view model is empty
|
||||
XCTAssertEqual(completionSuggestionServiceMock.setSuggestionTriggerReceivedInvocations, [nil, .init(type: .user, text: "test", range: .init(location: 0, length: 5)), nil])
|
||||
|
||||
@@ -256,39 +256,6 @@ class TimelineViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(arguments?.type, .read)
|
||||
}
|
||||
|
||||
func testSendMoreReadReceipts() async throws {
|
||||
// Given a room with only text items in the timeline that are all read.
|
||||
let items = [TextRoomTimelineItem(eventID: "t1"),
|
||||
TextRoomTimelineItem(eventID: "t2"),
|
||||
TextRoomTimelineItem(eventID: "t3")]
|
||||
let (viewModel, _, timelineProxy, timelineController) = readReceiptsConfiguration(with: items)
|
||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id))
|
||||
try await Task.sleep(for: .milliseconds(100))
|
||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 1)
|
||||
var arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
||||
XCTAssertEqual(arguments?.eventID, "t3")
|
||||
XCTAssertEqual(arguments?.type, .read)
|
||||
|
||||
// When sending a receipt for the first item in the timeline.
|
||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.first!.id))
|
||||
try await Task.sleep(for: .milliseconds(100))
|
||||
|
||||
// When a new message is received and marked as read.
|
||||
let newMessage = TextRoomTimelineItem(eventID: "t4")
|
||||
timelineController.timelineItems.append(newMessage)
|
||||
timelineController.callbacks.send(.updatedTimelineItems(timelineItems: timelineController.timelineItems, isSwitchingTimelines: false))
|
||||
try await Task.sleep(for: .milliseconds(100))
|
||||
|
||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(newMessage.id))
|
||||
try await Task.sleep(for: .milliseconds(100))
|
||||
|
||||
// Then the request should be made.
|
||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 3)
|
||||
arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
||||
XCTAssertEqual(arguments?.eventID, "t4")
|
||||
XCTAssertEqual(arguments?.type, .read)
|
||||
}
|
||||
|
||||
func testSendReadReceiptWithoutEvents() async throws {
|
||||
// Given a room with only virtual items.
|
||||
let items = [SeparatorRoomTimelineItem(timelineID: "v1"),
|
||||
|
||||
@@ -246,7 +246,7 @@ class UserSessionFlowCoordinatorTests: XCTestCase {
|
||||
|
||||
private func process(route: AppRoute, expectedState: UserSessionFlowCoordinatorStateMachine.State) async throws {
|
||||
// Sometimes the state machine's state changes before the coordinators have updated the stack.
|
||||
let delayedPublisher = userSessionFlowCoordinator.statePublisher.delay(for: .milliseconds(10), scheduler: DispatchQueue.main)
|
||||
let delayedPublisher = userSessionFlowCoordinator.statePublisher.delay(for: .milliseconds(100), scheduler: DispatchQueue.main)
|
||||
|
||||
let deferred = deferFulfillment(delayedPublisher) { $0 == expectedState }
|
||||
userSessionFlowCoordinator.handleAppRoute(route, animated: true)
|
||||
|
||||
Reference in New Issue
Block a user