import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:provider/provider.dart'; import 'package:lanebow/screens/club/participant_form_screen.dart'; import 'package:lanebow/services/event_service.dart'; void main() { group('ParticipantFormScreen - Guest Prefill BottomSheet', () { Widget _buildApp() => MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => EventService()), ], child: const MaterialApp( home: Scaffold( body: ParticipantFormScreen(eventId: 'test_event'), ), ), ); testWidgets('opens bottom sheet and applies filled values', (tester) async { await tester.pumpWidget(_buildApp()); await tester.pumpAndSettle(); // 사전입력 버튼 노출 expect(find.text('게스트 사전입력'), findsOneWidget); // 버튼 탭으로 BottomSheet 오픈 await tester.tap(find.text('게스트 사전입력')); await tester.pumpAndSettle(); // 필드 입력 await tester.enterText(find.byType(TextField).at(0), '홍길동'); await tester.enterText(find.byType(TextField).at(1), 'hong@test.com'); await tester.enterText(find.byType(TextField).at(2), '01012345678'); // 적용 await tester.tap(find.text('적용')); await tester.pumpAndSettle(); // 폼 필드에 값 반영 확인 expect(find.widgetWithText(TextFormField, '홍길동'), findsOneWidget); expect(find.widgetWithText(TextFormField, 'hong@test.com'), findsOneWidget); expect(find.widgetWithText(TextFormField, '01012345678'), findsOneWidget); }); testWidgets('shows warning when name is empty', (tester) async { await tester.pumpWidget(_buildApp()); await tester.pumpAndSettle(); await tester.tap(find.text('게스트 사전입력')); await tester.pumpAndSettle(); // 이름 비우고 적용 await tester.enterText(find.byType(TextField).at(0), ''); await tester.tap(find.text('적용')); await tester.pump(); expect(find.text('이름은 필수 입력 항목입니다'), findsOneWidget); }); }); }