From 7fffa94925593c85830f54a0585fddaa90c56ca4 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Tue, 7 May 2024 23:58:20 +0200 Subject: [PATCH] cleanup --- .../nutritional_plan_screen_test.dart | 91 ------------------- 1 file changed, 91 deletions(-) diff --git a/test/nutrition/nutritional_plan_screen_test.dart b/test/nutrition/nutritional_plan_screen_test.dart index 4fbd97a20..26ab314e6 100644 --- a/test/nutrition/nutritional_plan_screen_test.dart +++ b/test/nutrition/nutritional_plan_screen_test.dart @@ -16,112 +16,23 @@ * along with this program. If not, see . */ -import 'dart:convert'; - import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:golden_toolkit/golden_toolkit.dart'; import 'package:http/http.dart' as http; import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; import 'package:provider/provider.dart'; -import 'package:wger/models/nutrition/ingredient.dart'; import 'package:wger/providers/auth.dart'; import 'package:wger/providers/base_provider.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/providers/nutrition.dart'; import 'package:wger/screens/nutritional_plan_screen.dart'; import '../../test_data/nutritional_plans.dart'; -import '../fixtures/fixture_reader.dart'; -import 'helper.dart'; import 'nutritional_plan_screen_test.mocks.dart'; @GenerateMocks([WgerBaseProvider, AuthProvider, http.Client]) void main() { - // makeUrl('nutritionplan', {id: 1, objectMethod: null, query: null}) - // Add a stub for this method using Mockito's 'when' API, or generate the MockWgerBaseProvider mock with the @GenerateNiceMocks annotation (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).) - - late NutritionPlansProvider nutritionProvider; - late MockWgerBaseProvider mockWgerBaseProvider; - - setUp(() { - mockWgerBaseProvider = MockWgerBaseProvider(); - nutritionProvider = NutritionPlansProvider(mockWgerBaseProvider, []); - - const String planInfoUrl = 'nutritionplaninfo'; - const String planUrl = 'nutritionplan'; - const String diaryUrl = 'nutritiondiary'; - const String ingredientUrl = 'ingredient'; - - final Map nutritionalPlanInfoResponse = jsonDecode( - fixture('nutrition/nutritional_plan_info_detail_response.json'), - ); - final Map nutritionalPlanDetailResponse = jsonDecode( - fixture('nutrition/nutritional_plan_detail_response.json'), - ); - final List nutritionDiaryResponse = jsonDecode( - fixture('nutrition/nutrition_diary_response.json'), - )['results']; - final Map ingredient59887Response = jsonDecode( - fixture('nutrition/ingredient_59887_response.json'), - ); - final Map ingredient10065Response = jsonDecode( - fixture('nutrition/ingredient_10065_response.json'), - ); - final Map ingredient58300Response = jsonDecode( - fixture('nutrition/ingredient_58300_response.json'), - ); - - final ingredientList = [ - Ingredient.fromJson(ingredient59887Response), - Ingredient.fromJson(ingredient10065Response), - Ingredient.fromJson(ingredient58300Response), - ]; - - nutritionProvider.ingredients = ingredientList; - - final Uri planInfoUri = Uri( - scheme: 'http', - host: 'localhost', - path: 'api/v2/$planInfoUrl/1', - ); - final Uri planUri = Uri( - scheme: 'http', - host: 'localhost', - path: 'api/v2/$planUrl', - ); - final Uri diaryUri = Uri( - scheme: 'http', - host: 'localhost', - path: 'api/v2/$diaryUrl', - ); - when(mockWgerBaseProvider.makeUrl(planInfoUrl, id: anyNamed('id'))).thenReturn(planInfoUri); - when(mockWgerBaseProvider.makeUrl(planUrl, id: anyNamed('id'))).thenReturn(planUri); - when(mockWgerBaseProvider.makeUrl(diaryUrl, query: anyNamed('query'))).thenReturn(diaryUri); - when(mockWgerBaseProvider.fetch(planInfoUri)).thenAnswer( - (realInvocation) => Future.value(nutritionalPlanInfoResponse), - ); - when(mockWgerBaseProvider.fetch(planUri)).thenAnswer( - (realInvocation) => Future.value(nutritionalPlanDetailResponse), - ); - when(mockWgerBaseProvider.fetchPaginated(diaryUri)).thenAnswer( - (realInvocation) => Future.value(nutritionDiaryResponse), - ); - }); - -/* - late MockWgerBaseProvider mockBaseProvider; -// late ExercisesProvider provider; - - const String npPlanUrl = 'nutritionplan'; - - final Uri tNpPlanEntriesUri = Uri( - scheme: 'http', - host: 'localhost', - path: 'api/v2/$npPlanUrl/', - ); -*/ Widget createNutritionalPlan({locale = 'en'}) { final key = GlobalKey(); final mockBaseProvider = MockWgerBaseProvider(); @@ -159,7 +70,6 @@ void main() { 'Test the widgets on the nutritional plan screen', (tester) async { await loadAppFonts(); - await tester.takeScreenshot(name: 'die1'); final globalKey = GlobalKey(); await tester.pumpWidgetBuilder( Material( @@ -189,7 +99,6 @@ void main() { var infoOutlineButtons = find.byIcon(Icons.info_outline); await tester.tap(infoOutlineButtons.first); // 2nd button shows up also, but is off-screen await tester.pumpAndSettle(); - await tester.takeScreenshot(name: 'die2'); await screenMatchesGolden(tester, 'nutritional_plan_2_one_meal_with_ingredients'); // Ingredients show up now