import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hl_lieferservice/feature/delivery/detail/presentation/widget/internal_note_sheet.dart'; void main() { late InternalNoteDecision? result; late bool closed; Future open(WidgetTester tester) async { result = null; closed = false; await tester.pumpWidget( MaterialApp( home: Builder( builder: (context) => Scaffold( body: TextButton( onPressed: () async { result = await showInternalNoteSheet(context); closed = true; }, child: const Text('open'), ), ), ), ), ); await tester.tap(find.text('open')); await tester.pumpAndSettle(); } testWidgets('ohne Eingabe: ein Tipp schließt ohne Notiz ab', (tester) async { await open(tester); await tester.tap(find.text('Ohne Notiz abschließen')); await tester.pumpAndSettle(); expect(closed, isTrue); expect(result, isNotNull); expect(result!.note, isNull); }); testWidgets('mit Eingabe: Button wechselt, Text wird getrimmt', (tester) async { await open(tester); await tester.enterText(find.byType(TextField), ' Rückruf wegen Montage '); await tester.pump(); expect(find.text('Mit Notiz abschließen'), findsOneWidget); await tester.tap(find.text('Mit Notiz abschließen')); await tester.pumpAndSettle(); expect(result!.note, 'Rückruf wegen Montage'); }); testWidgets('Zurück bricht das Abschließen ab', (tester) async { await open(tester); await tester.tap(find.text('Zurück zur Unterschrift')); await tester.pumpAndSettle(); expect(closed, isTrue); expect(result, isNull); }); }