diff --git a/mobile/test/src/features/schedules/presentations/goldens/empty_list.png b/mobile/test/src/features/schedules/presentations/goldens/empty_list.png new file mode 100644 index 0000000..19a9c10 Binary files /dev/null and b/mobile/test/src/features/schedules/presentations/goldens/empty_list.png differ diff --git a/mobile/test/src/features/schedules/presentations/goldens/non_empty_list.png b/mobile/test/src/features/schedules/presentations/goldens/non_empty_list.png new file mode 100644 index 0000000..a93e76d Binary files /dev/null and b/mobile/test/src/features/schedules/presentations/goldens/non_empty_list.png differ diff --git a/mobile/test/src/features/schedules/presentations/schedule_screen_test.dart b/mobile/test/src/features/schedules/presentations/schedule_screen_test.dart new file mode 100644 index 0000000..dc496a2 --- /dev/null +++ b/mobile/test/src/features/schedules/presentations/schedule_screen_test.dart @@ -0,0 +1,46 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:golden_toolkit/golden_toolkit.dart'; +import 'package:mocktail/mocktail.dart'; +import 'package:openapi/openapi.dart'; + +import '../../../mocks.dart'; +import '../schedules_robot.dart'; + +void main() { + group('ScheduleScreen Golden test group', () { + testGoldens('Empty list', (tester) async { + await loadAppFonts(); + final r = SchedulesRobot(tester); + final res = ListTransactionSchedulesRes(); + final repository = MockSchedulesRepository(); + when(() => repository.fetchSchedulesList()) + .thenAnswer((_) => Future.value(res)); + await r.pumpSchedulesScreen(repository: repository); + await screenMatchesGolden(tester, 'empty_list'); + }); + + testGoldens('Non Empty list', (tester) async { + await loadAppFonts(); + final r = SchedulesRobot(tester); + final res = ListTransactionSchedulesRes((r) => r + ..incomeSchedules.replace([ + TransactionSchedule((t) => t + ..id = 'income_schedule_id' + ..amount = 400 + ..title = 'Income Title') + ]) + ..expenseSchedules.replace([ + TransactionSchedule((t) => t + ..id = 'expense_schedule_id' + ..amount = 400 + ..title = 'Expense Title') + ])); + final repository = MockSchedulesRepository(); + when(() => repository.fetchSchedulesList()) + .thenAnswer((_) => Future.value(res)); + await r.pumpSchedulesScreen(repository: repository); + await screenMatchesGolden(tester, 'non_empty_list'); + }); + + }); +} diff --git a/mobile/test/src/features/schedules/schedules_robot.dart b/mobile/test/src/features/schedules/schedules_robot.dart index 80b2460..83478b3 100644 --- a/mobile/test/src/features/schedules/schedules_robot.dart +++ b/mobile/test/src/features/schedules/schedules_robot.dart @@ -4,6 +4,8 @@ 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/schedules/presentations/schedule_screen.dart'; +import 'package:suito/src/features/schedules/repositories/schedules_repository.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'; @@ -40,4 +42,21 @@ class SchedulesRobot { ); await tester.pumpAndSettle(); } + + Future pumpSchedulesScreen( + {SchedulesRepository? repository, + }) async { + await tester.pumpWidget( + ProviderScope( + overrides: [ + if (repository != null) + schedulesRepositoryProvider.overrideWithValue(repository) + ], + child: MaterialApp( + home: const ScheduleScreen(), theme: AppTheme().create()), + ), + ); + await tester.pumpAndSettle(); + } + }