Skip to content

Commit 32ddf81

Browse files
[CI] Introduce Backend Integration Tests (#3876)
1 parent 1f9b6c3 commit 32ddf81

7 files changed

Lines changed: 180 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Backend Checks
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
env:
11+
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI
12+
IOS_SIMULATOR_DEVICE: "iPhone 16 Pro (18.5)"
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
jobs:
16+
test-backend-integration:
17+
name: Test Backend Integration
18+
runs-on: macos-15
19+
steps:
20+
- uses: actions/checkout@v4.1.1
21+
- uses: ./.github/actions/bootstrap
22+
env:
23+
INSTALL_YEETD: true
24+
SKIP_SWIFT_BOOTSTRAP: true
25+
- name: Run UI Tests (Debug)
26+
run: bundle exec fastlane test_e2e device:"${{ env.IOS_SIMULATOR_DEVICE }}"
27+
timeout-minutes: 100
28+
- name: Parse xcresult
29+
if: failure()
30+
run: |
31+
brew install chargepoint/xcparse/xcparse
32+
xcparse logs fastlane/test_output/StreamChatUITestsApp.xcresult fastlane/test_output/logs/
33+
- uses: actions/upload-artifact@v4
34+
if: failure()
35+
with:
36+
name: Test Data Backend Integration
37+
path: |
38+
fastlane/recordings
39+
fastlane/sinatra_log.txt
40+
fastlane/test_output/logs/*/Diagnostics/**/*.txt
41+
fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/*

StreamChat.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@
629629
8274A7962B7FAC3900D8696B /* ChannelListScrollTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8274A7952B7FAC3900D8696B /* ChannelListScrollTime.swift */; };
630630
8279706F29689680006741A3 /* UserDetails_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8279706E29689680006741A3 /* UserDetails_Tests.swift */; };
631631
827DD1A0289D5B3300910AC5 /* MessageActionsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 827DD19F289D5B3300910AC5 /* MessageActionsVC.swift */; };
632+
82865DA42EC4B87B007D7053 /* Backend_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82865DA32EC4B874007D7053 /* Backend_Tests.swift */; };
632633
8292D6DB29B78476007A17D1 /* QuotedReply_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8292D6DA29B78476007A17D1 /* QuotedReply_Tests.swift */; };
633634
829762E028C7587500B953E8 /* PushNotification_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 829762DF28C7587500B953E8 /* PushNotification_Tests.swift */; };
634635
829CD5C52848C2EA003C3877 /* ParticipantRobot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 829CD5C32848C25F003C3877 /* ParticipantRobot.swift */; };
@@ -3691,6 +3692,8 @@
36913692
8274A7952B7FAC3900D8696B /* ChannelListScrollTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelListScrollTime.swift; sourceTree = "<group>"; };
36923693
8279706E29689680006741A3 /* UserDetails_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetails_Tests.swift; sourceTree = "<group>"; };
36933694
827DD19F289D5B3300910AC5 /* MessageActionsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActionsVC.swift; sourceTree = "<group>"; };
3695+
82865DA12EC4B84F007D7053 /* Backend.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = Backend.xctestplan; path = StreamChatUITestsAppUITests/Backend.xctestplan; sourceTree = "<group>"; };
3696+
82865DA32EC4B874007D7053 /* Backend_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Backend_Tests.swift; sourceTree = "<group>"; };
36943697
8292D6DA29B78476007A17D1 /* QuotedReply_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuotedReply_Tests.swift; sourceTree = "<group>"; };
36953698
829762DF28C7587500B953E8 /* PushNotification_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushNotification_Tests.swift; sourceTree = "<group>"; };
36963699
8298C8E827D22C3E004082D3 /* UserRobot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserRobot.swift; sourceTree = "<group>"; };
@@ -6312,6 +6315,14 @@
63126315
path = Swifter;
63136316
sourceTree = "<group>";
63146317
};
6318+
82865DA22EC4B86A007D7053 /* Backend */ = {
6319+
isa = PBXGroup;
6320+
children = (
6321+
82865DA32EC4B874007D7053 /* Backend_Tests.swift */,
6322+
);
6323+
path = Backend;
6324+
sourceTree = "<group>";
6325+
};
63156326
829CD5C22848C244003C3877 /* Robots */ = {
63166327
isa = PBXGroup;
63176328
children = (
@@ -6370,6 +6381,7 @@
63706381
82AD02BE27D8E453000611B7 /* Tests */ = {
63716382
isa = PBXGroup;
63726383
children = (
6384+
82865DA22EC4B86A007D7053 /* Backend */,
63736385
82EBA1822B30A63800B3A048 /* Performance */,
63746386
A3600B3D283F63C700E1C930 /* Base TestCase */,
63756387
A3B78F16282A670600348AD1 /* Message Delivery Status */,
@@ -6843,6 +6855,7 @@
68436855
8AD5EC8522E9A3E8005CFAC9 = {
68446856
isa = PBXGroup;
68456857
children = (
6858+
82865DA12EC4B84F007D7053 /* Backend.xctestplan */,
68466859
4A4E184528D06CA30062378D /* Documentation.docc */,
68476860
AD9BE32526680E4200A6D284 /* Stream.playground */,
68486861
792E3D6A25C97D920040B0C2 /* Package.swift */,
@@ -12534,6 +12547,7 @@
1253412547
8232B84F28635C4A0032C7DB /* Attachments_Tests.swift in Sources */,
1253512548
822F266027D9FDB500E454FB /* URLProtocol_Mock.swift in Sources */,
1253612549
82BA52EF27E1EF7B00951B87 /* MessageList_Tests.swift in Sources */,
12550+
82865DA42EC4B87B007D7053 /* Backend_Tests.swift in Sources */,
1253712551
A33FA818282E559A00DC40E8 /* SlowMode_Tests.swift in Sources */,
1253812552
A39B040B27F196F200D6B18A /* StreamChatUITests.swift in Sources */,
1253912553
825A32CF27DBB48D000402A9 /* StartPage.swift in Sources */,

StreamChat.xcodeproj/xcshareddata/xcschemes/StreamChatUITestsApp.xcscheme

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<TestPlanReference
3636
reference = "container:StreamChatUITestsAppUITests/Performance.xctestplan">
3737
</TestPlanReference>
38+
<TestPlanReference
39+
reference = "container:StreamChatUITestsAppUITests/Backend.xctestplan">
40+
</TestPlanReference>
3841
</TestPlans>
3942
<Testables>
4043
<TestableReference
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "2125E461-58C7-480E-9DB9-4CF3B51D3C5C",
5+
"name" : "Configuration 1",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
13+
},
14+
"testTargets" : [
15+
{
16+
"selectedTests" : [
17+
"Backend_Tests\/test_message()",
18+
"Backend_Tests\/test_reaction()"
19+
],
20+
"target" : {
21+
"containerPath" : "container:StreamChat.xcodeproj",
22+
"identifier" : "A34407DB27D8C3400044F150",
23+
"name" : "StreamChatUITestsAppUITests"
24+
}
25+
}
26+
],
27+
"version" : 1
28+
}

StreamChatUITestsAppUITests/StreamChatUITestsApp.xctestplan

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"testTargets" : [
2121
{
2222
"skippedTests" : [
23+
"Backend_Tests",
2324
"ChannelListScrollTime",
2425
"MessageListScrollTime"
2526
],
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// Copyright © 2025 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import XCTest
6+
7+
final class Backend_Tests: StreamTestCase {
8+
override func setUpWithError() throws {
9+
mockServerEnabled = false
10+
switchApiKey = "8br4watad788"
11+
try super.setUpWithError()
12+
}
13+
14+
func test_message() {
15+
let originalMessage = "hi"
16+
let editedMessage = "hello"
17+
18+
GIVEN("user opens the channel") {
19+
userRobot
20+
.login()
21+
.openChannel()
22+
}
23+
WHEN("user sends a message") {
24+
userRobot.sendMessage(originalMessage)
25+
}
26+
THEN("message appears") {
27+
userRobot.assertMessage(originalMessage)
28+
}
29+
WHEN("user edits the message") {
30+
userRobot.editMessage(editedMessage)
31+
}
32+
THEN("the message is edited") {
33+
userRobot.assertMessage(editedMessage)
34+
}
35+
WHEN("user deletes the message") {
36+
userRobot.deleteMessage()
37+
}
38+
THEN("the message is deleted") {
39+
userRobot.assertDeletedMessage()
40+
}
41+
}
42+
43+
func test_reaction() throws {
44+
let message = "test"
45+
46+
GIVEN("user opens the channel") {
47+
userRobot.login().openChannel()
48+
}
49+
WHEN("user sends the message: '\(message)'") {
50+
userRobot.sendMessage(message)
51+
}
52+
AND("user adds the reaction") {
53+
userRobot
54+
.addReaction(type: .like)
55+
.waitForNewReaction()
56+
}
57+
THEN("the reaction is added") {
58+
userRobot.assertReaction(isPresent: true)
59+
}
60+
AND("user removes the reaction") {
61+
userRobot.deleteReaction(type: .like)
62+
}
63+
THEN("the reaction is removed") {
64+
userRobot.assertReaction(isPresent: false)
65+
}
66+
}
67+
}

fastlane/Fastfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,32 @@ private_lane :xcmetrics_log_parser do |options|
538538
metrics
539539
end
540540

541+
desc 'Runs e2e ui tests using real backend server in Debug config'
542+
lane :test_e2e do |options|
543+
scan_options = {
544+
project: xcode_project,
545+
scheme: 'StreamChatUITestsApp',
546+
testplan: 'Backend',
547+
result_bundle: true,
548+
derived_data_path: derived_data_path,
549+
cloned_source_packages_path: source_packages_path,
550+
clean: is_localhost,
551+
test_without_building: options[:test_without_building],
552+
xcargs: buildcache_xcargs,
553+
devices: options[:device],
554+
prelaunch_simulator: is_ci,
555+
number_of_retries: 3
556+
}
557+
558+
begin
559+
scan(scan_options)
560+
rescue StandardError
561+
failed_tests = retreive_failed_tests
562+
UI.important("Re-running #{failed_tests.size} failed tests ⌛️")
563+
scan(scan_options.merge(only_testing: failed_tests))
564+
end
565+
end
566+
541567
desc 'Runs e2e ui tests using mock server in Debug config'
542568
lane :test_e2e_mock do |options|
543569
next unless is_check_required(sources: sources_matrix[:e2e], force_check: @force_check)

0 commit comments

Comments
 (0)