mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Comment test
We need a navigator stack to test that we arrive back at the detail page or at least a navigator observer to check that we pop() the page
This commit is contained in:
@@ -93,13 +93,18 @@ void main() {
|
||||
verify(mockNutrition.editPlan(any));
|
||||
verifyNever(mockNutrition.addPlan(any));
|
||||
|
||||
// TODO: edit calls Navigator.pop(), since the form can only be reached from the
|
||||
// detail page. The test needs to add the detail page to the stack so that
|
||||
// this can be checked.
|
||||
// https://stackoverflow.com/questions/50704647/how-to-test-navigation-via-navigator-in-flutter
|
||||
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text(('New description')),
|
||||
findsOneWidget,
|
||||
reason: 'Nutritional plan detail page',
|
||||
);
|
||||
//await tester.pumpAndSettle();
|
||||
//expect(
|
||||
// find.text(('New description')),
|
||||
//findsOneWidget,
|
||||
//reason: 'Nutritional plan detail page',
|
||||
//);
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new nutritional plan', (WidgetTester tester) async {
|
||||
|
||||
@@ -119,8 +119,9 @@ class MockNutrition extends _i1.Mock implements _i9.Nutrition {
|
||||
returnValue: Future<void>.value(null),
|
||||
returnValueForMissingStub: Future.value()) as _i10.Future<void>);
|
||||
@override
|
||||
_i10.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, int? mealId) =>
|
||||
(super.noSuchMethod(Invocation.method(#addMealItem, [mealItem, mealId]),
|
||||
_i10.Future<_i6.MealItem> addMealItem(
|
||||
_i6.MealItem? mealItem, _i5.Meal? meal) =>
|
||||
(super.noSuchMethod(Invocation.method(#addMealItem, [mealItem, meal]),
|
||||
returnValue: Future<_i6.MealItem>.value(_FakeMealItem()))
|
||||
as _i10.Future<_i6.MealItem>);
|
||||
@override
|
||||
|
||||
@@ -79,13 +79,17 @@ void main() {
|
||||
await tester.enterText(find.byKey(Key('field-description')), 'New description');
|
||||
await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct ed
|
||||
// Correct method was called
|
||||
verify(mockWorkoutPlans.editWorkout(any));
|
||||
verifyNever(mockWorkoutPlans.addWorkout(any));
|
||||
|
||||
// TODO: edit calls Navigator.pop(), since the form can only be reached from the
|
||||
// detail page. The test needs to add the detail page to the stack so that
|
||||
// this can be checked.
|
||||
// https://stackoverflow.com/questions/50704647/how-to-test-navigation-via-navigator-in-flutter
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(('New description')), findsOneWidget, reason: 'Workout plan detail page');
|
||||
//await tester.pumpAndSettle();
|
||||
//expect(find.text(('New description')), findsOneWidget, reason: 'Workout plan detail page');
|
||||
});
|
||||
|
||||
testWidgets('Test creating a new workout', (WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user