test: 새 캐릭터 화면 테스트 개선
This commit is contained in:
@@ -5,10 +5,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// 테스트용 MaterialApp 래퍼 (localization 포함)
|
||||
/// locale을 영어로 고정하여 테스트 텍스트와 일치시킴
|
||||
Widget _buildTestApp(Widget child) {
|
||||
return MaterialApp(
|
||||
localizationsDelegates: L10n.localizationsDelegates,
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
locale: const Locale('en'), // 영어 locale 고정
|
||||
home: child,
|
||||
);
|
||||
}
|
||||
@@ -20,23 +22,25 @@ void main() {
|
||||
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
|
||||
),
|
||||
);
|
||||
// Localization 로드 대기
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 화면 타이틀 확인 (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('CON'), findsOneWidget);
|
||||
|
||||
// Sold! 버튼 확인
|
||||
expect(find.text('Sold!'), findsOneWidget);
|
||||
expect(find.text('SOLD!'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Unroll button exists and can be tapped', (tester) async {
|
||||
@@ -45,17 +49,18 @@ void main() {
|
||||
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Unroll 버튼 확인
|
||||
final unrollButton = find.text('Unroll');
|
||||
// Unroll 버튼 확인 (RetroTextButton이 대문자로 변환)
|
||||
final unrollButton = find.text('UNROLL');
|
||||
expect(unrollButton, findsOneWidget);
|
||||
|
||||
// Unroll 버튼 탭
|
||||
await tester.tap(unrollButton);
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Total이 표시되는지 확인
|
||||
expect(find.textContaining('Total'), findsOneWidget);
|
||||
// Total이 표시되는지 확인 (TOTAL은 대문자로 표시됨)
|
||||
expect(find.textContaining('TOTAL'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Sold button creates character with generated name', (
|
||||
@@ -72,17 +77,18 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Sold! 버튼이 보이도록 스크롤
|
||||
await tester.scrollUntilVisible(
|
||||
find.text('Sold!'),
|
||||
find.text('SOLD!'),
|
||||
500.0,
|
||||
scrollable: find.byType(Scrollable).first,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Sold! 버튼 탭
|
||||
await tester.tap(find.text('Sold!'));
|
||||
await tester.tap(find.text('SOLD!'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 콜백이 호출되었는지 확인
|
||||
@@ -99,6 +105,7 @@ void main() {
|
||||
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 능력치 라벨들이 표시되는지 확인
|
||||
expect(find.text('STR'), findsOneWidget);
|
||||
@@ -108,8 +115,8 @@ void main() {
|
||||
expect(find.text('WIS'), findsOneWidget);
|
||||
expect(find.text('CHA'), findsOneWidget);
|
||||
|
||||
// Total 라벨 확인
|
||||
expect(find.textContaining('Total'), findsOneWidget);
|
||||
// Total 라벨 확인 (TOTAL은 대문자로 표시됨)
|
||||
expect(find.textContaining('TOTAL'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Name text field exists', (tester) async {
|
||||
@@ -118,6 +125,7 @@ void main() {
|
||||
NewCharacterScreen(onCharacterCreated: (_, {bool testMode = false}) {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// TextField 확인 (이름 입력 필드)
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user