Files
bowlingManager/mobile/test/widgets/public_event_404_guard_test.dart
T
2025-11-10 14:14:08 +09:00

39 lines
1.4 KiB
Dart

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lanebow/screens/public_event/public_event_entry_screen.dart';
import 'package:lanebow/screens/public_event/public_event_screen.dart';
import 'package:lanebow/services/public_event_service.dart';
DioException dio404(String path) => DioException(
requestOptions: RequestOptions(path: path),
response: Response(requestOptions: RequestOptions(path: path), statusCode: 404),
type: DioExceptionType.badResponse,
);
class Stub404Service extends PublicEventService {
@override
Future<Map<String, dynamic>> fetchEvent(String publicHash) async {
throw dio404('/api/public/$publicHash');
}
}
void main() {
testWidgets('shows 404 message and go to entry button navigates back', (tester) async {
await tester.pumpWidget(MaterialApp(
home: PublicEventScreen(publicHash: 'nope', service: Stub404Service()),
));
await tester.pumpAndSettle();
expect(find.text('이벤트를 찾을 수 없습니다'), findsOneWidget);
expect(find.byKey(const Key('go_entry_button')), findsOneWidget);
await tester.tap(find.byKey(const Key('go_entry_button')));
await tester.pumpAndSettle();
expect(find.byType(PublicEventEntryScreen), findsOneWidget);
expect(find.text('공개 이벤트 입장'), findsOneWidget);
});
}