Commit 5cd6ef6

derdilla <contact@derdilla.com>
2024-11-18 07:57:35
Update goldens structure and CI to be easier to navigate
1 parent 52580db
.github/workflows/app-CI.yml
@@ -64,7 +64,7 @@ jobs:
       - name: Update goldens
         id: gold-upd
         if: failure()
-        run: flutter test --update-goldens --fail-fast --dart-define="channel=${{ matrix.channel }}"
+        run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}"
         working-directory: app
       - name: PR golden changes
         # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-of-failure-with-conditions
app/test/features/statistics/beta-ClockBpGraph-dark.png → app/test/features/statistics/golden/beta-ClockBpGraph-dark.png
File renamed without changes
app/test/features/statistics/beta-ClockBpGraph-light.png → app/test/features/statistics/golden/beta-ClockBpGraph-light.png
File renamed without changes
app/test/features/statistics/beta-full_graph-years.png → app/test/features/statistics/golden/beta-full_graph-years.png
File renamed without changes
app/test/features/statistics/beta-value-graph-end-warn.png → app/test/features/statistics/golden/beta-value-graph-end-warn.png
File renamed without changes
app/test/features/statistics/beta-value-graph-start-warn.png → app/test/features/statistics/golden/beta-value-graph-start-warn.png
File renamed without changes
app/test/features/statistics/stable-ClockBpGraph-dark.png → app/test/features/statistics/golden/stable-ClockBpGraph-dark.png
File renamed without changes
app/test/features/statistics/stable-ClockBpGraph-light.png → app/test/features/statistics/golden/stable-ClockBpGraph-light.png
File renamed without changes
app/test/features/statistics/stable-full_graph-years.png → app/test/features/statistics/golden/stable-full_graph-years.png
File renamed without changes
app/test/features/statistics/stable-value-graph-end-warn.png → app/test/features/statistics/golden/stable-value-graph-end-warn.png
File renamed without changes
app/test/features/statistics/stable-value-graph-start-warn.png → app/test/features/statistics/golden/stable-value-graph-start-warn.png
File renamed without changes
app/test/features/statistics/clock_bp_graph_test.dart
@@ -22,7 +22,7 @@ void main() {
     expect(tester.takeException(), isNull);
     expect(find.byType(ClockBpGraph), findsOneWidget);
   });
-  testWidgets('renders sample data like expected in light mode', (tester) async {
+  testWidgets('[gold] renders sample data like expected in light mode', (tester) async {
     final rng = Random(1234);
     await tester.pumpWidget(MaterialApp(
       home: Scaffold(
@@ -44,7 +44,7 @@ void main() {
     ));
     await expectLater(find.byType(ClockBpGraph), myMatchesGoldenFile('ClockBpGraph-light.png'));
   });
-  testWidgets('renders sample data like expected in dark mode', (tester) async {
+  testWidgets('[gold] renders sample data like expected in dark mode', (tester) async {
     final rng = Random(1234);
     await tester.pumpWidget(MaterialApp(
       theme: ThemeData.dark(useMaterial3: true),
app/test/features/statistics/value_graph_test.dart
@@ -75,7 +75,7 @@ void main() {
     final localizations = await AppLocalizations.delegate.load(const Locale('en'));
     expect(find.text(localizations.errNotEnoughDataToGraph), findsOneWidget);
   });
-  testWidgets('graph with all extras is rendered correctly', (tester) async {
+  testWidgets('[gold] graph with all extras is rendered correctly', (tester) async {
     await tester.pumpWidget(_buildGraph([
       mockRecord(time: DateTime(2005), sys: 123, dia: 80, pul: 50),
       mockRecord(time: DateTime(2003), sys: 110, dia: 73, pul: 130),
@@ -131,7 +131,7 @@ void main() {
     expect(find.text(localizations.errNotEnoughDataToGraph), findsNothing);
   });
 
-  testWidgets('graph renders area at start correctly', (tester) async {
+  testWidgets('[gold] graph renders area at start correctly', (tester) async {
     await tester.pumpWidget(_buildGraph([
         mockRecord(time: DateTime(2003), sys: 170, dia: 100, pul: 50),
         mockRecord(time: DateTime(2005), sys: 110, dia: 70, pul: 50),
@@ -147,7 +147,7 @@ void main() {
 
     await expectLater(find.byType(BloodPressureValueGraph), myMatchesGoldenFile('value-graph-start-warn.png'));
   });
-  testWidgets('graph renders area at end correctly', (tester) async {
+  testWidgets('[gold] graph renders area at end correctly', (tester) async {
     await tester.pumpWidget(_buildGraph([
       mockRecord(time: DateTime(2005), sys: 170, dia: 100, pul: 50),
       mockRecord(time: DateTime(2003), sys: 110, dia: 70, pul: 50),
app/test/util.dart
@@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
 import 'package:flutter_gen/gen_l10n/app_localizations.dart';
 import 'package:flutter_test/flutter_test.dart';
 import 'package:health_data_store/health_data_store.dart';
+import 'package:path/path.dart';
 import 'package:provider/provider.dart';
 
 /// Create a root material widget with localizations.
@@ -328,7 +329,8 @@ class MockMedicineRepository extends _MockRepo<Medicine> implements MedicineRepo
 class MockNoteRepository extends _MockRepo<Note> implements NoteRepository {}
 class MockBodyweightRepository extends _MockRepo<BodyweightRecord> implements BodyweightRepository {}
 
+/// [matchesGoldenFile] wrapper that includes a dir and a channel for image names
 dynamic myMatchesGoldenFile(String key) {
   final channel = const String.fromEnvironment('channel');
-  return matchesGoldenFile('$channel-$key');
+  return matchesGoldenFile(join('golden', '$channel-$key'));
 }