forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_loading_sliver_test.dart
More file actions
47 lines (37 loc) · 1.84 KB
/
Copy pathsearch_loading_sliver_test.dart
File metadata and controls
47 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:omi/pages/apps/widgets/search_loading_sliver.dart';
import 'package:omi/widgets/shimmer_with_timeout.dart';
/// The shimmer placeholders stop animating after [ShimmerWithTimeout]'s timeout
/// and fall back to static blocks. A search that takes longer than that is then
/// indistinguishable from a frozen screen, which is the bug these tests pin.
Future<void> _pumpLoadingState(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: CustomScrollView(slivers: [SearchLoadingSliver()])),
),
);
}
void main() {
group('search loading state', () {
testWidgets('shows placeholder rows while the search runs', (tester) async {
await _pumpLoadingState(tester);
expect(find.byType(ShimmerWithTimeout), findsNWidgets(5));
});
testWidgets('still shows a running progress indicator after the shimmer has timed out', (tester) async {
await _pumpLoadingState(tester);
// Past ShimmerWithTimeout's 5s fallback, where the placeholders go static.
await tester.pump(const Duration(seconds: 10));
// The user must still be able to tell the search is running rather than wedged.
expect(find.byType(LinearProgressIndicator), findsOneWidget);
});
testWidgets('the progress indicator is indeterminate, because search has no known duration', (tester) async {
await _pumpLoadingState(tester);
await tester.pump(const Duration(seconds: 10));
final indicator = tester.widget<LinearProgressIndicator>(find.byType(LinearProgressIndicator));
// A determinate bar would have to invent a percentage; a stuck one at a fixed
// value is exactly the "is it working?" doubt this is meant to remove.
expect(indicator.value, isNull);
});
});
}