only-bible-app v3.7.2+24
git clone https://git.pyrossh.dev/only-bible-app
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
test/verse_selection_integration_test.dart
| 64b2ff0 | 1 | // Integration-style tests driving verse selection and highlighting through |
| 64b2ff0 | 2 | // real taps on the rendered Home screen and MenuOverlay, rather than |
| 64b2ff0 | 3 | // dispatching SelectVerseAction/SetHighlightAction/RemoveHighlightAction |
| 64b2ff0 | 4 | // directly against a bare store. Tapping through the actual widgets is what |
| 64b2ff0 | 5 | // verifies the UI wiring (GestureDetector -> action, MenuOverlay appearing |
| 64b2ff0 | 6 | // only while verses are selected, etc.) alongside the reducer logic itself. |
| 64b2ff0 | 7 | import "package:flutter/material.dart"; |
| 64b2ff0 | 8 | import "package:flutter_test/flutter_test.dart"; |
| 64b2ff0 | 9 | import "package:async_redux/async_redux.dart"; |
| 64b2ff0 | 10 | import "package:only_bible_app/app.dart"; |
| 64b2ff0 | 11 | import "package:only_bible_app/store/app_state.dart"; |
| 64b2ff0 | 12 | import "package:only_bible_app/widgets/highlight_button.dart"; |
| 64b2ff0 | 13 | import "package:only_bible_app/widgets/menu_overlay.dart"; |
| 64b2ff0 | 14 | import "app_logic_test.dart" show buildTestBible; |
| 64b2ff0 | 15 | |
| 64b2ff0 | 16 | void main() { |
| 64b2ff0 | 17 | TestWidgetsFlutterBinding.ensureInitialized(); |
| 64b2ff0 | 18 | |
| 64b2ff0 | 19 | testWidgets( |
| 64b2ff0 | 20 | "tapping a verse selects it and shows the menu overlay; tapping a highlight color " |
| 64b2ff0 | 21 | "applies it and clears the selection; tapping remove clears the highlight", |
| 64b2ff0 | 22 | (tester) async { |
| 64b2ff0 | 23 | final bible = buildTestBible(); |
| 64b2ff0 | 24 | final store = Store<AppState>( |
| 64b2ff0 | 25 | initialState: AppState(bible: bible, savedBook: 0, savedChapter: 0), |
| 64b2ff0 | 26 | ); |
| 64b2ff0 | 27 | await tester.pumpWidget( |
| 64b2ff0 | 28 | App(globalNavigatorKey: GlobalKey<NavigatorState>(), store: store), |
| 64b2ff0 | 29 | ); |
| 64b2ff0 | 30 | await tester.pumpAndSettle(); |
| 64b2ff0 | 31 | |
| 64b2ff0 | 32 | // No selection yet - the overlay shouldn't be showing. |
| 64b2ff0 | 33 | expect(find.byType(MenuOverlay), findsNothing); |
| 64b2ff0 | 34 | |
| 64b2ff0 | 35 | // Tap the first verse ("In the beginning...") to select it. |
| 64b2ff0 | 36 | await tester.tap(find.textContaining("In the beginning...")); |
| 64b2ff0 | 37 | await tester.pumpAndSettle(); |
| 64b2ff0 | 38 | |
| 64b2ff0 | 39 | expect(store.state.selectedVerses, hasLength(1)); |
| 64b2ff0 | 40 | expect(store.state.selectedVerses.single.index, 0); |
| 64b2ff0 | 41 | expect(find.byType(MenuOverlay), findsOneWidget); |
| 64b2ff0 | 42 | |
| 64b2ff0 | 43 | // Tap the first highlight color in the now-visible overlay. |
| 64b2ff0 | 44 | await tester.tap(find.byType(HighlightButton).first); |
| 64b2ff0 | 45 | await tester.pumpAndSettle(); |
| 64b2ff0 | 46 | |
| 64b2ff0 | 47 | expect(store.state.highlights["0:0:0"], 0); |
| 64b2ff0 | 48 | // Applying a highlight clears the selection, so the overlay goes away. |
| 64b2ff0 | 49 | expect(store.state.selectedVerses, isEmpty); |
| 64b2ff0 | 50 | expect(find.byType(MenuOverlay), findsNothing); |
| 64b2ff0 | 51 | |
| 64b2ff0 | 52 | // Select the now-highlighted verse again and remove its highlight. |
| 64b2ff0 | 53 | await tester.tap(find.textContaining("In the beginning...")); |
| 64b2ff0 | 54 | await tester.pumpAndSettle(); |
| 64b2ff0 | 55 | expect(find.byType(MenuOverlay), findsOneWidget); |
| 64b2ff0 | 56 | |
| 64b2ff0 | 57 | await tester.tap(find.byIcon(Icons.cancel_outlined)); |
| 64b2ff0 | 58 | await tester.pumpAndSettle(); |
| 64b2ff0 | 59 | |
| 64b2ff0 | 60 | expect(store.state.highlights.containsKey("0:0:0"), isFalse); |
| 64b2ff0 | 61 | expect(store.state.selectedVerses, isEmpty); |
| 64b2ff0 | 62 | expect(find.byType(MenuOverlay), findsNothing); |
| 64b2ff0 | 63 | }, |
| 64b2ff0 | 64 | ); |
| 64b2ff0 | 65 | } |