tane/apps/app_seeds/test/ui/legal_screen_test.dart

50 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/i18n/strings.g.dart';
import 'package:tane/ui/legal_screen.dart';
void main() {
Widget app() => TranslationProvider(
child: const MaterialApp(
localizationsDelegates: GlobalMaterialLocalizations.delegates,
home: LegalScreen(),
),
);
testWidgets('shows the three summaries with their full-text links', (
tester,
) async {
LocaleSettings.setLocaleSync(AppLocale.en);
await tester.pumpWidget(app());
await tester.pump();
expect(find.text('Your privacy'), findsOneWidget);
// No account, no tracker, plain-words copy is on screen.
expect(find.textContaining('without an account'), findsOneWidget);
expect(find.text('Read the full documents online'), findsWidgets);
// The later sections start below the fold of the test viewport.
await tester.scrollUntilVisible(find.text('About sharing seeds'), 300);
expect(find.text('Rules of the road'), findsOneWidget);
expect(find.text('About sharing seeds'), findsOneWidget);
});
testWidgets('renders under RTL without overflowing', (tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
await tester.pumpWidget(
TranslationProvider(
child: const MaterialApp(
localizationsDelegates: GlobalMaterialLocalizations.delegates,
home: Directionality(
textDirection: TextDirection.rtl,
child: LegalScreen(),
),
),
),
);
await tester.pump();
expect(tester.takeException(), isNull);
expect(find.byType(LegalScreen), findsOneWidget);
});
}