-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from wakamenod/352-mobile-test-支出スケジュール詳細uiテスト追加
[Mobile] [Test] 支出スケジュール詳細UIテスト追加 #352
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...est/src/features/schedules/presentations/expense/expense_schedule_detail_screen_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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/expense/expense_form_value.dart'; | ||
|
||
import '../../schedules_robot.dart'; | ||
|
||
void main() { | ||
// TODO エラー時の表示テスト追加 | ||
|
||
group('ExpenseScheduleDetail Golden test group', () { | ||
testGoldens('Open ExpenseDetailView as registration for new expense', | ||
(tester) async { | ||
await loadAppFonts(); | ||
final r = SchedulesRobot(tester); | ||
final now = DateTime(2023, 5, 1); | ||
final expense = ExpenseFormValue.newExpense(now); | ||
await r.pumpExpenseDetailScreen(expense); | ||
await screenMatchesGolden(tester, 'new_expense_schedule_detail'); | ||
}); | ||
|
||
testGoldens('Open ExpenseScheduleDetailView for updating a registered expense schedule', | ||
(tester) async { | ||
await loadAppFonts(); | ||
final r = SchedulesRobot(tester); | ||
const id = 'expense_schedule_id'; | ||
final category = ModelExpenseCategory((e) => e | ||
..id = 'expense_category_id' | ||
..name = 'Test Category'); | ||
final categoryMap = {category.id: category}; | ||
final location = ModelExpenseLocation((e) => e | ||
..id = 'expense_location_id' | ||
..name = 'Test Location'); | ||
final locationMap = {location.id: location}; | ||
final res = | ||
ExpenseScheduleDetailRes((r) => r.expenseSchedule.replace(ModelExpenseSchedule((b) => b | ||
..id = id | ||
..timezone = 'Asia/Tokyo' | ||
..title = 'registered title' | ||
..memo = 'Some memo' | ||
..amount = 400 | ||
..expenseCategoryID = category.id | ||
..expenseLocationID = location.id))); | ||
|
||
final expense = | ||
ExpenseFormValue.fromSchedule(res, categoryMap, locationMap); | ||
await r.pumpExpenseDetailScreen(expense); | ||
await screenMatchesGolden(tester, 'update_expense_schedule_detail'); | ||
}); | ||
}); | ||
} |
Binary file added
BIN
+62.7 KB
...eatures/schedules/presentations/expense/goldens/new_expense_schedule_detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+94.2 KB
...ures/schedules/presentations/expense/goldens/update_expense_schedule_detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
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/transactions/services/expense/expense_form_controller.dart'; | ||
import 'package:suito/src/features/transactions/services/expense/expense_form_value.dart'; | ||
|
||
class SchedulesRobot { | ||
SchedulesRobot(this.tester); | ||
final WidgetTester tester; | ||
|
||
Future<void> pumpExpenseDetailScreen(ExpenseFormValue value) async { | ||
await tester.pumpWidget( | ||
ProviderScope( | ||
overrides: [ | ||
expenseFormInitialValueProvider.overrideWith((ref) => value), | ||
], | ||
child: MaterialApp( | ||
home: const ExpenseScheduleDetailScreen(), | ||
theme: AppTheme().create()), | ||
), | ||
); | ||
await tester.pumpAndSettle(); | ||
} | ||
} |