test(app): fix integration test and improve reliability and speed (#1792)

This commit is contained in:
Zack Pollard 2023-02-19 17:50:36 +00:00 committed by GitHub
parent 5ad4e5b614
commit 78a5fe2d37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 54 deletions

View file

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hive/hive.dart';
@ -43,7 +45,6 @@ class ImmichTestHelper {
// Load main Widget
await tester.pumpWidget(app.getMainWidget(db));
// Post run tasks
await tester.pumpAndSettle();
await EasyLocalization.ensureInitialized();
}
}
@ -62,3 +63,17 @@ void immichWidgetTest(
semanticsEnabled: false,
);
}
Future<void> pumpUntilFound(
WidgetTester tester,
Finder finder, {
Duration timeout = const Duration(seconds: 120),
}) async {
bool found = false;
final timer = Timer(timeout, () => throw TimeoutException("Pump until has timed out"));
while (found != true) {
await tester.pump();
found = tester.any(finder);
}
timer.cancel();
}