Fix release notification resource and add multiple advance reminders

This commit is contained in:
Codex
2026-10-14 11:30:37 +08:00
parent caf7abe0c0
commit 4d86db3dd5
16 changed files with 350 additions and 58 deletions
@@ -0,0 +1,40 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:hepan_everyday/domain/app_snapshot.dart';
import 'package:hepan_everyday/domain/app_settings.dart';
void main() {
test('changing input list cannot change saved reminder choices', () {
final choices = [5, 15];
final settings = AppSettings(reminderOffsets: choices);
choices.clear();
expect(settings.reminderOffsets, [5, 15]);
expect(() => settings.reminderOffsets.add(30), throwsUnsupportedError);
});
test('legacy single advance setting migrates to one selected time', () {
final json = AppSnapshot(settings: AppSettings(reminderMinutes: 30))
.toJson();
(json['settings'] as Map).remove('reminderOffsets');
final migrated = AppSnapshot.fromJson(json).toJson();
expect((migrated['settings'] as Map)['reminderOffsets'], [30]);
});
test('selected times are normalized and survive snapshot round trip', () {
final json = AppSnapshot().toJson();
(json['settings'] as Map)['reminderOffsets'] = [15, 5, 15];
final saved = AppSnapshot.fromJson(AppSnapshot.fromJson(json).toJson())
.toJson();
expect((saved['settings'] as Map)['reminderOffsets'], [5, 15]);
});
for (final invalid in [
[],
[0],
[7],
['15'],
[15, 90],
]) {
test('invalid selected reminder times $invalid are rejected', () {
final json = AppSnapshot().toJson();
(json['settings'] as Map)['reminderOffsets'] = invalid;
expect(() => AppSnapshot.fromJson(json), throwsFormatException);
});
}
}