70 lines
2.5 KiB
Dart
70 lines
2.5 KiB
Dart
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 StubFinalService extends PublicEventService {
|
|
@override
|
|
Future<Map<String, dynamic>> fetchEvent(String publicHash) async {
|
|
return {
|
|
'event': {'id': 'E1', 'title': '최종 결과 테스트', 'gameCount': 3, 'status': 'completed'},
|
|
'participants': [
|
|
{
|
|
'participantId': 'p1',
|
|
'name': 'Kim',
|
|
'scores': [140, 150, 0],
|
|
'handicap': 0,
|
|
},
|
|
{
|
|
'participantId': 'p2',
|
|
'name': 'Lee',
|
|
'scores': [200, 100, 0],
|
|
'handicap': 0,
|
|
},
|
|
{
|
|
'participantId': 'p3',
|
|
'name': 'Park',
|
|
'scores': [200, 100, 0],
|
|
'handicap': 0,
|
|
},
|
|
],
|
|
'teams': [],
|
|
};
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('완료 상태에서 최종 결과 섹션 렌더와 동순위 처리, 평균 1자리', (tester) async {
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: PublicEventScreen(publicHash: 'H', service: StubFinalService()),
|
|
));
|
|
await tester.pumpAndSettle();
|
|
|
|
// 최종 결과 섹션 존재 (스크롤 필요 시 스크롤)
|
|
final scrollable = find.byType(Scrollable).first;
|
|
await tester.scrollUntilVisible(find.byKey(const Key('section_final_results')), 300, scrollable: scrollable);
|
|
expect(find.byKey(const Key('section_final_results')), findsOneWidget);
|
|
|
|
// 각 행 존재
|
|
expect(find.byKey(const Key('result_row_p1')), findsOneWidget);
|
|
expect(find.byKey(const Key('result_row_p2')), findsOneWidget);
|
|
expect(find.byKey(const Key('result_row_p3')), findsOneWidget);
|
|
|
|
// 총점: p2/p3=300, p1=300 (동률), 동순위 1,1,3
|
|
expect(find.byKey(const Key('result_rank_p2')), findsOneWidget);
|
|
expect(find.byKey(const Key('result_rank_p3')), findsOneWidget);
|
|
expect(find.byKey(const Key('result_rank_p1')), findsOneWidget);
|
|
|
|
final r2 = tester.widget<Text>(find.byKey(const Key('result_rank_p2'))).data;
|
|
final r3 = tester.widget<Text>(find.byKey(const Key('result_rank_p3'))).data;
|
|
final r1 = tester.widget<Text>(find.byKey(const Key('result_rank_p1'))).data;
|
|
|
|
expect(r2, '1');
|
|
expect(r3, '1');
|
|
expect(r1, '3');
|
|
|
|
// 평균 표기 1자리 확인: 0점도 입력으로 카운트됨 → p2: (200+100+0)/3 = 100.0
|
|
expect(find.textContaining('평균 100.0'), findsWidgets);
|
|
});
|
|
}
|