|
...
|
...
|
@@ -153,8 +153,7 @@ void main() { |
|
|
|
expect(notifications.single.recordTime, latestTime);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('builds hrv notifications for every candidate including sleep likely',
|
|
|
|
() {
|
|
|
|
test('builds only the latest hrv notification for multiple candidates', () {
|
|
|
|
final firstTime = _seconds(DateTime(2026, 1, 1, 9));
|
|
|
|
final secondTime = _seconds(DateTime(2026, 1, 1, 10));
|
|
|
|
final notifications = builder.build(
|
|
...
|
...
|
@@ -173,8 +172,55 @@ void main() { |
|
|
|
record: const HealthRawLocalNotificationRecord(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(notifications, hasLength(1));
|
|
|
|
expect(notifications.single.recordType,
|
|
|
|
HealthRawLocalNotificationRecordType.hrv);
|
|
|
|
expect(notifications.single.recordTime, secondTime);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('keeps the latest notification per type without dropping other types',
|
|
|
|
() {
|
|
|
|
final hrvFirstTime = _seconds(DateTime(2026, 1, 1, 9));
|
|
|
|
final hrvSecondTime = _seconds(DateTime(2026, 1, 1, 10));
|
|
|
|
final realtimeBase = _seconds(DateTime(2026, 1, 1, 11));
|
|
|
|
final notifications = builder.build(
|
|
|
|
result: HealthRawStressCalculationResult(
|
|
|
|
userId: 1,
|
|
|
|
hrvStressPoints: [
|
|
|
|
_hrvPoint(hrvFirstTime),
|
|
|
|
_hrvPoint(hrvSecondTime),
|
|
|
|
],
|
|
|
|
realtimeStressPoints: [
|
|
|
|
_realtimePoint(realtimeBase + 9 * 300, 70),
|
|
|
|
],
|
|
|
|
dailyStressPoints: const [],
|
|
|
|
),
|
|
|
|
hasExistingHrv: true,
|
|
|
|
hasExistingSleep: false,
|
|
|
|
realtimeWindow: [
|
|
|
|
for (var i = 0; i < 10; i++) _realtimePoint(realtimeBase + i * 300, 70),
|
|
|
|
],
|
|
|
|
record: const HealthRawLocalNotificationRecord(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(notifications, hasLength(2));
|
|
|
|
expect(notifications.map((e) => e.recordTime), [firstTime, secondTime]);
|
|
|
|
expect(
|
|
|
|
notifications
|
|
|
|
.where(
|
|
|
|
(e) => e.recordType == HealthRawLocalNotificationRecordType.hrv)
|
|
|
|
.single
|
|
|
|
.recordTime,
|
|
|
|
hrvSecondTime,
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
notifications
|
|
|
|
.where((e) =>
|
|
|
|
e.recordType ==
|
|
|
|
HealthRawLocalNotificationRecordType.realtimeStress)
|
|
|
|
.single
|
|
|
|
.recordTime,
|
|
|
|
realtimeBase + 9 * 300,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('builds realtime stress notification from latest 60 minute window', () {
|
...
|
...
|
|