From 4935ad4c7735dacf86c5d3ed68f73774e91c768c Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 28 Apr 2021 12:52:06 +0200 Subject: [PATCH] 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 --- test/nutritional_plan_form_test.dart | 17 +++++++++++------ test/nutritional_plan_form_test.mocks.dart | 5 +++-- test/workout_form_test.dart | 10 +++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/test/nutritional_plan_form_test.dart b/test/nutritional_plan_form_test.dart index a9aedd2d..3c995ae3 100644 --- a/test/nutritional_plan_form_test.dart +++ b/test/nutritional_plan_form_test.dart @@ -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 { diff --git a/test/nutritional_plan_form_test.mocks.dart b/test/nutritional_plan_form_test.mocks.dart index 207d033b..1fb9726d 100644 --- a/test/nutritional_plan_form_test.mocks.dart +++ b/test/nutritional_plan_form_test.mocks.dart @@ -119,8 +119,9 @@ class MockNutrition extends _i1.Mock implements _i9.Nutrition { returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @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 diff --git a/test/workout_form_test.dart b/test/workout_form_test.dart index 92b89519..8cbe5685 100644 --- a/test/workout_form_test.dart +++ b/test/workout_form_test.dart @@ -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 {