이벤트 가져오기 위젯 테스트 추가 및 테스트 훅 도입

This commit is contained in:
2025-09-12 06:33:44 +09:00
parent 107abc963f
commit a5f2544d11
121 changed files with 39277 additions and 3911 deletions
@@ -0,0 +1,71 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lanebow/widgets/import_result_dialog.dart';
void main() {
group('ImportResultDialog', () {
testWidgets('기본 정보 및 실패 행/사유 프리뷰를 표시한다', (tester) async {
const fileName = 'sample.csv';
const processedRows = 12;
const createdCount = 8;
const invalidRows = 4;
final invalidRowIndices = ['2', '5', '7', '10'];
// 7개 사유를 제공하여 상위 5개 + 외 N건 동작 검증
final invalidRowReasons = <String, String>{
'2': 'title 누락',
'3': 'startDate 누락',
'4': 'title 누락',
'5': 'startDate 누락',
'6': 'title 누락',
'7': 'startDate 누락',
'8': 'title 누락',
};
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: SizedBox.shrink()),
),
);
showDialog(
context: tester.element(find.byType(SizedBox)),
builder: (_) => ImportResultDialog(
fileName: fileName,
processedRows: processedRows,
createdCount: createdCount,
invalidRows: invalidRows,
invalidRowIndices: invalidRowIndices,
invalidRowReasons: invalidRowReasons,
onClose: () {},
),
);
await tester.pumpAndSettle();
// 기본 정보
expect(find.text('파일 처리 결과'), findsOneWidget);
expect(find.text('파일명: $fileName'), findsOneWidget);
expect(find.text('처리된 행: ${processedRows}'), findsOneWidget);
expect(find.text('생성된 이벤트: ${createdCount}'), findsOneWidget);
expect(find.text('유효하지 않은 행: ${invalidRows}'), findsOneWidget);
// 실패 행 번호 프리뷰
expect(
find.textContaining('실패 행(최대 10개 미리보기): 2, 5, 7, 10'),
findsOneWidget,
);
// 실패 사유 상위 5개 + 외 N건
expect(find.text('실패 사유(일부):'), findsOneWidget);
expect(find.text('행 2: title 누락'), findsOneWidget);
expect(find.text('행 3: startDate 누락'), findsOneWidget);
expect(find.text('행 4: title 누락'), findsOneWidget);
expect(find.text('행 5: startDate 누락'), findsOneWidget);
expect(find.text('행 6: title 누락'), findsOneWidget);
expect(find.text('... 외 2건'), findsOneWidget);
// 닫기 버튼 존재
expect(find.text('닫기'), findsOneWidget);
});
});
}