Commit 60fb035

derdilla <contact@derdilla.com>
2024-11-18 08:06:08
Fix warn area starting above graph in some cases
1 parent 5cd6ef6
Changed files (3)
app
lib
features
statistics
test
app/lib/features/statistics/value_graph.dart
@@ -210,7 +210,7 @@ class _ValueGraphPainter extends CustomPainter {
         path = Path();
         path.moveTo(point.dx, point.dy);
 
-        warnPath?.moveTo(_kLeftLegendWidth, _transformY(size, warnValue!, minY, maxY));
+        warnPath?.moveTo(_kLeftLegendWidth, warnValue!);
         warnPath?.lineTo(point.dx, point.dy);
       }
     }
app/test/features/statistics/golden/stable-value-graph-warn-not-above.png
Binary file
app/test/features/statistics/value_graph_test.dart
@@ -163,6 +163,19 @@ void main() {
 
     await expectLater(find.byType(BloodPressureValueGraph), myMatchesGoldenFile('value-graph-end-warn.png'));
   });
+  testWidgets('[gold] warn area not drawn above graph', (tester) async {
+    await tester.pumpWidget(_buildGraph([
+      mockRecord(time: DateTime(2005), sys: 103, dia: null, pul: null),
+      mockRecord(time: DateTime(2003), sys: 89, dia: null, pul: null),
+    ], [], [],
+      settings: Settings(sysWarn: 120),
+    ));
+    await tester.pumpAndSettle();
+    final localizations = await AppLocalizations.delegate.load(const Locale('en'));
+    expect(find.text(localizations.errNotEnoughDataToGraph), findsNothing);
+
+    await expectLater(find.byType(BloodPressureValueGraph), myMatchesGoldenFile('value-graph-warn-not-above.png'));
+  });
 }
 
 Widget _buildGraph(