Seems the rendering is not that equal after all...

Also add a constant device size for all goldens
This commit is contained in:
Roland Geider
2025-04-12 18:16:07 +02:00
parent 4920c2a091
commit 67ee79b54b
4 changed files with 38 additions and 15 deletions

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:drift/native.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -92,10 +94,12 @@ void main() {
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
await expectLater(
find.byType(NutritionalPlanScreen),
matchesGoldenFile('goldens/nutritional_plan_1_default_view.png'),
);
if (Platform.isLinux) {
await expectLater(
find.byType(NutritionalPlanScreen),
matchesGoldenFile('goldens/nutritional_plan_1_default_view.png'),
);
}
// Default view shows plan description, info button, and no ingredients
expect(find.text('Less fat, more protein'), findsOneWidget);
@@ -109,10 +113,12 @@ void main() {
await tester.tap(infoOutlineButtons.first); // 2nd button shows up also, but is off-screen
await tester.pumpAndSettle();
await expectLater(
find.byType(NutritionalPlanScreen),
matchesGoldenFile('goldens/nutritional_plan_2_one_meal_with_ingredients.png'),
);
if (Platform.isLinux) {
await expectLater(
find.byType(NutritionalPlanScreen),
matchesGoldenFile('goldens/nutritional_plan_2_one_meal_with_ingredients.png'),
);
}
// Ingredients show up now
expect(find.text('100g Water'), findsOneWidget);
@@ -131,10 +137,13 @@ void main() {
await tester.tap(infoOutlineButtons.first);
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/nutritional_plan_3_both_meals_with_ingredients.png'),
);
if (Platform.isLinux) {
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/nutritional_plan_3_both_meals_with_ingredients.png'),
);
}
expect(find.byIcon(Icons.info_outline), findsOneWidget);
expect(find.byIcon(Icons.info), findsNWidgets(2));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:clock/clock.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -70,13 +72,20 @@ void main() {
testWidgets(
'Smoke test the widgets on the routine logs screen',
(WidgetTester tester) async {
tester.view.physicalSize = const Size(500, 1000);
tester.view.devicePixelRatio = 1.0; // Ensure correct pixel ratio
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
await tester.pumpWidget(renderWidget());
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
await expectLater(find.byType(WorkoutLogsScreen),
matchesGoldenFile('goldens/routine_logs_screen_detail.png'));
if (Platform.isLinux) {
await expectLater(
find.byType(WorkoutLogsScreen),
matchesGoldenFile('goldens/routine_logs_screen_detail.png'),
);
}
expect(find.text('Training logs'), findsOneWidget);
expect(find.byType(WorkoutLogCalendar), findsOneWidget);

View File

@@ -72,13 +72,18 @@ void main() {
testWidgets(
'Test the widgets on the routine screen',
(WidgetTester tester) async {
tester.view.physicalSize = const Size(500, 1000);
tester.view.devicePixelRatio = 1.0; // Ensure correct pixel ratio
await tester.pumpWidget(renderWidget());
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
if (Platform.isLinux) {
await expectLater(
find.byType(MaterialApp), matchesGoldenFile('goldens/routine_logs_screen_detail.png'));
find.byType(MaterialApp),
matchesGoldenFile('goldens/routine_logs_screen_detail.png'),
);
}
expect(find.text('3 day workout'), findsOneWidget);