Skip to content

Commit

Permalink
Updated StreamChat dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski committed Oct 27, 2022
1 parent 7f9a73d commit 458bef6
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.22.0"),
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.23.0"),
.package(url: "https://github.com/kean/Nuke.git", .exact("11.3.0"))
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion StreamChatSwiftUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Pod::Spec.new do |spec|

spec.framework = "Foundation", "UIKit", "SwiftUI"

spec.dependency "StreamChat", "~> 4.22.0"
spec.dependency "StreamChat", "~> 4.23.0"
spec.dependency "SwiftyGif", "~> 5.0"
spec.dependency "NukeUI", "0.8.0"
end
Expand Down
14 changes: 9 additions & 5 deletions StreamChatSwiftUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
8421BCEC27A400E8000F977D /* ReactionsUsersView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8421BCEB27A400E8000F977D /* ReactionsUsersView_Tests.swift */; };
8421BCEE27A43E14000F977D /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8421BCED27A43E14000F977D /* SearchBar.swift */; };
8421BCF027A44EAE000F977D /* SearchResultsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8421BCEF27A44EAE000F977D /* SearchResultsView.swift */; };
842383E02767394200888CFC /* ChatChannelDataSource_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842383DF2767394200888CFC /* ChatChannelDataSource_Tests.swift */; };
842383E427678A4D00888CFC /* QuotedMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842383E327678A4D00888CFC /* QuotedMessageView.swift */; };
8423C33D277C94F30092DCF1 /* TwoStepMentionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8423C33C277C94F30092DCF1 /* TwoStepMentionCommand.swift */; };
8423C33F277C9A5F0092DCF1 /* UnmuteCommandHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8423C33E277C9A5F0092DCF1 /* UnmuteCommandHandler.swift */; };
Expand Down Expand Up @@ -278,6 +277,9 @@
84C94D66275A660B007FE2B9 /* MessageActionsViewModel_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D65275A660B007FE2B9 /* MessageActionsViewModel_Tests.swift */; };
84C94D68275A6AFD007FE2B9 /* ChannelHeaderLoader_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D67275A6AFD007FE2B9 /* ChannelHeaderLoader_Tests.swift */; };
84CAD77B284E5AAA00F28C17 /* MessageListViewLastGroupHeader_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CAD77A284E5AAA00F28C17 /* MessageListViewLastGroupHeader_Tests.swift */; };
84CC3731290B095E00689B73 /* ChatChannelDataSource_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842383DF2767394200888CFC /* ChatChannelDataSource_Tests.swift */; };
84CC3732290B0A4000689B73 /* StreamChatModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84E57C5528103822002213C1 /* StreamChatModel.xcdatamodeld */; };
84CC3734290B0C2900689B73 /* ChatMessageControllerSUI_Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC3733290B0C2900689B73 /* ChatMessageControllerSUI_Mock.swift */; };
84D419BA28EAD20C00F574F9 /* ChatMessageBubbles_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D419B928EAD20C00F574F9 /* ChatMessageBubbles_Tests.swift */; };
84D6B55A27DF6EC7009C6D07 /* LoadingView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6B55927DF6EC7009C6D07 /* LoadingView_Tests.swift */; };
84D77B58289D3CF800C241CE /* MessageListViewAvatars_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D77B57289D3CF800C241CE /* MessageListViewAvatars_Tests.swift */; };
Expand Down Expand Up @@ -305,7 +307,6 @@
84E04797284A444E00BAFA17 /* WebSocketPingControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847BA08627E0BACB00ED20C7 /* WebSocketPingControllerMock.swift */; };
84E04798284A444E00BAFA17 /* InternetConnectionMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D23275794D3007FE2B9 /* InternetConnectionMock.swift */; };
84E57C5928103822002213C1 /* TestDataModel2.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84E57C5328103822002213C1 /* TestDataModel2.xcdatamodeld */; };
84E57C5A28103822002213C1 /* StreamChatModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84E57C5528103822002213C1 /* StreamChatModel.xcdatamodeld */; };
84E57C5B28103822002213C1 /* TestDataModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84E57C5728103822002213C1 /* TestDataModel.xcdatamodeld */; };
84E6EC23279AEE6B0017207B /* MessageContainerView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E6EC22279AEE6B0017207B /* MessageContainerView_Tests.swift */; };
84E6EC25279AEE9F0017207B /* StreamChatTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E6EC24279AEE9F0017207B /* StreamChatTestCase.swift */; };
Expand Down Expand Up @@ -689,6 +690,7 @@
84C94D65275A660B007FE2B9 /* MessageActionsViewModel_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActionsViewModel_Tests.swift; sourceTree = "<group>"; };
84C94D67275A6AFD007FE2B9 /* ChannelHeaderLoader_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelHeaderLoader_Tests.swift; sourceTree = "<group>"; };
84CAD77A284E5AAA00F28C17 /* MessageListViewLastGroupHeader_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewLastGroupHeader_Tests.swift; sourceTree = "<group>"; };
84CC3733290B0C2900689B73 /* ChatMessageControllerSUI_Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageControllerSUI_Mock.swift; sourceTree = "<group>"; };
84D419B928EAD20C00F574F9 /* ChatMessageBubbles_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageBubbles_Tests.swift; sourceTree = "<group>"; };
84D6B55927DF6EC7009C6D07 /* LoadingView_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView_Tests.swift; sourceTree = "<group>"; };
84D77B57289D3CF800C241CE /* MessageListViewAvatars_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewAvatars_Tests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1351,6 +1353,7 @@
847BA08427E0BA2500ED20C7 /* EventNotificationCenterMock.swift */,
847BA08627E0BACB00ED20C7 /* WebSocketPingControllerMock.swift */,
847BA08827E0BAEE00ED20C7 /* WebSocketEngineMock.swift */,
84CC3733290B0C2900689B73 /* ChatMessageControllerSUI_Mock.swift */,
);
path = Mocks;
sourceTree = "<group>";
Expand Down Expand Up @@ -2004,7 +2007,6 @@
84E0478E284A444E00BAFA17 /* WebSocketEngineMock.swift in Sources */,
84C94D4D2758FD5C007FE2B9 /* MessageComposerViewModel_Tests.swift in Sources */,
84C94D62275A5BB7007FE2B9 /* ChatChannelNamer_Tests.swift in Sources */,
84E57C5A28103822002213C1 /* StreamChatModel.xcdatamodeld in Sources */,
840A3F3828193AB20084E9CC /* ChatChannelInfoView_Tests.swift in Sources */,
84C94D492758BE1C007FE2B9 /* ChatChannelViewModel_Tests.swift in Sources */,
842F036D288E93BF00496D49 /* ChatMessage_AdjustedText_Tests.swift in Sources */,
Expand Down Expand Up @@ -2033,18 +2035,20 @@
84AB7B21277203EF00631A10 /* GalleryView_Tests.swift in Sources */,
84E0478D284A444E00BAFA17 /* ImageLoader_Mock.swift in Sources */,
8423C348277DBBDA0092DCF1 /* InstantCommandsHandler_Tests.swift in Sources */,
842383E02767394200888CFC /* ChatChannelDataSource_Tests.swift in Sources */,
84DEC8DF2760A1D100172876 /* MessageView_Tests.swift in Sources */,
847F7949282A91AD0009F74C /* ChatChannelView_Tests.swift in Sources */,
84CC3734290B0C2900689B73 /* ChatMessageControllerSUI_Mock.swift in Sources */,
91B763A6283EB39600B458A9 /* MoreChannelActionsFullScreenWrappingView_Tests.swift in Sources */,
846608E9278C98CB00D3D7B3 /* TypingIndicatorView_Tests.swift in Sources */,
8421BCEC27A400E8000F977D /* ReactionsUsersView_Tests.swift in Sources */,
84E04794284A444E00BAFA17 /* APIClient_Mock.swift in Sources */,
844D1D682851DE58000CCCB9 /* ChannelControllerFactory_Tests.swift in Sources */,
84CC3731290B095E00689B73 /* ChatChannelDataSource_Tests.swift in Sources */,
84B439E127C6B2F100C04C99 /* MessageCachingUtils_Tests.swift in Sources */,
8423C346277D9BFF0092DCF1 /* TestCommandsConfig.swift in Sources */,
84B2B5D82819778D00479CEE /* FileAttachmentsViewModel_Tests.swift in Sources */,
841B2EF6278F108700ED619E /* MessageReadIndicatorView_Tests.swift in Sources */,
84CC3732290B0A4000689B73 /* StreamChatModel.xcdatamodeld in Sources */,
84E04790284A444E00BAFA17 /* CDNClient_Mock.swift in Sources */,
84E04796284A444E00BAFA17 /* EventBatcherMock.swift in Sources */,
84E57C5B28103822002213C1 /* TestDataModel.xcdatamodeld in Sources */,
Expand Down Expand Up @@ -2657,7 +2661,7 @@
repositoryURL = "https://github.com/GetStream/stream-chat-swift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.22.0;
minimumVersion = 4.23.0;
};
};
A3571601283E9D9F0014E3B0 /* XCRemoteSwiftPackageReference "swifter" */ = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// Copyright © 2022 Stream.io Inc. All rights reserved.
//

import Foundation
@testable import StreamChat
@testable import StreamChatTestTools

public class ChatMessageControllerSUI_Mock: ChatMessageController {
/// Creates a new mock instance of `ChatMessageController`.
public static func mock(
chatClient: ChatClient,
currentUserId: UserId = "ID",
cid: ChannelId? = nil,
messageId: String = "MockMessage"
) -> ChatMessageController_Mock {
if let authenticationRepository = chatClient.authenticationRepository as? AuthenticationRepository_Mock {
authenticationRepository.mockedCurrentUserId = currentUserId
}
var channelId = cid
if channelId == nil {
channelId = try! .init(cid: "mock:channel")
}
return .init(client: chatClient, cid: channelId!, messageId: messageId)
}

public var message_mock: ChatMessage?
override public var message: ChatMessage? {
message_mock ?? super.message
}

public var replies_mock: [ChatMessage]?
override public var replies: LazyCachedMapCollection<ChatMessage> {
replies_mock.map { $0.lazyCachedMap { $0 } } ?? super.replies
}

public var state_mock: State?
override public var state: DataController.State {
get { state_mock ?? super.state }
set { super.state = newValue }
}

public var startObserversIfNeeded_mock: (() -> Void)?
override public func startObserversIfNeeded() {
if let mock = startObserversIfNeeded_mock {
mock()
return
}

super.startObserversIfNeeded()
}

var synchronize_callCount = 0
override public func synchronize(_ completion: ((Error?) -> Void)? = nil) {
synchronize_callCount += 1
}
}

public extension ChatMessageControllerSUI_Mock {
/// Simulates the initial conditions. Setting these values doesn't trigger any observer callback.
func simulateInitial(message: ChatMessage, replies: [ChatMessage], state: DataController.State) {
message_mock = message
replies_mock = replies
state_mock = state
// Initial simulation should also have a user pre-created
try? client.databaseContainer.createCurrentUser()
}

/// Simulates a change of the `message` value. Observers are notified with the provided `change` value.
func simulate(message: ChatMessage?, change: EntityChange<ChatMessage>) {
message_mock = message
delegateCallback {
$0.messageController(self, didChangeMessage: change)
}
}

/// Simulates changes in the `replies` array. Observers are notified with the provided `changes` value.
func simulate(replies: [ChatMessage], changes: [ListChange<ChatMessage>]) {
replies_mock = replies
delegateCallback {
$0.messageController(self, didChangeReplies: changes)
}
}

/// Simulates changes of `state`. Observers are notified with the new value.
func simulate(state: DataController.State) {
state_mock = state
delegateCallback {
$0.controller(self, didChangeState: state)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class ChatChannelDataSource_Tests: StreamChatTestCase {
// Given
let channel = ChatChannel.mockDMChannel()
let expected: [ChatMessage] = [message]
let messageController = ChatMessageController_Mock.mock(
client: chatClient,
let messageController = ChatMessageControllerSUI_Mock.mock(
chatClient: chatClient,
cid: channel.cid,
messageId: message.id
)
Expand All @@ -113,8 +113,8 @@ class ChatChannelDataSource_Tests: StreamChatTestCase {
// Given
let channel = ChatChannel.mockDMChannel()
let expected: [ChatMessage] = [message]
let messageController = ChatMessageController_Mock.mock(
client: chatClient,
let messageController = ChatMessageControllerSUI_Mock.mock(
chatClient: chatClient,
cid: channel.cid,
messageId: message.id
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class ChatChannelViewModel_Tests: StreamChatTestCase {
func test_chatChannelVM_messageThread() {
// Given
let channelController = makeChannelController()
let messageController = ChatMessageController_Mock.mock(
client: chatClient,
let messageController = ChatMessageControllerSUI_Mock.mock(
chatClient: chatClient,
cid: .unique,
messageId: .unique
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ class MessageComposerViewModel_Tests: StreamChatTestCase {
func test_messageComposerVM_inThread() {
// Given
let channelController = makeChannelController()
let messageController = ChatMessageController_Mock.mock(
client: chatClient,
let messageController = ChatMessageControllerSUI_Mock.mock(
chatClient: chatClient,
cid: .unique,
messageId: .unique
)
Expand Down
5 changes: 4 additions & 1 deletion StreamChatSwiftUITests/Tests/StreamChatTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ open class StreamChatTestCase: XCTestCase {

public var chatClient: ChatClient = {
let client = ChatClient.mock(isLocalStorageEnabled: false)
client.currentUserId = currentUserId
let tokenValue =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.b6EiC8dq2AHk0JPfI-6PN-AM9TVzt8JV-qB1N9kchlI"
let token = try! Token(rawValue: tokenValue)
client.connectUser(userInfo: .init(id: currentUserId), token: token)
return client
}()

Expand Down

0 comments on commit 458bef6

Please sign in to comment.