Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
--rules redundantRawValues
--rules redundantVoidReturnType
--rules semicolons
--rules sortedImports
--rules sortImports
--rules spaceAroundBraces
--rules spaceAroundBrackets
--rules spaceAroundComments
Expand Down Expand Up @@ -81,4 +81,4 @@
--wrapcollections before-first

# Exclude paths
--exclude Sources/StreamChatSwiftUI/Generated,Sources/StreamChatSwiftUI/StreamSwiftyGif,Sources/StreamChatSwiftUI/StreamNuke
--exclude Sources/StreamChatSwiftUI/Generated,Sources/StreamChatSwiftUI/StreamSwiftyGif,Sources/StreamChatSwiftUI/StreamNuke,vendor/bundle,Pods,spm_cache,derived_data,.build
5 changes: 1 addition & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ excluded:
- Sources/StreamChatSwiftUI/Generated
- Sources/StreamChatSwiftUI/StreamSwiftyGif
- Sources/StreamChatSwiftUI/StreamNuke
- vendor/bundle

only_rules:
- attribute_name_spacing
Expand Down Expand Up @@ -43,7 +44,6 @@ only_rules:
- trailing_comma
- trailing_newline
- trailing_semicolon
- trailing_whitespace
- unneeded_break_in_switch
- unneeded_override
- unused_closure_parameter
Expand All @@ -55,8 +55,5 @@ only_rules:
multiline_arguments:
only_enforce_after_first_closure_on_first_line: true

trailing_whitespace:
ignores_empty_lines: true

file_name_no_space:
severity: error
4 changes: 1 addition & 3 deletions Scripts/GenerateSPMFileLists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func sourceFileList(at url: URL) -> [String] {
let basePathRange = path.range(of: url.path + "/")!
return String(path[basePathRange.upperBound...])
}
.filter { $0.hasSuffix("_Tests.swift") || $0.hasSuffix("_Mock.swift") || $0.contains("__Snapshots__")}
.filter { $0.hasSuffix("_Tests.swift") || $0.hasSuffix("_Mock.swift") || $0.contains("__Snapshots__") }

return sourceFiles
}
Expand All @@ -59,8 +59,6 @@ newGeneratedContent += "] }\n"

newGeneratedContent += "\n"



// StreamChatUI excluded source files
let streamChatUIExcludedFiles = sourceFileList(at: URL(string: "Sources/StreamChatUI")!)
newGeneratedContent += "var streamChatUIFilesExcluded: [String] { [\n"
Expand Down
20 changes: 12 additions & 8 deletions StreamChatSwiftUITestsApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
import SwiftUI

class AppDelegate: NSObject, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
disableAnimations()
registerForPushNotifications()
UNUserNotificationCenter.current().delegate = NotificationsHandler.shared
return true
}

func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
sceneConfig.delegateClass = SceneDelegate.self
return sceneConfig
Expand Down Expand Up @@ -44,13 +47,14 @@ class AppDelegate: NSObject, UIApplicationDelegate {
}

func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
let token = tokenParts.joined()
print("Device Token: \(token)")
}

func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error
Expand Down
2 changes: 0 additions & 2 deletions StreamChatSwiftUITestsApp/CustomChannelHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import StreamChatSwiftUI
import SwiftUI

public struct CustomChannelHeader: ToolbarContent {

@Injected(\.fonts) var fonts
@Injected(\.images) var images
@Injected(\.colors) var colors
Expand Down Expand Up @@ -36,7 +35,6 @@ public struct CustomChannelHeader: ToolbarContent {
}

struct CustomChannelModifier: ChannelListHeaderViewModifier {

@Injected(\.chatClient) var chatClient

var title: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation

//#if TESTS
// #if TESTS
@testable import StreamChat

final class InternetConnectionMonitor_Mock: InternetConnectionMonitor {
Expand All @@ -19,6 +19,6 @@ final class InternetConnectionMonitor_Mock: InternetConnectionMonitor {
self.status = status
delegate?.internetConnectionStatusDidChange(status: status)
}

}
//#endif

// #endif
8 changes: 3 additions & 5 deletions StreamChatSwiftUITestsApp/StartPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import SwiftUI
import StreamChat
import StreamChatSwiftUI
import SwiftUI

struct StartPage: View {

@State var streamChat: StreamChat?
@State var chatShown = false
@ObservedObject var appState = AppState.shared
Expand Down Expand Up @@ -67,8 +66,8 @@ struct StartPage: View {
streamChat = StreamChat(chatClient: chatClient)

chatClient.connectUser(
userInfo: .init(id: credentials.id, name: credentials.name, imageURL: credentials.avatarURL),
token: token
userInfo: .init(id: credentials.id, name: credentials.name, imageURL: credentials.avatarURL),
token: token
) { error in
if let error = error {
log.error("connecting the user failed \(error)")
Expand All @@ -79,7 +78,6 @@ struct StartPage: View {
}

class DemoAppFactory: ViewFactory {

@Injected(\.chatClient) public var chatClient

private init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import SwiftUI

@main
struct StreamChatSwiftUITestsAppApp: App {

@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

var body: some Scene {
Expand All @@ -18,7 +17,6 @@ struct StreamChatSwiftUITestsAppApp: App {
}

class AppState: ObservableObject, Equatable {

static func == (lhs: AppState, rhs: AppState) -> Bool {
lhs.userState == rhs.userState
}
Expand Down
12 changes: 6 additions & 6 deletions StreamChatSwiftUITestsApp/StreamChatWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

import Foundation
#if TESTS
@testable import StreamChat
import OHHTTPStubs
@testable import StreamChat
#else
import StreamChat
#endif
import StreamChatSwiftUI
import UIKit

final class StreamChatWrapper {

@Injected(\.chatClient) var client

static let shared = StreamChatWrapper()
Expand All @@ -26,9 +25,11 @@ final class StreamChatWrapper {
let baseURL = self.client.config.baseURL.restAPIBaseURL.absoluteString
return request.url?.absoluteString.contains(baseURL) ?? false
}, withStubResponse: { _ -> HTTPStubsResponse in
let error = NSError(domain: "NSURLErrorDomain",
code: -1009,
userInfo: nil)
let error = NSError(
domain: "NSURLErrorDomain",
code: -1009,
userInfo: nil
)
return HTTPStubsResponse(error: error)
})

Expand All @@ -51,5 +52,4 @@ final class StreamChatWrapper {
}
#endif
}

}
14 changes: 7 additions & 7 deletions StreamChatSwiftUITestsApp/UserCredentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public struct UserCredentials {
}

extension UserCredentials {

static func builtInUsersByID(id: String) -> UserCredentials? {
mock
}

static let mock: 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")

static let mock: 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 @@ -3,11 +3,10 @@
//

import Foundation
import XCTest
import StreamChat
import XCTest

enum ChannelListPage {

static var userAvatar: XCUIElement {
return app.buttons["LogoutButton"]
}
Expand Down Expand Up @@ -55,5 +54,4 @@ enum ChannelListPage {
return cell.images["readIndicatorCheckmark"]
}
}

}
16 changes: 7 additions & 9 deletions StreamChatSwiftUITestsAppTests/Pages/MessageListPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
//

import Foundation
import XCTest
import StreamChat
@testable import StreamChatSwiftUI
import XCTest

// swiftlint:disable convenience_type

class MessageListPage {

static var cells: XCUIElementQuery {
app.otherElements.matching(identifier: "MessageContainerView")
}
Expand Down Expand Up @@ -44,7 +43,6 @@ class MessageListPage {
}

enum NavigationBar {

static var chatAvatar: XCUIElement {
app.images["ChannelAvatarView"]
}
Expand All @@ -57,13 +55,13 @@ class MessageListPage {
app.staticTexts.matching(identifier: "ChannelTitleView").lastMatch!
}

// FIXME
// FIXME:
static var debugMenu: XCUIElement {
app.buttons[""].firstMatch
}
}

// FIXME
// FIXME:
enum Alert {
enum Debug {
// Add member
Expand Down Expand Up @@ -168,7 +166,7 @@ class MessageListPage {
messageCell.staticTexts["readIndicatorCount"]
}

// FIXME
// FIXME:
static func statusCheckmark(for status: MessageDeliveryStatus? = nil, in messageCell: XCUIElement) -> XCUIElement {
messageCell.images["readIndicatorCheckmark"]
}
Expand Down Expand Up @@ -314,7 +312,7 @@ class MessageListPage {
}
}

struct Element {
enum Element {
static var actionsView: XCUIElement { app.otherElements["MessageActionsView"] }
static var reply: XCUIElement { app.otherElements["messageAction-reply_message_action"].images.firstMatch }
static var threadReply: XCUIElement { app.otherElements["messageAction-thread_message_action"].images.firstMatch }
Expand All @@ -324,7 +322,7 @@ class MessageListPage {
static var unmute: XCUIElement { app.otherElements["messageAction-unmute_message_action"].images.firstMatch }
static var edit: XCUIElement { app.otherElements["messageAction-edit_message_action"].images.firstMatch }
static var delete: XCUIElement { app.otherElements["messageAction-delete_message_action"].images.firstMatch }
static var hardDelete: XCUIElement { app.otherElements["messageAction-delete_message_action"].images.firstMatch } // FIXME
static var hardDelete: XCUIElement { app.otherElements["messageAction-delete_message_action"].images.firstMatch } // FIXME:
static var resend: XCUIElement { app.otherElements["messageAction-resend_message_action"].images.firstMatch }
static var pin: XCUIElement { app.otherElements["messageAction-pin_message_action"].images.firstMatch }
static var unpin: XCUIElement { app.otherElements["messageAction-unpin_message_action"].images.firstMatch }
Expand All @@ -348,6 +346,7 @@ class MessageListPage {
static var cancelButton: XCUIElement {
app.scrollViews.buttons.matching(NSPredicate(format: "label LIKE 'Cancel'")).firstMatch
}

static var images: XCUIElementQuery { app.scrollViews["AttachmentTypeContainer"].images }
}

Expand All @@ -374,5 +373,4 @@ class MessageListPage {
app.scrollViews["CommandsContainerView"].otherElements.matching(NSPredicate(format: "identifier LIKE 'MessageAvatarView'"))
}
}

}
6 changes: 3 additions & 3 deletions StreamChatSwiftUITestsAppTests/Pages/SpringBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ enum SpringBoard {

static var notificationBanner: XCUIElement {
app.otherElements["Notification"]
.descendants(matching: .any)
.matching(NSPredicate(format: "label CONTAINS[c] ', now,'"))
.firstMatch
.descendants(matching: .any)
.matching(NSPredicate(format: "label CONTAINS[c] ', now,'"))
.firstMatch
}

static var testAppIcon: XCUIElement {
Expand Down
2 changes: 0 additions & 2 deletions StreamChatSwiftUITestsAppTests/Pages/ThreadPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ import Foundation
import XCTest

class ThreadPage: MessageListPage {

static var alsoSendInChannelCheckbox: XCUIElement { app.buttons["SendInChannelView"] }

}
Loading
Loading