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 StubFetchService extends PublicEventService { @override Future> fetchEvent(String publicHash) async { return { 'event': {'id': 'E100', 'title': '오픈 리그'}, 'participants': [ {'participantId': '1', 'name': 'Kim'}, {'participantId': '2', 'name': 'Lee'}, ], 'teams': [ {'teamId': 'T1'}, ], }; } } void main() { testWidgets('renders title and counts from fetchEvent', (tester) async { await tester.pumpWidget(MaterialApp( home: PublicEventScreen(publicHash: 'abc', service: StubFetchService()), )); // initial loading expect(find.byType(CircularProgressIndicator), findsOneWidget); await tester.pumpAndSettle(); expect(find.byKey(const Key('event_title')), findsOneWidget); expect(find.text('오픈 리그'), findsOneWidget); expect(find.byKey(const Key('participants_count')), findsOneWidget); final pc = tester.widget(find.byKey(const Key('participants_count'))); expect(pc.data, '총 2명'); expect(find.byKey(const Key('teams_count')), findsOneWidget); expect(find.text('총 1팀'), findsOneWidget); }); }