mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(mobile): add login integration tests and reorganize CI definitions (#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
This commit is contained in:
parent
d1db47ee34
commit
f64db3a2f9
8 changed files with 212 additions and 76 deletions
|
|
@ -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",
|
||||
"demo@immich.app",
|
||||
"demo",
|
||||
),
|
||||
|
||||
testInstanceButWithWrongPassword(
|
||||
"https://flutter-int-test.preview.immich.app",
|
||||
"demo@immich.app",
|
||||
"wrong",
|
||||
),
|
||||
|
||||
wrongInstanceUrl(
|
||||
"https://does-not-exist.preview.immich.app",
|
||||
"demo@immich.app",
|
||||
"demo",
|
||||
);
|
||||
|
||||
const LoginCredentials(this.server, this.email, this.password);
|
||||
|
||||
final String server;
|
||||
final String email;
|
||||
final String password;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue