Skip to content
Merged
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
63 changes: 38 additions & 25 deletions test/features/recovery/querya_startup_recovery_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,43 @@ void main() {
expect(find.text('Start in Safe Mode'), findsOneWidget);
});

testWidgets('retry callback triggers when database can be opened',
(tester) async {
var retried = false;

// Ensure clean db can be opened
await LocalDb.instance.close();
final dbPath = await LocalDb.instance.databasePath();
final dbFile = File(dbPath);
if (await dbFile.exists()) await dbFile.delete();

await tester.pumpWidget(
QueryaStartupRecoveryApp(
error: 'Transient startup lock error',
onRetrySuccess: () {
retried = true;
},
),
);
await tester.pumpAndSettle();

await tester.tap(find.text('Retry Opening'));
await tester.pumpAndSettle();

expect(retried, isTrue);
});
// testWidgets runs in FakeAsync: real file/SQLite I/O only completes inside
// tester.runAsync, otherwise the test hangs until the 10 minute timeout.
testWidgets(
'retry callback triggers when database can be opened',
(tester) async {
var retried = false;

// Ensure clean db can be opened
await tester.runAsync(() async {
await LocalDb.instance.close();
final dbPath = await LocalDb.instance.databasePath();
final dbFile = File(dbPath);
if (await dbFile.exists()) await dbFile.delete();
});

await tester.pumpWidget(
QueryaStartupRecoveryApp(
error: 'Transient startup lock error',
onRetrySuccess: () {
retried = true;
},
),
);
await tester.pumpAndSettle();

await tester.tap(find.text('Retry Opening'));
await tester.runAsync(() async {
final deadline = DateTime.now().add(const Duration(seconds: 10));
while (!retried && DateTime.now().isBefore(deadline)) {
await Future<void>.delayed(const Duration(milliseconds: 20));
}
});
await tester.pump();

expect(retried, isTrue);
},
timeout: const Timeout(Duration(seconds: 30)),
);
});
}
Loading