Skip to content

Commit

Permalink
Merge pull request #355 from wakamenod/354-mobile-test-収入スケジュール詳細uiテスト追加
Browse files Browse the repository at this point in the history
[Mobile] [Test] 収入スケジュール詳細UIテスト追加 #354
  • Loading branch information
wakamenod authored Jul 24, 2023
2 parents 91b5c07 + 26cef30 commit aaf6fbd
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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');
});
});
}
17 changes: 17 additions & 0 deletions mobile/test/src/features/schedules/schedules_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -23,4 +26,18 @@ class SchedulesRobot {
);
await tester.pumpAndSettle();
}

Future<void> pumpIncomeDetailScreen(IncomeFormValue value) async {
await tester.pumpWidget(
ProviderScope(
overrides: [
incomeFormInitialValueProvider.overrideWith((ref) => value),
],
child: MaterialApp(
home: const IncomeScheduleDetailScreen(),
theme: AppTheme().create()),
),
);
await tester.pumpAndSettle();
}
}

0 comments on commit aaf6fbd

Please sign in to comment.