import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:lanebow/screens/public_event/public_event_screen.dart'; import 'package:lanebow/services/public_event_service.dart'; class StubTeamsService extends PublicEventService { @override Future> fetchEvent(String publicHash) async { return { 'event': {'id': 'E1', 'title': '팀/미배정 테스트', 'gameCount': 3, 'status': 'active'}, 'participants': [ { 'participantId': 'p1', 'name': 'Kim', 'scores': [100, 100, 100], 'handicap': 0, }, { 'participantId': 'p2', 'name': 'Lee', 'scores': [120, 110, 90], 'handicap': 0, }, ], 'teams': [ { 'teamId': 'T1', 'teamNumber': 1, 'handicap': 0, 'members': [ { 'participantId': 'p1', 'name': 'Kim', 'scores': [100, 100, 100], } ] } ], }; } } void main() { testWidgets('팀 순위 배지와 미배정 목록 렌더', (tester) async { await tester.pumpWidget(MaterialApp( home: PublicEventScreen(publicHash: 'H', service: StubTeamsService()), )); await tester.pumpAndSettle(); // 팀 섹션 (스크롤 필요 시 스크롤) final scrollable = find.byType(Scrollable).first; await tester.scrollUntilVisible(find.byKey(const Key('section_teams')), 300, scrollable: scrollable); expect(find.byKey(const Key('section_teams')), findsOneWidget); expect(find.byKey(const Key('team_rank_1')), findsOneWidget); // 미배정: p2가 표시되어야 함 (필요 시 더 스크롤) await tester.scrollUntilVisible(find.byKey(const Key('section_unassigned')), 300, scrollable: scrollable); expect(find.byKey(const Key('section_unassigned')), findsOneWidget); expect(find.byKey(const Key('unassigned_count')), findsOneWidget); await tester.scrollUntilVisible(find.byKey(const Key('unassigned_p2')), 300, scrollable: scrollable); expect(find.byKey(const Key('unassigned_p2')), findsOneWidget); }); }