Skip to content

Commit 703d656

Browse files
committed
Fix broken e2e tests
1 parent 190fb1d commit 703d656

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

StreamChatSwiftUI.xcodeproj/xcshareddata/xcschemes/StreamChatSwiftUITestsApp.xcscheme

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</BuildAction>
2525
<TestAction
2626
buildConfiguration = "Debug"
27-
selectedDebuggerIdentifier = ""
28-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<TestPlans>
3131
<TestPlanReference
@@ -48,8 +48,8 @@
4848
</TestAction>
4949
<LaunchAction
5050
buildConfiguration = "Debug"
51-
selectedDebuggerIdentifier = ""
52-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
51+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
52+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
5353
launchStyle = "0"
5454
useCustomWorkingDirectory = "NO"
5555
ignoresPersistentStateOnLaunch = "NO"

StreamChatSwiftUITestsAppTests/Pages/MessageListPage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class MessageListPage {
133133
}
134134

135135
static func text(in messageCell: XCUIElement) -> XCUIElement {
136-
messageCell.otherElements["MessageView"].staticTexts["MessageTextView"]
136+
messageCell.staticTexts["MessageTextView"]
137137
}
138138

139139
static func systemMessage(in messageCell: XCUIElement) -> XCUIElement {

StreamChatSwiftUITestsAppTests/Robots/UserRobot+Asserts.swift

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,30 @@ extension UserRobot {
547547
MessageListPage.list.swipeDown()
548548
}
549549

550-
let paginationLimit = 20
551-
let penultimateMessageСellIndex = MessageListPage.cells.count - 2
552-
let penultimateMessageСell = MessageListPage.cells.element(boundBy: penultimateMessageСellIndex)
553-
let lastLoadedMessage = Int(MessageListPage.Attributes.text(in: penultimateMessageСell).text) ?? paginationLimit
550+
let oldestMessage = MessageListPage.cells.lastMatch!
551+
XCTAssertEqual(attributes.text(in: oldestMessage).text, "1", file: file, line: line)
552+
return self
553+
}
554+
555+
@discardableResult
556+
func assertThreadListPagination(
557+
messagesCount expectedCount: Int,
558+
file: StaticString = #filePath,
559+
line: UInt = #line
560+
) -> Self {
561+
let endTime = Date().timeIntervalSince1970 * 1000 + XCUIElement.waitTimeout * 2000
562+
let actualCount = ThreadPage.cells.count
563+
XCTAssertNotEqual(expectedCount, actualCount, file: file, line: line)
554564

555-
XCTAssertLessThan(lastLoadedMessage, paginationLimit, file: file, line: line)
565+
while endTime > Date().timeIntervalSince1970 * 1000 {
566+
ThreadPage.list.swipeDown()
567+
}
568+
569+
let parentMessage = MessageListPage.cells.lastMatch! // parent message
570+
XCTAssertEqual(attributes.text(in: parentMessage).text, "1", file: file, line: line)
571+
572+
let firstThreadReply = MessageListPage.cells.allElementsBoundByIndex[MessageListPage.cells.count - 2]
573+
XCTAssertEqual(attributes.text(in: firstThreadReply).text, "1", file: file, line: line)
556574
return self
557575
}
558576

StreamChatSwiftUITestsAppTests/Tests/MessageList_Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ extension MessageList_Tests {
516516
userRobot.openThread()
517517
}
518518
THEN("user makes sure that thread history is loaded") {
519-
userRobot.assertMessageListPagination(messagesCount: replyCount + 1)
519+
userRobot.assertThreadListPagination(messagesCount: replyCount + 1)
520520
}
521521
}
522522
}

0 commit comments

Comments
 (0)