Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github workflow to run tests #1372

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run automated tests

on:
pull_request:
branches:
- develop
- beta
- stable
push:
branches:
- develop

permissions: {}

jobs:
run_tests:
runs-on: macos-latest
name: Run automated tests
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Build rust
run: ./rust/build-rust.sh
- name: Install pods
working-directory: Monal
run: pod install --repo-update
- name: Run tests
working-directory: Monal
run: |
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-workspace Monal.xcworkspace \
-scheme Monal \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' \
test \
2>&1 | \
xcbeautify --renderer github-actions
12 changes: 9 additions & 3 deletions Monal/Monal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
C16D18342792A4AF00F869A0 /* DataLayerMigrations.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DataLayerMigrations.m; sourceTree = "<group>"; };
C176F1EB2AF11C31002034E5 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/UserNotifications.framework; sourceTree = DEVELOPER_DIR; };
C1850E6625F37EC0003D506A /* Monal Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Monal Tests-Bridging-Header.h"; sourceTree = "<group>"; };
C1850EB525F38A2D003D506A /* .xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = .xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C1850EB525F38A2D003D506A /* MonalUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MonalUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C1850EB725F38A2D003D506A /* MonalUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonalUITests.swift; sourceTree = "<group>"; };
C1850EB925F38A2D003D506A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C1850EC525F3C5EB003D506A /* TestHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHelper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -903,7 +903,7 @@
26AA70112146BBB800598605 /* shareSheet.appex */,
260773C0232FC4E800BFD50F /* NotificationService.appex */,
26CC579223A0867400ABB92A /* monalxmpp.framework */,
C1850EB525F38A2D003D506A /* .xctest */,
C1850EB525F38A2D003D506A /* MonalUITests.xctest */,
C1049186261301530054AC9E /* MonalXMPPUnitTests.xctest */,
);
name = Products;
Expand Down Expand Up @@ -1700,7 +1700,7 @@
);
name = MonalUITests;
productName = MonalUITests;
productReference = C1850EB525F38A2D003D506A /* .xctest */;
productReference = C1850EB525F38A2D003D506A /* MonalUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
Expand Down Expand Up @@ -3751,6 +3751,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand Down Expand Up @@ -4108,6 +4109,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand Down Expand Up @@ -4199,6 +4201,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand All @@ -4217,6 +4220,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand All @@ -4236,6 +4240,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand Down Expand Up @@ -4520,6 +4525,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_NAME = MonalUITests;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
TEST_TARGET_NAME = Monal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand All @@ -43,7 +43,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand All @@ -53,7 +53,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand All @@ -63,7 +63,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1850EB425F38A2D003D506A"
BuildableName = ".xctest"
BuildableName = "MonalUITests.xctest"
BlueprintName = "MonalUITests"
ReferencedContainer = "container:Monal.xcodeproj">
</BuildableReference>
Expand Down
117 changes: 1 addition & 116 deletions Monal/MonalUITests/MonalUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,6 @@ class MonalUITests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

private func intro(app: XCUIApplication)
{
// wait for launch
sleep(1)

let elementsQuery = app.scrollViews["intro_scroll"].otherElements
elementsQuery.buttons["Welcome to Monal, Chat for free with your friends, colleagues and family!"].swipeLeft()
sleep(1)
elementsQuery.buttons["Choices Galore, Use your existing account or make a new one on the many servers around the world"].swipeLeft()
sleep(1)
elementsQuery.buttons["Escape The Garden, You are not trapped in a garden. Talk to anyone else without anyone tracking you."].swipeLeft()
sleep(1)
elementsQuery.buttons["Spread The Word, If you like Monal, please let others know and leave a review"].swipeLeft()
sleep(1)
}

private func introSkip(app: XCUIApplication)
{
// wait for launch
sleep(1)
app.buttons["Skip"].tap()
sleep(1)
}

private func createStartArgs() -> [String]
{
return createStartArgs(extraArgs: [])
Expand Down Expand Up @@ -82,99 +58,8 @@ class MonalUITests: XCTestCase {
XCTAssertTrue(app.buttons["microphone"].exists)
}

func test_0001_DBInit() throws {
let app = XCUIApplication()
app.launchArguments = createStartArgs(extraArgs: ["--reset"])
app.launch()
}

func test_0002_Intro() throws
{
let app = XCUIApplication()
app.launchArguments = createStartArgs(extraArgs: ["--reset"])
app.launch()

intro(app: app)

let elementsQuery2 = app.scrollViews.otherElements
elementsQuery2.textFields["[email protected]"].tap()
elementsQuery2.secureTextFields["Password"].tap()
}

func test_0003_IntroSkip() throws
{
let app = XCUIApplication()
app.launchArguments = createStartArgs(extraArgs: ["--reset"])
app.launch()

introSkip(app: app)
app.scrollViews.otherElements.buttons["Set up an account later"].tap()

let chatsNavigationBar = app.navigationBars["Chats"]
chatsNavigationBar.buttons["Add"].tap()

let closeButton = app.alerts["No enabled account found"].scrollViews.otherElements.buttons["Close"]
closeButton.tap()
chatsNavigationBar.buttons["Compose"].tap()
closeButton.tap()
}

func test_0005_Register() throws
{
let app = XCUIApplication()
app.launchArguments = createStartArgs(extraArgs: ["--reset"])
app.launch()

introSkip(app: app)

let elementsQuery = app.scrollViews.otherElements
let registerStaticText = elementsQuery.buttons["Register"]
registerStaticText.tap()

app.scrollViews.otherElements.buttons["Terms of service"].tap()
// wait for safari window to open
sleep(5)
app.buttons["Done"].tap()
elementsQuery.textFields["Username"].tap()
// create random username
elementsQuery.textFields["Username"].typeText(String(format: "MonalTestclient-%d", Int.random(in: 1000..<999999)))

elementsQuery.secureTextFields["Password"].tap()
elementsQuery.secureTextFields["Password"].typeText(randomPassword())
registerStaticText.tap()
// wait for register hud
sleep(10)
let startChattingStaticText = app.buttons["Start Chatting"]
startChattingStaticText.tap()
sleep(1)
app.navigationBars["Privacy Settings"].buttons["Close"].tap()
startChattingStaticText.tap()
}

func test_0007_PlusAndContactsButtons() throws {
let app = XCUIApplication()
app.launchArguments = createStartArgs()
app.launch()

let chatsNavigationBar = app.navigationBars["Chats"]
sleep(1)
chatsNavigationBar.buttons["Add"].tap()

let tablesQuery = app.tables
tablesQuery.staticTexts["Add a New Contact"].tap()
app.navigationBars["Add Contact"].buttons["New"].tap()
tablesQuery.staticTexts["Join a Group Chat"].tap()
app.navigationBars["Join Group Chat"].buttons["New"].tap()
tablesQuery.staticTexts["View Contact Requests"].tap()
app.navigationBars["Contact Requests"].buttons["New"].tap()
app.navigationBars["New"].buttons["Close"].tap()
chatsNavigationBar.buttons["Compose"].tap()

let contactsNavigationBar = app.navigationBars["Contacts"]
contactsNavigationBar.buttons["Close"].tap()
}

func test_0008_AddContact() throws {
try XCTSkipIf(true, "This test is left as an example of UI tests. At some point in the future we should consider rewriting these.")
let app = XCUIApplication()
app.launchArguments = createStartArgs()
app.launch()
Expand Down
Empty file modified rust/build-rust.sh
100644 → 100755
Empty file.
Loading