import 'package:flutter_test/flutter_test.dart'; import 'package:halkyon_ui/halkyon_ui.dart'; import 'package:material_ui/material_ui.dart'; import '../support/test_app.dart'; void main() { /// Shows [child] on a screen, in German. Future show(WidgetTester tester, Widget child) => tester.pumpWidget( testApp(locale: const Locale('de'), Scaffold(body: child)), ); testWidgets("a required field says so in the app's language", ( tester, ) async { await show( tester, Builder( builder: (context) => TextField( decoration: requiredDecoration( context, const InputDecoration(labelText: 'Name'), missing: true, ), ), ), ); expect(find.text('Pflichtfeld'), findsOneWidget); }); testWidgets('a count stepper names its buttons', (tester) async { await show( tester, CountStepper(value: '5', onFewer: () {}, onMore: () {}, onTyped: (_) {}), ); expect(find.byTooltip('Verringern'), findsOneWidget); expect(find.byTooltip('Erhöhen'), findsOneWidget); expect(find.byTooltip('Zahl eingeben'), findsOneWidget); }); testWidgets('a reorderable row is dragged by its grip', (tester) async { await show( tester, CustomScrollView( slivers: [ SliverReorderableList( itemCount: 1, onReorderItem: (_, _) {}, itemBuilder: (context, index) => ListTile( key: const ValueKey('row'), title: const Text('Row'), trailing: ReorderGrip(index: index), ), ), ], ), ); expect(find.byTooltip('Zum Umsortieren ziehen'), findsOneWidget); }); testWidgets('More info names itself, and copies a value with a tap', ( tester, ) async { await show( tester, Builder( builder: (context) => TextButton( onPressed: () => showMoreInfoSheet(context, [ ( title: null, rows: [(label: 'ID', value: '0199a', copyable: true)], ), ]), child: const Text('Open'), ), ), ); await tester.tap(find.text('Open')); await tester.pumpAndSettle(); expect(find.text('Weitere Informationen'), findsOneWidget); await tester.tap(find.byTooltip('Kopieren')); await tester.pump(); expect(find.text('In die Zwischenablage kopiert'), findsOneWidget); }); testWidgets('the palette picker names its colour', (tester) async { await show( tester, PaletteColorPicker(selected: PaletteColor.copper, onChanged: (_) {}), ); expect(find.text('Kupfer'), findsOneWidget); expect(find.bySemanticsLabel('Farbe: Kupfer'), findsOneWidget); }); }