forked from immich-app/immich
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(mobile): add login integration tests and reorganize CI definiti…
…ons (immich-app#1417) * Add integration tests for the login process * Reorganize tests * Test wrong instance URL * Run mobile unit tests in CI * Fix CI * Pin Flutter Version to 3.3.10 * Push something stupid to re-trigger CI
- Loading branch information
Showing
8 changed files
with
212 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,56 @@ jobs: | |
|
||
- name: Run tests | ||
run: cd web && npm ci && npm run check:all | ||
|
||
mobile-unit-tests: | ||
name: Run mobile unit tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Flutter SDK | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: 'stable' | ||
flutter-version: '3.3.10' | ||
- name: Run tests | ||
working-directory: ./mobile | ||
run: flutter test | ||
|
||
mobile-integration-tests: | ||
name: Run mobile end-to-end integration tests | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
- name: Cache android SDK | ||
uses: actions/cache@v3 | ||
id: android-sdk | ||
with: | ||
key: android-sdk | ||
path: | | ||
/usr/local/lib/android/ | ||
~/.android | ||
- name: Setup Android SDK | ||
if: steps.android-sdk.outputs.cache-hit != 'true' | ||
uses: android-actions/setup-android@v2 | ||
- name: Setup Flutter SDK | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: 'stable' | ||
flutter-version: '3.3.10' | ||
- name: Run integration tests | ||
uses: reactivecircus/[email protected] | ||
with: | ||
working-directory: ./mobile | ||
api-level: 29 | ||
arch: x86_64 | ||
profile: pixel | ||
target: default | ||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim | ||
disable-linux-hw-accel: false | ||
script: | | ||
flutter pub get | ||
flutter test integration_test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,19 @@ void main() async { | |
await ImmichTestHelper.initialize(); | ||
|
||
group("Login input validation test", () { | ||
immichWidgetTest("Test leading/trailing whitespace", (tester) async { | ||
await ImmichTestLoginHelper.waitForLoginScreen(tester); | ||
await ImmichTestLoginHelper.acknowledgeNewServerVersion(tester); | ||
immichWidgetTest("Test leading/trailing whitespace", (tester, helper) async { | ||
await helper.loginHelper.waitForLoginScreen(); | ||
await helper.loginHelper.acknowledgeNewServerVersion(); | ||
|
||
await ImmichTestLoginHelper.enterLoginCredentials( | ||
tester, | ||
await helper.loginHelper.enterCredentials( | ||
email: " [email protected]" | ||
); | ||
|
||
await tester.pump(const Duration(milliseconds: 300)); | ||
|
||
expect(find.text("login_form_err_leading_whitespace".tr()), findsOneWidget); | ||
|
||
await ImmichTestLoginHelper.enterLoginCredentials( | ||
tester, | ||
await helper.loginHelper.enterCredentials( | ||
email: "[email protected] " | ||
); | ||
|
||
|
@@ -31,12 +29,11 @@ void main() async { | |
expect(find.text("login_form_err_trailing_whitespace".tr()), findsOneWidget); | ||
}); | ||
|
||
immichWidgetTest("Test invalid email", (tester) async { | ||
await ImmichTestLoginHelper.waitForLoginScreen(tester); | ||
await ImmichTestLoginHelper.acknowledgeNewServerVersion(tester); | ||
immichWidgetTest("Test invalid email", (tester, helper) async { | ||
await helper.loginHelper.waitForLoginScreen(); | ||
await helper.loginHelper.acknowledgeNewServerVersion(); | ||
|
||
await ImmichTestLoginHelper.enterLoginCredentials( | ||
tester, | ||
await helper.loginHelper.enterCredentials( | ||
email: "demo.immich.app" | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../test_utils/general_helper.dart'; | ||
import '../test_utils/login_helper.dart'; | ||
|
||
void main() async { | ||
await ImmichTestHelper.initialize(); | ||
|
||
group("Login tests", () { | ||
immichWidgetTest("Test correct credentials", (tester, helper) async { | ||
await helper.loginHelper.waitForLoginScreen(); | ||
await helper.loginHelper.acknowledgeNewServerVersion(); | ||
await helper.loginHelper | ||
.enterCredentialsOf(LoginCredentials.testInstance); | ||
await helper.loginHelper.pressLoginButton(); | ||
await helper.loginHelper.assertLoginSuccess(); | ||
}); | ||
|
||
immichWidgetTest("Test login with wrong password", (tester, helper) async { | ||
await helper.loginHelper.waitForLoginScreen(); | ||
await helper.loginHelper.acknowledgeNewServerVersion(); | ||
await helper.loginHelper.enterCredentialsOf( | ||
LoginCredentials.testInstanceButWithWrongPassword); | ||
await helper.loginHelper.pressLoginButton(); | ||
await helper.loginHelper.assertLoginFailed(); | ||
}); | ||
|
||
immichWidgetTest("Test login with wrong server URL", (tester, helper) async { | ||
await helper.loginHelper.waitForLoginScreen(); | ||
await helper.loginHelper.acknowledgeNewServerVersion(); | ||
await helper.loginHelper.enterCredentialsOf( | ||
LoginCredentials.wrongInstanceUrl); | ||
await helper.loginHelper.pressLoginButton(); | ||
await helper.loginHelper.assertLoginFailed(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import 'dart:async'; | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart'; | ||
|
||
class ImmichTestLoginHelper { | ||
static Future<void> waitForLoginScreen(WidgetTester tester, | ||
{int timeoutSeconds = 20}) async { | ||
final WidgetTester tester; | ||
|
||
ImmichTestLoginHelper(this.tester); | ||
|
||
Future<void> waitForLoginScreen({int timeoutSeconds = 20}) async { | ||
for (var i = 0; i < timeoutSeconds; i++) { | ||
// Search for "IMMICH" test in the app bar | ||
final result = find.text("IMMICH"); | ||
|
@@ -21,7 +26,7 @@ class ImmichTestLoginHelper { | |
fail("Timeout while waiting for login screen"); | ||
} | ||
|
||
static Future<bool> acknowledgeNewServerVersion(WidgetTester tester) async { | ||
Future<bool> acknowledgeNewServerVersion() async { | ||
final result = find.text("Acknowledge"); | ||
if (!tester.any(result)) { | ||
return false; | ||
|
@@ -33,8 +38,7 @@ class ImmichTestLoginHelper { | |
return true; | ||
} | ||
|
||
static Future<void> enterLoginCredentials( | ||
WidgetTester tester, { | ||
Future<void> enterCredentials({ | ||
String server = "", | ||
String email = "", | ||
String password = "", | ||
|
@@ -50,6 +54,70 @@ class ImmichTestLoginHelper { | |
await tester.pump(const Duration(milliseconds: 500)); | ||
await tester.enterText(loginForms.at(2), server); | ||
|
||
await tester.pump(const Duration(milliseconds: 500)); | ||
await tester.testTextInput.receiveAction(TextInputAction.done); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
Future<void> enterCredentialsOf(LoginCredentials credentials) async { | ||
await enterCredentials( | ||
server: credentials.server, | ||
email: credentials.email, | ||
password: credentials.password, | ||
); | ||
} | ||
|
||
Future<void> pressLoginButton() async { | ||
final button = find.textContaining("login_form_button_text".tr()); | ||
await tester.tap(button); | ||
} | ||
|
||
Future<void> assertLoginSuccess({int timeoutSeconds = 15}) async { | ||
for (var i = 0; i < timeoutSeconds * 2; i++) { | ||
if (tester.any(find.text("home_page_building_timeline".tr()))) { | ||
return; | ||
} | ||
|
||
await tester.pump(const Duration(milliseconds: 500)); | ||
} | ||
|
||
fail("Login failed."); | ||
} | ||
|
||
Future<void> assertLoginFailed({int timeoutSeconds = 15}) async { | ||
for (var i = 0; i < timeoutSeconds * 2; i++) { | ||
if (tester.any(find.text("login_form_failed_login".tr()))) { | ||
return; | ||
} | ||
|
||
await tester.pump(const Duration(milliseconds: 500)); | ||
} | ||
|
||
fail("Timeout."); | ||
} | ||
} | ||
|
||
enum LoginCredentials { | ||
testInstance( | ||
"https://flutter-int-test.preview.immich.app", | ||
"[email protected]", | ||
"demo", | ||
), | ||
|
||
testInstanceButWithWrongPassword( | ||
"https://flutter-int-test.preview.immich.app", | ||
"[email protected]", | ||
"wrong", | ||
), | ||
|
||
wrongInstanceUrl( | ||
"https://does-not-exist.preview.immich.app", | ||
"[email protected]", | ||
"demo", | ||
); | ||
|
||
const LoginCredentials(this.server, this.email, this.password); | ||
|
||
final String server; | ||
final String email; | ||
final String password; | ||
} |
Oops, something went wrong.