only-bible-app v3.7.2+24

#kotlin#android#ios

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
// Integration-style tests driving verse selection and highlighting through
// real taps on the rendered Home screen and MenuOverlay, rather than
// dispatching SelectVerseAction/SetHighlightAction/RemoveHighlightAction
// directly against a bare store. Tapping through the actual widgets is what
// verifies the UI wiring (GestureDetector -> action, MenuOverlay appearing
// only while verses are selected, etc.) alongside the reducer logic itself.
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
import "package:async_redux/async_redux.dart";
import "package:only_bible_app/app.dart";
import "package:only_bible_app/store/app_state.dart";
import "package:only_bible_app/widgets/highlight_button.dart";
import "package:only_bible_app/widgets/menu_overlay.dart";
import "app_logic_test.dart" show buildTestBible;

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();

  testWidgets(
    "tapping a verse selects it and shows the menu overlay; tapping a highlight color "
    "applies it and clears the selection; tapping remove clears the highlight",
    (tester) async {
      final bible = buildTestBible();
      final store = Store<AppState>(
        initialState: AppState(bible: bible, savedBook: 0, savedChapter: 0),
      );
      await tester.pumpWidget(
        App(globalNavigatorKey: GlobalKey<NavigatorState>(), store: store),
      );
      await tester.pumpAndSettle();

      // No selection yet - the overlay shouldn't be showing.
      expect(find.byType(MenuOverlay), findsNothing);

      // Tap the first verse ("In the beginning...") to select it.
      await tester.tap(find.textContaining("In the beginning..."));
      await tester.pumpAndSettle();

      expect(store.state.selectedVerses, hasLength(1));
      expect(store.state.selectedVerses.single.index, 0);
      expect(find.byType(MenuOverlay), findsOneWidget);

      // Tap the first highlight color in the now-visible overlay.
      await tester.tap(find.byType(HighlightButton).first);
      await tester.pumpAndSettle();

      expect(store.state.highlights["0:0:0"], 0);
      // Applying a highlight clears the selection, so the overlay goes away.
      expect(store.state.selectedVerses, isEmpty);
      expect(find.byType(MenuOverlay), findsNothing);

      // Select the now-highlighted verse again and remove its highlight.
      await tester.tap(find.textContaining("In the beginning..."));
      await tester.pumpAndSettle();
      expect(find.byType(MenuOverlay), findsOneWidget);

      await tester.tap(find.byIcon(Icons.cancel_outlined));
      await tester.pumpAndSettle();

      expect(store.state.highlights.containsKey("0:0:0"), isFalse);
      expect(store.state.selectedVerses, isEmpty);
      expect(find.byType(MenuOverlay), findsNothing);
    },
  );
}