import 'package:flutter_test/flutter_test.dart'; import 'package:halkyon_learn_flutter/src/feature/about/bloc/about_bloc.dart'; import 'package:halkyon_learn_flutter/src/feature/about/data/about_repository.dart'; import 'package:material_ui/material_ui.dart'; import '../../support/fake_about_gateway.dart'; import '../../support/pump_app.dart'; import '../../support/test_dependencies.dart'; void main() { group('AboutBloc', () { test('finds where the instance says its source is', () async { final bloc = AboutBloc(AboutRepository(FakeAboutGateway())) ..add(const AboutEventStarted()); addTearDown(bloc.close); await expectLater( bloc.stream, emits(const AboutStateLoaded('https://example.org/halkyon-learn')), ); }); test('says so when the instance cannot be reached', () async { final gateway = FakeAboutGateway() ..unreachable = Exception('No connection'); final bloc = AboutBloc(AboutRepository(gateway)) ..add(const AboutEventStarted()); addTearDown(bloc.close); await expectLater(bloc.stream, emits(const AboutStateUnreachable())); }); }); testWidgets('profile → settings → about shows the licences and the source', ( tester, ) async { await pumpApp(tester, testDependencies()); await openTab(tester, 'Profile'); await tester.tap(find.byTooltip('Settings')); await tester.pumpAndSettle(); await tester.scrollUntilVisible( find.text('About Halkyon Learn'), 200, // The citation preview is selectable, a scroll view of its own. scrollable: find.byType(Scrollable).first, ); await tester.pumpAndSettle(); await tester.tap(find.text('About Halkyon Learn')); await tester.pumpAndSettle(); expect( find.textContaining('GNU Affero General Public License'), findsOneWidget, ); expect(find.text('https://example.org/halkyon-learn'), findsOneWidget); expect(find.text('View licenses'), findsOneWidget); }); }