Repository navigation
Empty daytime metrics: ask for the band through the day, not overnight #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,18 @@ String nounInSentence(AppLocalizations? l, String name) { | |
| return '${name[0].toLowerCase()}${name.substring(1)}'; | ||
| } | ||
|
|
||
| /// Metrics a day's wear produces, not a night's. Their empty state asks for | ||
| /// the band through the day; "overnight" would send someone to bed to get a | ||
| /// step count. | ||
| const kDaytimeMetricKeys = { | ||
| 'steps', | ||
| 'calories', | ||
| 'strain', | ||
| 'trimp', | ||
|
Comment on lines
+64
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 'active_min', | ||
| 'wear', | ||
| }; | ||
|
|
||
| /// What a metric key means on screen, and whether we are willing to draw it. | ||
| class MetricSpec { | ||
| /// The alias `getChart` / `getTrend` understand (`_trendKey` maps it on). | ||
|
|
@@ -956,8 +968,11 @@ class _MetricDetailState extends State<MetricDetail> { | |
| // them to wear the band is a promise that cannot change anything — | ||
| // they already did, and the days are one tab away. | ||
| fix: all.isEmpty | ||
| ? (l?.metricDetailWearBandFix ?? | ||
| 'Wear the band overnight to start the series') | ||
| ? (kDaytimeMetricKeys.contains(widget.metricKey) | ||
| ? (l?.dayStrainWearBandFix ?? | ||
| 'Wear the band through the day') | ||
| : (l?.metricDetailWearBandFix ?? | ||
| 'Wear the band overnight to start the series')) | ||
| : '', | ||
| icon: spec.icon, | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // A metric with no history at all tells the user what to do about it. Every | ||
| // metric used to say "Wear the band overnight to start the series", which is | ||
| // right for resting heart rate or sleep and wrong for a step count: steps, | ||
| // energy, strain and wear come from the day. Those now say "Wear the band | ||
| // through the day" (the strain screen's existing, translated hint). | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:openstrap_edge/ui2/screens/screens.dart'; | ||
| import 'package:openstrap_edge/ui2/ui2.dart'; | ||
|
|
||
| Future<void> _pump(WidgetTester t, String key) async { | ||
| t.view.physicalSize = const Size(390 * 3, 1600 * 3); | ||
| t.view.devicePixelRatio = 3; | ||
| addTearDown(t.view.reset); | ||
| await t.pumpWidget(MaterialApp( | ||
| theme: buildTheme(Brightness.light), | ||
| home: Scaffold(body: MetricDetail(key, data: MetricData())), | ||
| )); | ||
| await t.pumpAndSettle(); | ||
| } | ||
|
|
||
| const _overnight = 'Wear the band overnight to start the series'; | ||
| const _daytime = 'Wear the band through the day'; | ||
|
|
||
| void main() { | ||
| for (final key in kDaytimeMetricKeys) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Steps regression goes unnoticed When a daytime key such as Use an independent explicit list of expected daytime keys in the test, so omissions from the production set fail coverage. Prompt for AI agentsIn `test/metric_detail_empty_hint_test.dart` at line 27:
**Steps regression goes unnoticed**
When a daytime key such as `steps` is accidentally removed from `kDaytimeMetricKeys`, when `kDaytimeMetricKeys` omits `steps`, the loop at line 27 of `metric_detail_empty_hint_test.dart` stops creating the Steps case, so Steps can show the overnight hint while every remaining assertion passes.
Use an independent explicit list of expected daytime keys in the test, so omissions from the production set fail coverage. |
||
| testWidgets('$key, never recorded: wear it through the day', (t) async { | ||
| await _pump(t, key); | ||
| expect(find.text(_daytime), findsOneWidget); | ||
| expect(find.text(_overnight), findsNothing); | ||
| }); | ||
| } | ||
|
|
||
| for (final key in ['resting_hr', 'hrv', 'sleep']) { | ||
| testWidgets('$key, never recorded: still overnight', (t) async { | ||
| await _pump(t, key); | ||
| expect(find.text(_overnight), findsOneWidget); | ||
| expect(find.text(_daytime), findsNothing); | ||
| }); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Daytime metrics get overnight advice
When an empty
hrrornap_minhistory is opened,kDaytimeMetricKeysomits both keys, soMetricDetailselectsmetricDetailWearBandFixand tells users to wear the band overnight even though these metrics come from daytime bouts or sleep outside the main night.Add
hrrandnap_mintokDaytimeMetricKeys.Also at
test/metric_detail_empty_hint_test.dart:27,lib/ui2/screens/metric_detail.dart:69.Prompt for AI agents