test(app): add geocoding and restaurant card coverage

This commit is contained in:
JiWoong Sul
2025-11-26 19:16:27 +09:00
parent 0e8c06bade
commit d05e378569
3 changed files with 158 additions and 4 deletions

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lunchpick/domain/entities/restaurant.dart';
import 'package:lunchpick/presentation/pages/restaurant_list/widgets/restaurant_card.dart';
import 'package:lunchpick/presentation/providers/visit_provider.dart';
void main() {
Restaurant buildRestaurant({required bool needsAddressVerification}) {
return Restaurant(
id: '1',
name: '테스트 식당',
category: '한식',
subCategory: '찌개',
roadAddress: '서울시 중구',
jibunAddress: '서울시 중구',
latitude: 37.5665,
longitude: 126.9780,
source: DataSource.USER_INPUT,
createdAt: DateTime(2024, 1, 1),
updatedAt: DateTime(2024, 1, 1),
needsAddressVerification: needsAddressVerification,
);
}
ProviderScope wrapWithProviders(Widget child) {
return ProviderScope(
overrides: [
lastVisitDateProvider.overrideWithProvider(
(id) => FutureProvider((ref) async => null),
),
],
child: MaterialApp(home: child),
);
}
testWidgets('주소 확인 배지가 표시되고 거리 뱃지가 노출된다', (tester) async {
final restaurant = buildRestaurant(needsAddressVerification: true);
await tester.pumpWidget(
wrapWithProviders(
RestaurantCard(restaurant: restaurant, distanceKm: 2.3),
),
);
await tester.pumpAndSettle();
expect(find.text('주소확인'), findsOneWidget);
expect(find.text('2.0km 이상'), findsOneWidget);
});
testWidgets('주소 확인 플래그가 없으면 배지가 숨겨진다', (tester) async {
final restaurant = buildRestaurant(needsAddressVerification: false);
await tester.pumpWidget(
wrapWithProviders(
RestaurantCard(restaurant: restaurant, distanceKm: null),
),
);
await tester.pumpAndSettle();
expect(find.text('주소확인'), findsNothing);
});
}