test: 새 캐릭터 화면 테스트 개선

This commit is contained in:
JiWoong Sul
2026-01-14 02:26:27 +09:00
parent 81eb2f8463
commit f9a4ae105a

View File

@@ -5,10 +5,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
/// 테스트용 MaterialApp 래퍼 (localization 포함) /// 테스트용 MaterialApp 래퍼 (localization 포함)
/// locale을 영어로 고정하여 테스트 텍스트와 일치시킴
Widget _buildTestApp(Widget child) { Widget _buildTestApp(Widget child) {
return MaterialApp( return MaterialApp(
localizationsDelegates: L10n.localizationsDelegates, localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales, supportedLocales: L10n.supportedLocales,
locale: const Locale('en'), // 영어 locale 고정
home: child, home: child,
); );
} }
@@ -20,23 +22,25 @@ void main() {
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}), NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
), ),
); );
// Localization 로드 대기
await tester.pumpAndSettle();
// 화면 타이틀 확인 (l10n 적용됨) // 화면 타이틀 확인 (l10n 적용됨)
expect(find.text('ASCII NEVER DIE - New Character'), findsOneWidget); expect(find.text('ASCII NEVER DIE - NEW CHARACTER'), findsOneWidget);
// 종족 섹션 확인 // 종족 섹션 확인 (대문자 하드코딩)
expect(find.text('Race'), findsOneWidget); expect(find.text('RACE'), findsOneWidget);
// 직업 섹션 확인 // 직업 섹션 확인 (대문자 하드코딩)
expect(find.text('Class'), findsOneWidget); expect(find.text('CLASS'), findsOneWidget);
// 능력치 섹션 확인 // 능력치 섹션 확인 (대문자 하드코딩)
expect(find.text('Stats'), findsOneWidget); expect(find.text('STATS'), findsOneWidget);
expect(find.text('STR'), findsOneWidget); expect(find.text('STR'), findsOneWidget);
expect(find.text('CON'), findsOneWidget); expect(find.text('CON'), findsOneWidget);
// Sold! 버튼 확인 // Sold! 버튼 확인
expect(find.text('Sold!'), findsOneWidget); expect(find.text('SOLD!'), findsOneWidget);
}); });
testWidgets('Unroll button exists and can be tapped', (tester) async { testWidgets('Unroll button exists and can be tapped', (tester) async {
@@ -45,17 +49,18 @@ void main() {
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}), NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
), ),
); );
await tester.pumpAndSettle();
// Unroll 버튼 확인 // Unroll 버튼 확인 (RetroTextButton이 대문자로 변환)
final unrollButton = find.text('Unroll'); final unrollButton = find.text('UNROLL');
expect(unrollButton, findsOneWidget); expect(unrollButton, findsOneWidget);
// Unroll 버튼 탭 // Unroll 버튼 탭
await tester.tap(unrollButton); await tester.tap(unrollButton);
await tester.pump(); await tester.pumpAndSettle();
// Total이 표시되는지 확인 // Total이 표시되는지 확인 (TOTAL은 대문자로 표시됨)
expect(find.textContaining('Total'), findsOneWidget); expect(find.textContaining('TOTAL'), findsOneWidget);
}); });
testWidgets('Sold button creates character with generated name', ( testWidgets('Sold button creates character with generated name', (
@@ -72,17 +77,18 @@ void main() {
), ),
), ),
); );
await tester.pumpAndSettle();
// Sold! 버튼이 보이도록 스크롤 // Sold! 버튼이 보이도록 스크롤
await tester.scrollUntilVisible( await tester.scrollUntilVisible(
find.text('Sold!'), find.text('SOLD!'),
500.0, 500.0,
scrollable: find.byType(Scrollable).first, scrollable: find.byType(Scrollable).first,
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Sold! 버튼 탭 // Sold! 버튼 탭
await tester.tap(find.text('Sold!')); await tester.tap(find.text('SOLD!'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// 콜백이 호출되었는지 확인 // 콜백이 호출되었는지 확인
@@ -99,6 +105,7 @@ void main() {
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}), NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
), ),
); );
await tester.pumpAndSettle();
// 능력치 라벨들이 표시되는지 확인 // 능력치 라벨들이 표시되는지 확인
expect(find.text('STR'), findsOneWidget); expect(find.text('STR'), findsOneWidget);
@@ -108,8 +115,8 @@ void main() {
expect(find.text('WIS'), findsOneWidget); expect(find.text('WIS'), findsOneWidget);
expect(find.text('CHA'), findsOneWidget); expect(find.text('CHA'), findsOneWidget);
// Total 라벨 확인 // Total 라벨 확인 (TOTAL은 대문자로 표시됨)
expect(find.textContaining('Total'), findsOneWidget); expect(find.textContaining('TOTAL'), findsOneWidget);
}); });
testWidgets('Name text field exists', (tester) async { testWidgets('Name text field exists', (tester) async {
@@ -118,6 +125,7 @@ void main() {
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}), NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
), ),
); );
await tester.pumpAndSettle();
// TextField 확인 (이름 입력 필드) // TextField 확인 (이름 입력 필드)
expect(find.byType(TextField), findsOneWidget); expect(find.byType(TextField), findsOneWidget);