Skip to content

Commit 216b8d4

Browse files
[CI] Use local images instead of remote ones for snapshot tests (#914)
1 parent df1898a commit 216b8d4

File tree

85 files changed

+51
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+51
-73
lines changed

β€Ž.github/workflows/cron-checks.ymlβ€Ž

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
strategy:
2222
matrix:
2323
include:
24-
- ios: 18.3
25-
xcode: 16.3
24+
- ios: 18.5
25+
xcode: 16.4
2626
os: macos-15
2727
device: "iPhone 16 Pro"
2828
setup_runtime: false
@@ -91,11 +91,7 @@ jobs:
9191
strategy:
9292
matrix:
9393
include:
94-
- xcode: 16.3
95-
os: macos-15
96-
- xcode: 16.2
97-
os: macos-15
98-
- xcode: 16.1
94+
- xcode: 16.4
9995
os: macos-15
10096
- xcode: 16.0
10197
os: macos-15

β€Ž.github/workflows/smoke-checks.ymlβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ concurrency:
2020

2121
env:
2222
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI
23-
IOS_SIMULATOR_DEVICE: "iPhone 16 Pro (18.3)"
23+
IOS_SIMULATOR_DEVICE: "iPhone 16 Pro (18.5)"
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
2626

2727
jobs:
2828
build-test-app-and-frameworks:
2929
name: Build Test App and Frameworks
3030
runs-on: macos-15
31+
if: ${{ github.event.inputs.record_snapshots != 'true' }}
3132
steps:
3233
- uses: actions/[email protected]
3334
- uses: ./.github/actions/ruby-cache

β€ŽStreamChatSwiftUI.xcodeproj/project.pbxprojβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@
449449
84DEC8EA2761089A00172876 /* MessageThreadHeaderViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DEC8E92761089A00172876 /* MessageThreadHeaderViewModifier.swift */; };
450450
84DEC8EC27611CAE00172876 /* SendInChannelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DEC8EB27611CAE00172876 /* SendInChannelView.swift */; };
451451
84E04789284A444E00BAFA17 /* AnyEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D2127579359007FE2B9 /* AnyEndpoint.swift */; };
452-
84E0478A284A444E00BAFA17 /* StreamChatUtilsMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D5B275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift */; };
452+
84E0478A284A444E00BAFA17 /* VideoPreviewLoader_Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D5B275A2E9F007FE2B9 /* VideoPreviewLoader_Mock.swift */; };
453453
84E0478B284A444E00BAFA17 /* VirtualTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D272757954C007FE2B9 /* VirtualTimer.swift */; };
454454
84E0478C284A444E00BAFA17 /* TestRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D1927579273007FE2B9 /* TestRequest.swift */; };
455455
84E0478D284A444E00BAFA17 /* ImageLoader_Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D452757D1CA007FE2B9 /* ImageLoader_Mock.swift */; };
@@ -1046,7 +1046,7 @@
10461046
84C94D55275A1AE1007FE2B9 /* StringExtensions_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions_Tests.swift; sourceTree = "<group>"; };
10471047
84C94D57275A1B89007FE2B9 /* MessageTypeResolver_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTypeResolver_Tests.swift; sourceTree = "<group>"; };
10481048
84C94D59275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChat_Utils_Tests.swift; sourceTree = "<group>"; };
1049-
84C94D5B275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChatUtilsMocks.swift; sourceTree = "<group>"; };
1049+
84C94D5B275A2E9F007FE2B9 /* VideoPreviewLoader_Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPreviewLoader_Mock.swift; sourceTree = "<group>"; };
10501050
84C94D5D275A3AA9007FE2B9 /* ImageCDN_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCDN_Tests.swift; sourceTree = "<group>"; };
10511051
84C94D5F275A45D2007FE2B9 /* ViewFactory_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewFactory_Tests.swift; sourceTree = "<group>"; };
10521052
84C94D61275A5BB7007FE2B9 /* ChatChannelNamer_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatChannelNamer_Tests.swift; sourceTree = "<group>"; };
@@ -2099,7 +2099,7 @@
20992099
84C94D29275796D0007FE2B9 /* MockNetworkURLProtocol.swift */,
21002100
84C94D2B275796F7007FE2B9 /* RequestRecorderURLProtocol.swift */,
21012101
84C94D452757D1CA007FE2B9 /* ImageLoader_Mock.swift */,
2102-
84C94D5B275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift */,
2102+
84C94D5B275A2E9F007FE2B9 /* VideoPreviewLoader_Mock.swift */,
21032103
847BA08227E0B9C600ED20C7 /* EventBatcherMock.swift */,
21042104
847BA08427E0BA2500ED20C7 /* EventNotificationCenterMock.swift */,
21052105
847BA08627E0BACB00ED20C7 /* WebSocketPingControllerMock.swift */,
@@ -3099,7 +3099,7 @@
30993099
84C94D422757C16D007FE2B9 /* ChatChannelListTestHelpers.swift in Sources */,
31003100
84BB4C4E284115C200CBE004 /* MessageListDateUtils_Tests.swift in Sources */,
31013101
84C94D5A275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift in Sources */,
3102-
84E0478A284A444E00BAFA17 /* StreamChatUtilsMocks.swift in Sources */,
3102+
84E0478A284A444E00BAFA17 /* VideoPreviewLoader_Mock.swift in Sources */,
31033103
);
31043104
runOnlyForDeploymentPostprocessing = 0;
31053105
};

β€ŽStreamChatSwiftUITests/Infrastructure/Mocks/ImageLoader_Mock.swiftβ€Ž

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import Foundation
66
@testable import StreamChat
77
import StreamChatSwiftUI
88
import UIKit
9+
import XCTest
910

11+
/// Mock implementation of `ImageLoading`.
1012
class ImageLoader_Mock: ImageLoading {
11-
static let defaultLoadedImage = UIImage(systemName: "checkmark")!
13+
static let defaultLoadedImage = XCTestCase.TestImages.yoda.image
14+
var loadImageCalled = false
1215

1316
func loadImage(
1417
url: URL?,
@@ -17,6 +20,8 @@ class ImageLoader_Mock: ImageLoading {
1720
preferredSize: CGSize?,
1821
completion: @escaping ((Result<UIImage, Error>) -> Void)
1922
) {
23+
loadImageCalled = true
24+
2025
completion(.success(Self.defaultLoadedImage))
2126
}
2227

@@ -28,9 +33,8 @@ class ImageLoader_Mock: ImageLoading {
2833
imageCDN: ImageCDN,
2934
completion: @escaping (([UIImage]) -> Void)
3035
) {
31-
let result = urls.map { _ in
32-
Self.defaultLoadedImage
33-
}
34-
completion(result)
36+
loadImageCalled = true
37+
38+
completion([Self.defaultLoadedImage])
3539
}
3640
}
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,15 @@
44

55
import StreamChatSwiftUI
66
import UIKit
7+
import XCTest
78

89
/// Mock implementation of `VideoPreviewLoader`.
910
class VideoPreviewLoader_Mock: VideoPreviewLoader {
1011
var loadPreviewVideoCalled = false
1112

1213
func loadPreviewForVideo(at url: URL, completion: @escaping (Result<UIImage, Error>) -> Void) {
1314
loadPreviewVideoCalled = true
14-
}
15-
}
16-
17-
/// Mock implementation of `ImageLoading`.
18-
class ImageLoaderUtils_Mock: ImageLoading {
19-
var loadImageCalled = false
2015

21-
func loadImage(
22-
url: URL?,
23-
imageCDN: ImageCDN,
24-
resize: Bool,
25-
preferredSize: CGSize?,
26-
completion: @escaping ((Result<UIImage, Error>) -> Void)
27-
) {
28-
loadImageCalled = true
16+
completion(.success(ImageLoader_Mock.defaultLoadedImage))
2917
}
3018
}

β€ŽStreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/PinnedMessagesView_Tests.swiftβ€Ž

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import SwiftUI
1010
import XCTest
1111

1212
class PinnedMessagesView_Tests: StreamChatTestCase {
13-
override func setUp() {
14-
super.setUp()
15-
let utils = Utils(dateFormatter: EmptyDateFormatter())
16-
streamChat = StreamChat(chatClient: chatClient, utils: utils)
17-
}
18-
1913
func test_pinnedMessagesView_notEmptySnapshot() {
2014
// Given
2115
let channel = ChatChannel.mockDMChannel(

0 commit comments

Comments
Β (0)