From 7dec4bd23c53f53ba83888d51ebe7a5d3237adb0 Mon Sep 17 00:00:00 2001 From: Yurii Dukhovnyi Date: Wed, 13 Sep 2023 21:44:54 +0300 Subject: [PATCH] Introduce list queue interface Restore Swift Package Manager compatibility in a local package connectivity mode. MOB-2594 --- GliaWidgets.xcodeproj/project.pbxproj | 4 --- .../Component/Bubble/BubbleView.Mock.swift | 3 +++ .../Sources/Interactor/Interactor.swift | 6 +++-- .../Chat/ChatViewController.Mock.swift | 25 ++++++++++++++++++ GliaWidgetsTests/CoreSdk/CoreSdk.swift | 26 ------------------- 5 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 GliaWidgetsTests/CoreSdk/CoreSdk.swift diff --git a/GliaWidgets.xcodeproj/project.pbxproj b/GliaWidgets.xcodeproj/project.pbxproj index 3a24a0096..2b4208b5c 100644 --- a/GliaWidgets.xcodeproj/project.pbxproj +++ b/GliaWidgets.xcodeproj/project.pbxproj @@ -299,7 +299,6 @@ 75CF8D9129C3A85C00CB1524 /* SecureConversationsWelcomeScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CF8D9029C3A85C00CB1524 /* SecureConversationsWelcomeScreenTests.swift */; }; 75CF8DAD29C8F2B500CB1524 /* SecureConversationsConfirmationScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CF8DAC29C8F2B500CB1524 /* SecureConversationsConfirmationScreenTests.swift */; }; 75F58EE127E7D5300065BA2D /* Survey.ViewController.Props.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F58EE027E7D5300065BA2D /* Survey.ViewController.Props.swift */; }; - 75FD003F2A80E8C5002DC458 /* CoreSdk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7552DFB32A6FBC7F0093519B /* CoreSdk.swift */; }; 75FF151427F3A2D600FE7BE2 /* Theme+Survey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FF151327F3A2D600FE7BE2 /* Theme+Survey.swift */; }; 75FF151727F4E13900FE7BE2 /* Theme.Survey.BooleanQuestion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FF151627F4E13900FE7BE2 /* Theme.Survey.BooleanQuestion.swift */; }; 75FF151B27F4F52D00FE7BE2 /* Theme.Survey.SingleQuestion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FF151A27F4F52D00FE7BE2 /* Theme.Survey.SingleQuestion.swift */; }; @@ -953,7 +952,6 @@ 7543141728806AEB00C9C1C6 /* EnvironmentSettingsTextCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvironmentSettingsTextCell.swift; sourceTree = ""; }; 754CC61427E27C42005676E9 /* Survey.Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Survey.Checkbox.swift; sourceTree = ""; }; 7552DFB02A6FB7DF0093519B /* ChatMessageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageTests.swift; sourceTree = ""; }; - 7552DFB32A6FBC7F0093519B /* CoreSdk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreSdk.swift; sourceTree = ""; }; 755D186429A6A4E20009F5E8 /* WelcomeStyle+TitleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WelcomeStyle+TitleStyle.swift"; sourceTree = ""; }; 755D186629A6A4FA0009F5E8 /* WelcomeStyle+SubtitleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WelcomeStyle+SubtitleStyle.swift"; sourceTree = ""; }; 755D186829A6A5270009F5E8 /* WelcomeStyle+CheckMessagesButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WelcomeStyle+CheckMessagesButtonStyle.swift"; sourceTree = ""; }; @@ -2656,7 +2654,6 @@ 7552DFB22A6FBC6E0093519B /* CoreSdk */ = { isa = PBXGroup; children = ( - 7552DFB32A6FBC7F0093519B /* CoreSdk.swift */, ); path = CoreSdk; sourceTree = ""; @@ -4659,7 +4656,6 @@ 754CC61227E2767A005676E9 /* Survey.BooleanQuestionView.swift in Sources */, 755D187529A6A6B70009F5E8 /* WelcomeStyle+SendButton.swift in Sources */, 6EA3516926E139DA00BF5941 /* GliaViewTransitionController.swift in Sources */, - 75FD003F2A80E8C5002DC458 /* CoreSdk.swift in Sources */, C0D2F07929A4E3DF00803B47 /* UserImageView.Mock.swift in Sources */, 84265E6B29912E2100D65842 /* RemoteConfiguration+CallVisualizer.swift in Sources */, 1A1E30C725F9FDAB00850E68 /* ChatImageFileContentView.swift in Sources */, diff --git a/GliaWidgets/Sources/Component/Bubble/BubbleView.Mock.swift b/GliaWidgets/Sources/Component/Bubble/BubbleView.Mock.swift index f39faad43..012a75053 100644 --- a/GliaWidgets/Sources/Component/Bubble/BubbleView.Mock.swift +++ b/GliaWidgets/Sources/Component/Bubble/BubbleView.Mock.swift @@ -1,4 +1,7 @@ #if DEBUG + +import Foundation + extension BubbleView { static func mock( with bubbleStyle: BubbleStyle = .mock(), diff --git a/GliaWidgets/Sources/Interactor/Interactor.swift b/GliaWidgets/Sources/Interactor/Interactor.swift index 5960e6b7c..95ab3e77e 100644 --- a/GliaWidgets/Sources/Interactor/Interactor.swift +++ b/GliaWidgets/Sources/Interactor/Interactor.swift @@ -385,10 +385,12 @@ extension InteractorState: Equatable { switch (lhs, rhs) { case (.none, .none), (.enqueueing, .enqueueing), - (.enqueued, .enqueued), - (.ended, .ended): + (.enqueued, .enqueued): return true + case (.ended(let lhsReason), .ended(let rhsReason)): + return lhsReason == rhsReason + case (.engaged(let lhsOperator), .engaged(let rhsOperator)): return lhsOperator == rhsOperator diff --git a/GliaWidgets/Sources/ViewController/Chat/ChatViewController.Mock.swift b/GliaWidgets/Sources/ViewController/Chat/ChatViewController.Mock.swift index c8f29234d..5b1c85064 100644 --- a/GliaWidgets/Sources/ViewController/Chat/ChatViewController.Mock.swift +++ b/GliaWidgets/Sources/ViewController/Chat/ChatViewController.Mock.swift @@ -641,5 +641,30 @@ extension ChatViewController { """.data(using: .utf8) } } + +/// Defines wrapper structure for getting decoding container. +/// This container can be used when message metadata is needed in +/// tests. +struct CoreSdkMessageMetadataContainer: Decodable { + let container: KeyedDecodingContainer + + init(from decoder: Decoder) throws { + self.container = try decoder.container( + keyedBy: GliaCoreSDK.Message.Metadata.CodingKeys.self + ) + } + + /// Creates instance with decoding container inside. + /// This initializer can be used for created mocked Metadata with passing + /// json-data inside of this initializer. + /// NB! Empty 'jsonData' will lead to decoding error. + init( + jsonData: Data, + jsonDecoder: JSONDecoder = .init() + ) throws { + self = try jsonDecoder.decode(CoreSdkMessageMetadataContainer.self, from: jsonData) + } +} + // swiftlint:enable function_body_length #endif diff --git a/GliaWidgetsTests/CoreSdk/CoreSdk.swift b/GliaWidgetsTests/CoreSdk/CoreSdk.swift deleted file mode 100644 index 089332b9c..000000000 --- a/GliaWidgetsTests/CoreSdk/CoreSdk.swift +++ /dev/null @@ -1,26 +0,0 @@ -import Foundation -import GliaCoreSDK - -/// Defines wrapper structure for getting decoding container. -/// This container can be used when message metadata is needed in -/// tests. -struct CoreSdkMessageMetadataContainer: Decodable { - let container: KeyedDecodingContainer - - init(from decoder: Decoder) throws { - self.container = try decoder.container( - keyedBy: GliaCoreSDK.Message.Metadata.CodingKeys.self - ) - } - - /// Creates instance with decoding container inside. - /// This initializer can be used for created mocked Metadata with passing - /// json-data inside of this initializer. - /// NB! Empty 'jsonData' will lead to decoding error. - init( - jsonData: Data, - jsonDecoder: JSONDecoder = .init() - ) throws { - self = try jsonDecoder.decode(CoreSdkMessageMetadataContainer.self, from: jsonData) - } -}