diff --git a/mobile/test/src/features/schedules/presentations/income/goldens/new_income_schedule_detail.png b/mobile/test/src/features/schedules/presentations/income/goldens/new_income_schedule_detail.png new file mode 100644 index 0000000..3bdece7 Binary files /dev/null and b/mobile/test/src/features/schedules/presentations/income/goldens/new_income_schedule_detail.png differ diff --git a/mobile/test/src/features/schedules/presentations/income/goldens/update_income_schedule_detail.png b/mobile/test/src/features/schedules/presentations/income/goldens/update_income_schedule_detail.png new file mode 100644 index 0000000..489d622 Binary files /dev/null and b/mobile/test/src/features/schedules/presentations/income/goldens/update_income_schedule_detail.png differ diff --git a/mobile/test/src/features/schedules/presentations/income/income_schedule_detail_screen_test.dart b/mobile/test/src/features/schedules/presentations/income/income_schedule_detail_screen_test.dart new file mode 100644 index 0000000..4d95ce5 --- /dev/null +++ b/mobile/test/src/features/schedules/presentations/income/income_schedule_detail_screen_test.dart @@ -0,0 +1,45 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:golden_toolkit/golden_toolkit.dart'; +import 'package:openapi/openapi.dart'; +import 'package:suito/src/features/transactions/services/income/income_form_value.dart'; + +import '../../schedules_robot.dart'; + +void main() { + // TODO エラー時の表示テスト追加 + + group('IncomeScheduleDetail Golden test group', () { + testGoldens('Open IncomeDetailView as registration for new income', + (tester) async { + await loadAppFonts(); + final r = SchedulesRobot(tester); + final now = DateTime(2023, 5, 1); + final income = IncomeFormValue.newIncome(now); + await r.pumpIncomeDetailScreen(income); + await screenMatchesGolden(tester, 'new_income_schedule_detail'); + }); + + testGoldens( + 'Open IncomeScheduleDetailView for updating a registered income schedule', + (tester) async { + await loadAppFonts(); + final r = SchedulesRobot(tester); + const id = 'income_schedule_id'; + final incomeType = ModelIncomeType((e) => e + ..id = 'income_type_id' + ..name = 'Test Income Type'); + final incomeTypeMap = {incomeType.id: incomeType}; + final res = IncomeScheduleDetailRes( + (r) => r.incomeSchedule.replace(ModelIncomeSchedule((b) => b + ..id = id + ..timezone = 'Asia/Tokyo' + ..incomeTypeId = incomeType.id + ..memo = 'Some memo' + ..amount = 400))); + + final income = IncomeFormValue.fromSchedule(res, incomeTypeMap); + await r.pumpIncomeDetailScreen(income); + await screenMatchesGolden(tester, 'update_income_schedule_detail'); + }); + }); +} diff --git a/mobile/test/src/features/schedules/schedules_robot.dart b/mobile/test/src/features/schedules/schedules_robot.dart index ae39567..80b2460 100644 --- a/mobile/test/src/features/schedules/schedules_robot.dart +++ b/mobile/test/src/features/schedules/schedules_robot.dart @@ -3,8 +3,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:suito/src/app_theme.dart'; import 'package:suito/src/features/schedules/presentations/expense/expense_schedule_detail_screen.dart'; +import 'package:suito/src/features/schedules/presentations/income/income_schedule_detail_screen.dart'; import 'package:suito/src/features/transactions/services/expense/expense_form_controller.dart'; import 'package:suito/src/features/transactions/services/expense/expense_form_value.dart'; +import 'package:suito/src/features/transactions/services/income/income_form_controller.dart'; +import 'package:suito/src/features/transactions/services/income/income_form_value.dart'; class SchedulesRobot { SchedulesRobot(this.tester); @@ -23,4 +26,18 @@ class SchedulesRobot { ); await tester.pumpAndSettle(); } + + Future pumpIncomeDetailScreen(IncomeFormValue value) async { + await tester.pumpWidget( + ProviderScope( + overrides: [ + incomeFormInitialValueProvider.overrideWith((ref) => value), + ], + child: MaterialApp( + home: const IncomeScheduleDetailScreen(), + theme: AppTheme().create()), + ), + ); + await tester.pumpAndSettle(); + } }