Skip to content

Commit db66870

Browse files
committed
Mock the current day in the routine logs test
The calendar marks the current day, so the goldens were constantly changing and would always fail.
1 parent df06cef commit db66870

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies:
3333
sdk: flutter
3434

3535
carousel_slider: ^5.0.0
36-
clock: ^1.1.1
36+
clock: ^1.1.2
3737
collection: ^1.18.0
3838
cupertino_icons: ^1.0.8
3939
drift: ^2.26.0

test/workout/routine_logs_screen_test.dart

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import 'dart:io';
2020

21+
import 'package:clock/clock.dart';
2122
import 'package:flutter/material.dart';
2223
import 'package:flutter_test/flutter_test.dart';
2324
import 'package:golden_toolkit/golden_toolkit.dart';
@@ -28,6 +29,7 @@ import 'package:wger/models/workouts/routine.dart';
2829
import 'package:wger/providers/routines.dart';
2930
import 'package:wger/screens/routine_logs_screen.dart';
3031
import 'package:wger/screens/routine_screen.dart';
32+
import 'package:wger/widgets/routines/workout_logs.dart';
3133

3234
import '../../test_data/routines.dart';
3335
import 'routine_logs_screen_test.mocks.dart';
@@ -68,23 +70,16 @@ void main() {
6870
);
6971
}
7072

71-
testGoldens('Test the widgets on the routine logs screen', (WidgetTester tester) async {
72-
await loadAppFonts();
73-
await tester.pumpWidget(renderWidget());
74-
await tester.tap(find.byType(TextButton));
75-
await tester.pumpAndSettle();
73+
testGoldens('Smoke test the widgets on the routine logs screen', (WidgetTester tester) async {
74+
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
75+
await tester.pumpWidget(renderWidget());
76+
await tester.tap(find.byType(TextButton));
77+
await tester.pumpAndSettle();
7678

77-
await screenMatchesGolden(tester, 'routine_logs_screen_detail', skip: !Platform.isLinux);
79+
await screenMatchesGolden(tester, 'routine_logs_screen_detail', skip: !Platform.isLinux);
7880

79-
// expect(find.text('3 day workout'), findsOneWidget);
80-
81-
// expect(find.text('first day'), findsOneWidget);
82-
// expect(find.text('chest, shoulders'), findsOneWidget);
83-
84-
// The second day is repeated
85-
// expect(find.text('second day'), findsNWidgets(2));
86-
// expect(find.text('legs'), findsNWidgets(2));
87-
88-
// expect(find.byType(Card), findsNWidgets(3));
81+
expect(find.text('Training logs'), findsOneWidget);
82+
expect(find.byType(WorkoutLogCalendar), findsOneWidget);
83+
});
8984
});
9085
}

0 commit comments

Comments
 (0)