Add tests with golden files
Let's see if this doesn't make too much work later on, when changing some detail in a widget causes the test to fail
BIN
test/gym_mode_1.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
test/gym_mode_2.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
test/gym_mode_3.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
test/gym_mode_4.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
test/gym_mode_5.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
test/gym_mode_6.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
test/gym_mode_7.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -80,6 +80,8 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsNothing);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_1.png'));
|
||||
|
||||
await tester.tap(find.byIcon(Icons.chevron_right));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -89,6 +91,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_2.png'));
|
||||
await tester.drag(find.byType(ExerciseOverview), Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -102,6 +105,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_3.png'));
|
||||
await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -111,6 +115,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_4.png'));
|
||||
await tester.tap(find.byIcon(Icons.chevron_right));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -118,6 +123,7 @@ void main() {
|
||||
expect(find.text('test exercise 1'), findsOneWidget);
|
||||
expect(find.byType(LogPage), findsOneWidget);
|
||||
expect(find.byType(Form), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_5.png'));
|
||||
await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -127,6 +133,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_6.png'));
|
||||
await tester.tap(find.byIcon(Icons.chevron_right));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -137,6 +144,7 @@ void main() {
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('gym_mode_7.png'));
|
||||
|
||||
//
|
||||
});
|
||||
|
||||
BIN
test/nutritional_meal_form.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -114,4 +114,9 @@ void main() {
|
||||
// Detail page
|
||||
// ...
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(meal1));
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('nutritional_meal_form.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/nutritional_plan_form.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -118,4 +118,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(('New cool plan')), findsOneWidget, reason: 'Nutritional plan detail page');
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(plan1));
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('nutritional_plan_form.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/nutritional_plan_screen.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
@@ -87,4 +87,9 @@ void main() {
|
||||
|
||||
expect(find.text('17:00'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createNutritionalPlan());
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('nutritional_plan_screen.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/nutritional_plans_screen.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
@@ -106,4 +106,9 @@ void main() {
|
||||
expect(find.text('1.1.2021'), findsOneWidget);
|
||||
expect(find.text('10.1.2021'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('nutritional_plans_screen.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/weight_screen.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
@@ -107,4 +107,9 @@ void main() {
|
||||
expect(find.text('1.1.2021'), findsOneWidget);
|
||||
expect(find.text('10.1.2021'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('weight_screen.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/workout_day_form.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
@@ -98,4 +98,9 @@ void main() {
|
||||
expect(find.text('Dienstag'), findsOneWidget);
|
||||
expect(find.text('Donnerstag'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('workout_day_form.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/workout_form.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -106,4 +106,10 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(('New cool workout')), findsOneWidget, reason: 'Workout plan detail page');
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen(plan2));
|
||||
await tester.pumpAndSettle();
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('workout_form.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/workout_plan_screen.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
@@ -83,4 +83,12 @@ void main() {
|
||||
expect(find.text('Montag, Dienstag'), findsOneWidget);
|
||||
expect(find.text('Donnerstag'), findsOneWidget);
|
||||
});
|
||||
|
||||
// flutter test --update-goldens
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await tester.tap(find.byType(TextButton));
|
||||
await tester.pumpAndSettle();
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('workout_plan_screen.png'));
|
||||
});
|
||||
}
|
||||
|
||||
BIN
test/workout_plan_screens.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
@@ -108,4 +108,9 @@ void main() {
|
||||
expect(find.text('1.1.2021'), findsOneWidget);
|
||||
expect(find.text('12.2.2021'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Golden test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createHomeScreen());
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('workout_plan_screens.png'));
|
||||
});
|
||||
}
|
||||
|
||||