Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions StreamChatUITestsAppUITests/Robots/UserRobot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ final class UserRobot: Robot {
let composer = MessageListPage.Composer.self
let contextMenu = MessageListPage.ContextMenu.self
let debugAlert = MessageListPage.Alert.Debug.self
private var server: StreamMockServer

init(_ server: StreamMockServer) {
self.server = server
}

@discardableResult
func login() -> Self {
Expand Down Expand Up @@ -56,13 +51,6 @@ final class UserRobot: Robot {
ChannelListPage.cells.allElementsBoundByIndex[channelCellIndex].waitForHitPoint().safeTap()
return self
}

@discardableResult
public func waitForJwtToExpire() -> Self {
let sleepTime = UInt32((StreamMockServer.jwtTimeout + 2) * 1_000_000)
usleep(sleepTime)
return self
}

@discardableResult
public func sleep(_ seconds: Double) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ final class Authentication_Tests: StreamTestCase {
.assertConnectionStatus(.connected)
}
WHEN("token expires") {
userRobot.waitForJwtToExpire()
backendRobot.waitForJwtToExpire()
}
THEN("app requests a token refresh") {
userRobot.assertConnectionStatus(.connected)
Expand All @@ -142,7 +142,7 @@ final class Authentication_Tests: StreamTestCase {
deviceRobot.moveApplication(to: .background)
}
AND("token expires") {
userRobot.waitForJwtToExpire()
backendRobot.waitForJwtToExpire()
}
WHEN("user comes back to foreground") {
deviceRobot.moveApplication(to: .foreground)
Expand All @@ -164,7 +164,7 @@ final class Authentication_Tests: StreamTestCase {
userRobot.setConnectivity(to: .off)
}
WHEN("token expires") {
userRobot.waitForJwtToExpire()
backendRobot.waitForJwtToExpire()
}
WHEN("user comes back online") {
userRobot.setConnectivity(to: .on)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let app = XCUIApplication()

class StreamTestCase: XCTestCase {
let deviceRobot = DeviceRobot(app)
var userRobot: UserRobot!
let userRobot = UserRobot()
var backendRobot: BackendRobot!
var participantRobot: ParticipantRobot!
var mockServer: StreamMockServer!
Expand All @@ -19,10 +19,6 @@ class StreamTestCase: XCTestCase {
continueAfterFailure = false

try super.setUpWithError()
mockServer = StreamMockServer(driverPort: "4566", testName: testName)
backendRobot = BackendRobot(mockServer)
participantRobot = ParticipantRobot(mockServer)
userRobot = UserRobot(mockServer)
alertHandler()
backendHandler()
app.launch()
Expand All @@ -48,6 +44,9 @@ extension StreamTestCase {
])

if useMockServer {
mockServer = StreamMockServer(driverPort: "4566", testName: testName)
backendRobot = BackendRobot(mockServer)
participantRobot = ParticipantRobot(mockServer)
app.setLaunchArguments(.useMockServer)
} else if let switchApiKey {
app.setEnvironmentVariables([.customApiKey: switchApiKey])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public class BackendRobot {
_ = mockServer.postRequest(endpoint: "delay_messages?delay=\(seconds)")
return self
}

@discardableResult
public func waitForJwtToExpire() -> Self {
let sleepTime = UInt32((StreamMockServer.jwtTimeout + 2) * 1_000_000)
usleep(sleepTime)
return self
}

public func revokeToken(duration: Int = 5) {
waitForMockServerToStart()
Expand Down
Loading