Skip to content

Commit

Permalink
Add an option to switch API keys in the tests (#3248)
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored Jun 14, 2024
1 parent 846f754 commit 08a4626
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DemoApp/Shared/DemoUsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Foundation
import StreamChat

let apiKeyString = "8br4watad788"
let apiKeyString = ProcessInfo.processInfo.arguments.contains("SWIFTUI_API_KEY") ? "zcgvnykxsfm8" : "8br4watad788"
let applicationGroupIdentifier = "group.io.getstream.iOS.ChatDemoApp"

enum DemoUserType {
Expand Down
12 changes: 12 additions & 0 deletions StreamChatUITestsApp/StreamChat/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ import StreamChat
extension UserCredentials {

static var `default`: UserCredentials {
ProcessInfo.processInfo.arguments.contains("SWIFTUI_API_KEY") ? .swiftUI : .swift
}

static var swift: UserCredentials {
UserCredentials(id: "luke_skywalker",
name: "Luke Skywalker",
avatarURL: URL(string: "https://vignette.wikia.nocookie.net/starwars/images/2/20/LukeTLJ.jpg")!,
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.kFSLHRB5X62t0Zlc7nwczWUfsQMwfkpylC6jCUZ6Mc0",
birthLand: "Tatooine")
}

static var swiftUI: UserCredentials {
UserCredentials(id: "luke_skywalker",
name: "Luke Skywalker",
avatarURL: URL(string: "https://vignette.wikia.nocookie.net/starwars/images/2/20/LukeTLJ.jpg")!,
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.b6EiC8dq2AHk0JPfI-6PN-AM9TVzt8JV-qB1N9kchlI",
birthLand: "Tatooine")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class StreamTestCase: XCTestCase {
var server: StreamMockServer!
var recordVideo = false
var mockServerEnabled = true
var switchApiKey = false

override func setUpWithError() throws {
continueAfterFailure = false
Expand Down Expand Up @@ -58,6 +59,9 @@ extension StreamTestCase {
.httpHost: "\(MockServerConfiguration.httpHost)",
.port: "\(MockServerConfiguration.port)"
])
} else if switchApiKey {
// Use SwiftUI api key instead
app.setLaunchArguments(.switchApiKey)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class ChannelListScrollTime: StreamTestCase {

override func setUpWithError() throws {
mockServerEnabled = false
switchApiKey = true
try super.setUpWithError()
}

func testChannelListScrollTime() {
WHEN("user opens the channel list") {
backendRobot.generateChannels(count: 100, messagesCount: 1)
userRobot.login().waitForChannelListToLoad()
}
THEN("user scrolls the channel list") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum EnvironmentVariable: String {

public enum LaunchArgument: String {
case useMockServer = "USE_MOCK_SERVER"
case switchApiKey = "SWIFTUI_API_KEY"
case jwt = "MOCK_JWT"
}

Expand Down

0 comments on commit 08a4626

Please sign in to comment.