LifeMate — Personal, Family & Learning Companion
docs/offline-data-rescue-options
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | import 'package:flutter/foundation.dart'; |
| 2 | import 'package:flutter/services.dart'; |
| 3 | import 'package:flutter_test/flutter_test.dart'; |
| 4 | import '../tool/native_reminder_fixture.dart' as fixture; |
| 5 | |
| 6 | void main() { |
| 7 | TestWidgetsFlutterBinding.ensureInitialized(); |
| 8 | const channel = MethodChannel('lifeguide/local_reminders'); |
| 9 | final calls = <MethodCall>[]; |
| 10 | final now = DateTime.utc(2026, 10, 19, 8); |
| 11 | setUp(() { |
| 12 | debugDefaultTargetPlatformOverride = TargetPlatform.android; |
| 13 | calls.clear(); |
| 14 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger |
| 15 | .setMockMethodCallHandler(channel, (call) async { |
| 16 | calls.add(call); |
| 17 | if (call.method == 'status') { |
| 18 | return { |
| 19 | 'supported': true, |
| 20 | 'permissionGranted': true, |
| 21 | 'active': true, |
| 22 | 'activeScope': fixture.scope, |
| 23 | 'scheduledCount': 1, |
| 24 | 'timing': 'exact', |
| 25 | 'canScheduleExactAlarms': true |
| 26 | }; |
| 27 | } |
| 28 | return true; |
| 29 | }); |
| 30 | }); |
| 31 | tearDown(() { |
| 32 | debugDefaultTargetPlatformOverride = null; |
| 33 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger |
| 34 | .setMockMethodCallHandler(channel, null); |
| 35 | }); |
| 36 | test('disabled and non-Android fixtures never reach native storage', |
| 37 | () async { |
| 38 | for (final flags in [ |
| 39 | (false, true, true), |
| 40 | (true, false, true), |
| 41 | (true, true, false) |
| 42 | ]) { |
| 43 | await expectLater( |
| 44 | fixture.runFixture('/schedule?nonce=0123456789abcdef&delay=45', |
| 45 | enabled: flags.$1, |
| 46 | debug: flags.$2, |
| 47 | android: flags.$3, |
| 48 | now: () => now), |
| 49 | throwsStateError); |
| 50 | expect(calls, isEmpty); |
| 51 | } |
| 52 | }); |
| 53 | test('unknown commands and malformed metadata fail before channel access', |
| 54 | () async { |
| 55 | for (final route in [ |
| 56 | '/', |
| 57 | '/other?nonce=01234567', |
| 58 | '/schedule?nonce=bad&delay=45', |
| 59 | '/schedule?nonce=01234567&delay=0', |
| 60 | '/schedule?nonce=01234567&delay=999', |
| 61 | '/inspect?nonce=01234567&owner=private', |
| 62 | '/inspect?nonce=01234567&nonce=abcdef01', |
| 63 | 'https://example.invalid/inspect?nonce=01234567' |
| 64 | ]) { |
| 65 | await expectLater( |
| 66 | fixture.runFixture(route, |
| 67 | enabled: true, debug: true, android: true, now: () => now), |
| 68 | throwsArgumentError); |
| 69 | expect(calls, isEmpty); |
| 70 | } |
| 71 | }); |
| 72 | test('schedule uses production port with only synthetic opaque metadata', |
| 73 | () async { |
| 74 | final result = await fixture.runFixture( |
| 75 | '/schedule?nonce=0123456789abcdef&delay=45', |
| 76 | enabled: true, |
| 77 | debug: true, |
| 78 | android: true, |
| 79 | now: () => now); |
| 80 | expect(calls.map((c) => c.method), |
| 81 | ['status', 'deactivate', 'activate', 'replace', 'status']); |
| 82 | final payload = |
| 83 | calls.singleWhere((c) => c.method == 'replace').arguments as Map; |
| 84 | expect(payload['scope'], fixture.scope); |
| 85 | expect(payload['reminders'], [ |
| 86 | { |
| 87 | 'id': fixture.reminder, |
| 88 | 'planItemId': fixture.plan, |
| 89 | 'scheduledAtEpochMs': |
| 90 | now.add(const Duration(seconds: 45)).millisecondsSinceEpoch, |
| 91 | 'companionName': fixture.companion |
| 92 | } |
| 93 | ]); |
| 94 | expect(result['simulatedServerAcknowledgement'], isTrue); |
| 95 | expect(result['mode'], 'schedule'); |
| 96 | expect(result.toString(), isNot(contains('SYNTHETIC_PRIVATE_TASK_CANARY'))); |
| 97 | }); |
| 98 | test('inspect after restart reads without resetting persisted generation', |
| 99 | () async { |
| 100 | await fixture.runFixture('/inspect?nonce=0123456789abcdef', |
| 101 | enabled: true, debug: true, android: true, now: () => now); |
| 102 | expect(calls.map((c) => c.method), ['status']); |
| 103 | }); |
| 104 | test('suppression and off do not reactivate a previous fixture', () async { |
| 105 | await fixture.runFixture('/suppress?nonce=0123456789abcdef', |
| 106 | enabled: true, debug: true, android: true, now: () => now); |
| 107 | expect(calls.map((c) => c.method), ['suppressPlanItems', 'status']); |
| 108 | calls.clear(); |
| 109 | await fixture.runFixture('/off?nonce=0123456789abcdef', |
| 110 | enabled: true, debug: true, android: true, now: () => now); |
| 111 | expect(calls.map((c) => c.method), ['deactivate', 'status']); |
| 112 | }); |
| 113 | } |