import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:ot_movil/screens/work_order_screen.dart'; import 'package:ot_movil/services/pdf_service.dart'; void main() { testWidgets('el diálogo de correo se desmonta sin errores', (tester) async { String? selectedEmail; await tester.pumpWidget( MaterialApp( home: Scaffold( body: Builder( builder: (context) => FilledButton( onPressed: () async { selectedEmail = await showDialog( context: context, builder: (_) => const EmailRecipientDialog(), ); }, child: const Text('Abrir'), ), ), ), ), ); await tester.tap(find.text('Abrir')); await tester.pumpAndSettle(); await tester.enterText(find.byType(TextFormField), 'tecnico@empresa.cl'); await tester.tap(find.text('Continuar')); await tester.pumpAndSettle(); expect(selectedEmail, 'tecnico@empresa.cl'); expect(find.byType(EmailRecipientDialog), findsNothing); expect(tester.takeException(), isNull); }); testWidgets('permite elegir el informe para empresa certificadora', ( tester, ) async { PdfReportType? selectedType; await tester.pumpWidget( MaterialApp( home: Scaffold( body: Builder( builder: (context) => FilledButton( onPressed: () async { selectedType = await showDialog( context: context, builder: (_) => const PdfReportTypeDialog(), ); }, child: const Text('Abrir'), ), ), ), ), ); await tester.tap(find.text('Abrir')); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('report-type-certificadora'))); await tester.pumpAndSettle(); expect(selectedType, PdfReportType.certifier); expect(find.byType(PdfReportTypeDialog), findsNothing); }); }