Fix cached reminder recovery and retain pre-reconcile idle diagnostics

This commit is contained in:
david1465833828
2026-10-28 17:46:33 +08:00
parent 93bcfd534c
commit dc71e411e9
13 changed files with 350 additions and 6 deletions
@@ -7,6 +7,39 @@ import 'package:hepan_everyday/services/local_notification_service.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test(
'system handle audit only accepts IDs from the requested cache',
() async {
const system = MethodChannel('com.tpschedule.app/reminders');
final messenger =
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
messenger.setMockMethodCallHandler(system, (call) async {
expect(call.method, 'findMissingAlarmHandles');
expect((call.arguments as List).toSet(), {11, 22});
return [22, 999];
});
addTearDown(() => messenger.setMockMethodCallHandler(system, null));
expect(await PluginReminderGateway().missingSystemIds({11, 22}), {22});
},
);
test(
'optional handle audit failure does not prevent reconciliation',
() async {
const system = MethodChannel('com.tpschedule.app/reminders');
final messenger =
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
var calls = 0;
messenger.setMockMethodCallHandler(system, (_) async {
calls++;
throw PlatformException(code: 'reminder_system_unavailable');
});
addTearDown(() => messenger.setMockMethodCallHandler(system, null));
final gateway = PluginReminderGateway();
expect(await gateway.missingSystemIds({11}), isEmpty);
expect(await gateway.missingSystemIds({}), isEmpty);
expect(calls, 1);
},
);
test('fresh notification initialization creates the course category before checks', () async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
AndroidFlutterLocalNotificationsPlugin.registerWith();