Fix tests

This commit is contained in:
Roland Geider
2025-01-18 14:40:13 +01:00
parent f5ab51fd5b
commit c397e10e3f
3 changed files with 61 additions and 23 deletions

View File

@@ -18,6 +18,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
@@ -56,21 +57,23 @@ void main() {
),
child: ChangeNotifierProvider<ExercisesProvider>(
create: (context) => mockExerciseProvider,
child: MaterialApp(
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: key,
home: TextButton(
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: const RouteSettings(arguments: GymModeArguments(1, 1, 1)),
builder: (_) => const GymModeScreen(),
child: riverpod.ProviderScope(
child: MaterialApp(
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: key,
home: TextButton(
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: const RouteSettings(arguments: GymModeArguments(1, 1, 1)),
builder: (_) => const GymModeScreen(),
),
),
child: const SizedBox(),
),
child: const SizedBox(),
routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()},
),
routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()},
),
),
);
@@ -174,9 +177,25 @@ void main() {
await tester.pumpAndSettle();
//
// Side raises - exercise overview page
// Bench press - log
//
expect(find.text('Bench press'), findsOneWidget);
expect(find.byType(LogPage), findsOneWidget);
expect(find.byType(Form), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
//
// Pause
//
expect(find.text('Pause'), findsOneWidget);
expect(find.byType(TimerWidget), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
//
// Side raises - overview
//
debugDumpApp();
expect(find.text('Side raises'), findsOneWidget);
expect(find.byType(ExerciseOverview), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
@@ -185,6 +204,7 @@ void main() {
//
// Side raises - log
//
expect(find.text('Side raises'), findsOneWidget);
expect(find.byType(LogPage), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
@@ -199,6 +219,22 @@ void main() {
//
// Side raises - log
//
expect(find.text('Side raises'), findsOneWidget);
expect(find.byType(LogPage), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
//
// Side raises - timer
//
expect(find.byType(TimerWidget), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
//
// Side raises - log
//
expect(find.text('Side raises'), findsOneWidget);
expect(find.byType(LogPage), findsOneWidget);
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();

View File

@@ -65,7 +65,7 @@ void main() {
);
}
testWidgets('Test the widgets on the nutritional plan screen', (WidgetTester tester) async {
testWidgets('Test the widgets on the routine screen', (WidgetTester tester) async {
await tester.pumpWidget(renderWidget());
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
@@ -75,8 +75,10 @@ void main() {
expect(find.text('first day'), findsOneWidget);
expect(find.text('chest, shoulders'), findsOneWidget);
expect(find.text('second day'), findsOneWidget);
expect(find.text('legs'), findsOneWidget);
expect(find.byType(Card), findsNWidgets(2));
// The second day is repeated
expect(find.text('second day'), findsNWidgets(2));
expect(find.text('legs'), findsNWidgets(2));
expect(find.byType(Card), findsNWidgets(3));
});
}

View File

@@ -240,7 +240,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
textRepr: '4 sets 12x10kg',
),
],
)
),
],
),
DayData(
@@ -269,7 +269,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
textRepr: '4 sets 3x100kg',
),
],
)
),
],
),
DayData(
@@ -325,7 +325,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
textRepr: '5 sets 8x105kg',
),
],
)
),
],
),
],
@@ -433,7 +433,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
textRepr: '12x10kg',
),
],
)
),
],
),
DayData(
@@ -490,7 +490,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
textRepr: '3x100kg',
),
],
)
),
],
),
],