LifeMate — Personal, Family & Learning Companion
fix/study-duration-display
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:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; |
| 2 | import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; |
| 3 | import 'package:flutter/services.dart'; |
| 4 | import 'package:flutter_test/flutter_test.dart'; |
| 5 | import 'package:lifemate/api.dart'; |
| 6 | import 'package:lifemate/main.dart'; |
| 7 | import 'package:shared_preferences/shared_preferences.dart'; |
| 8 | |
| 9 | class FakeApi implements IdentityApi { |
| 10 | FakeApi({this.role = 'teen_minor', this.themePreference = 'girl_pink'}); |
| 11 | final String role; |
| 12 | final String themePreference; |
| 13 | @override |
| 14 | String? accessToken; |
| 15 | @override |
| 16 | Future<void> login(String email, String password) async { |
| 17 | accessToken = 'test-token'; |
| 18 | } |
| 19 | |
| 20 | @override |
| 21 | Future<void> register( |
| 22 | {required String displayName, |
| 23 | required String email, |
| 24 | required String password}) async {} |
| 25 | @override |
| 26 | Future<void> verifyEmail(String token, {required String newPassword}) async {} |
| 27 | @override |
| 28 | Future<void> forgotPassword(String email) async {} |
| 29 | @override |
| 30 | Future<void> resetPassword(String token, String newPassword) async {} |
| 31 | @override |
| 32 | Future<void> changePassword( |
| 33 | String currentPassword, String newPassword) async {} |
| 34 | @override |
| 35 | Future<Map<String, dynamic>> getProfile() async => { |
| 36 | 'display_name': role == 'teen_minor' ? 'آرام' : 'والد', |
| 37 | 'email_normalized': 'user@example.test', |
| 38 | 'user_id': role == 'teen_minor' ? 'teen-1' : 'parent-1', |
| 39 | 'theme_preference': themePreference |
| 40 | }; |
| 41 | @override |
| 42 | Future<Map<String, dynamic>> updateProfile( |
| 43 | {String? displayName, |
| 44 | String? birthDate, |
| 45 | String? themePreference, |
| 46 | String? profileCategory}) async => |
| 47 | { |
| 48 | 'display_name': displayName ?? 'والد', |
| 49 | 'theme_preference': themePreference ?? 'adult_blue' |
| 50 | }; |
| 51 | @override |
| 52 | Future<List<Map<String, dynamic>>> listFamilies() async => [ |
| 53 | { |
| 54 | 'id': 'family-1', |
| 55 | 'name': 'خانواده', |
| 56 | 'role': role, |
| 57 | 'is_admin': role == 'parent_guardian' |
| 58 | } |
| 59 | ]; |
| 60 | @override |
| 61 | Future<List<Map<String, dynamic>>> listFamilyMembers(String familyId) async => |
| 62 | []; |
| 63 | @override |
| 64 | Future<Map<String, dynamic>> createFamily(String name, |
| 65 | {String? role}) async => |
| 66 | {'id': 'family-1', 'name': name}; |
| 67 | @override |
| 68 | Future<void> inviteMember( |
| 69 | {required String familyId, |
| 70 | required String email, |
| 71 | required String role, |
| 72 | String? themePreference, |
| 73 | String? profileCategory}) async {} |
| 74 | @override |
| 75 | Future<void> acceptInvitation(String token) async {} |
| 76 | @override |
| 77 | Future<void> setGuardian( |
| 78 | {required String familyId, |
| 79 | required String guardianUserId, |
| 80 | required String minorUserId}) async {} |
| 81 | @override |
| 82 | Future<List<Map<String, dynamic>>> getToday( |
| 83 | {required DateTime from, required DateTime to}) async => |
| 84 | []; |
| 85 | @override |
| 86 | Future<List<Map<String, dynamic>>> listPlanItems( |
| 87 | {DateTime? from, DateTime? to, String? kind}) async => |
| 88 | []; |
| 89 | @override |
| 90 | Future<Map<String, dynamic>> createPlanItem( |
| 91 | Map<String, dynamic> data) async => |
| 92 | {'id': 'new-plan', ...data}; |
| 93 | @override |
| 94 | Future<Map<String, dynamic>> updatePlanItem( |
| 95 | String itemId, Map<String, dynamic> data) async => |
| 96 | {'id': itemId, ...data}; |
| 97 | @override |
| 98 | Future<List<Map<String, dynamic>>> listLifeContexts() async => []; |
| 99 | @override |
| 100 | Future<Map<String, dynamic>> createLifeContext( |
| 101 | {required String kind, required String title}) async => |
| 102 | {'id': 'ctx-1', 'kind': kind, 'title': title}; |
| 103 | @override |
| 104 | Future<Map<String, dynamic>> createAcademicYear( |
| 105 | Map<String, dynamic> data) async => |
| 106 | {'id': 'year-1', ...data}; |
| 107 | @override |
| 108 | Future<Map<String, dynamic>> createAcademicTerm( |
| 109 | String yearId, Map<String, dynamic> data) async => |
| 110 | {'id': 'term-1', ...data}; |
| 111 | @override |
| 112 | Future<Map<String, dynamic>> createSubject( |
| 113 | String termId, Map<String, dynamic> data) async => |
| 114 | {'id': 'subject-1', ...data}; |
| 115 | @override |
| 116 | Future<Map<String, dynamic>> createClassSession( |
| 117 | String subjectId, Map<String, dynamic> data) async => |
| 118 | {'id': 'class-1', ...data}; |
| 119 | @override |
| 120 | Future<Map<String, dynamic>> setGrade(String itemId, |
| 121 | {required num points, required num outOf}) async => |
| 122 | {'id': itemId}; |
| 123 | @override |
| 124 | Future<List<Map<String, dynamic>>> claimDueReminders() async => []; |
| 125 | @override |
| 126 | Future<Map<String, dynamic>> getSchoolOverview(String studentUserId) async => |
| 127 | {'years': [], 'subjects': [], 'workload': [], 'grades': []}; |
| 128 | @override |
| 129 | Future<List<Map<String, dynamic>>> getTimetable(String studentUserId) async => |
| 130 | []; |
| 131 | @override |
| 132 | Future<List<Map<String, dynamic>>> getFamilyCalendar(String familyId) async => |
| 133 | []; |
| 134 | @override |
| 135 | Future<Map<String, dynamic>> getChildSupportSummary( |
| 136 | String familyId, String studentUserId) async => |
| 137 | {'upcoming': [], 'metrics': {}}; |
| 138 | @override |
| 139 | Future<Map<String, dynamic>> submitSyncMutations( |
| 140 | List<Map<String, dynamic>> mutations) async => |
| 141 | {'results': []}; |
| 142 | @override |
| 143 | Future<Map<String, dynamic>> createLearningGoal( |
| 144 | {required String title, String? target, String? subjectId}) async => |
| 145 | {'id': 'goal-1', 'title': title}; |
| 146 | @override |
| 147 | Future<List<Map<String, dynamic>>> listLearningGoals() async => []; |
| 148 | @override |
| 149 | Future<Map<String, dynamic>> createLearningCheckin( |
| 150 | {String? learningGoalId, |
| 151 | required int confidence, |
| 152 | required int difficulty, |
| 153 | String? note}) async => |
| 154 | {'id': 'checkin-1'}; |
| 155 | @override |
| 156 | Future<Map<String, dynamic>> createWellbeingCheckin( |
| 157 | {required int mood, |
| 158 | required int energy, |
| 159 | required int stress, |
| 160 | String? note, |
| 161 | String visibility = 'private'}) async => |
| 162 | {'id': 'wellbeing-1'}; |
| 163 | @override |
| 164 | Future<List<Map<String, dynamic>>> listWellbeingCheckins() async => []; |
| 165 | @override |
| 166 | Future<Map<String, dynamic>> createAiSession(String kind) async => |
| 167 | {'id': 'session-1'}; |
| 168 | @override |
| 169 | Future<Map<String, dynamic>> sendAiMessage( |
| 170 | String sessionId, String message) async => |
| 171 | {'id': 'message-1', 'body': 'پاسخ آزمایشی همراه هوشمند'}; |
| 172 | @override |
| 173 | Future<Map<String, dynamic>> getGuardianWellbeingSummary( |
| 174 | String familyId, String minorUserId) async => |
| 175 | { |
| 176 | 'summary': {}, |
| 177 | 'safety': {}, |
| 178 | 'rawNotesIncluded': false, |
| 179 | 'rawConversationIncluded': false |
| 180 | }; |
| 181 | @override |
| 182 | Future<Map<String, dynamic>> requestFamilyGuidance( |
| 183 | String familyId, String minorUserId, String question) async => |
| 184 | { |
| 185 | 'advice': 'پیشنهاد آزمایشی', |
| 186 | 'advisory': true, |
| 187 | 'medicalDiagnosis': false |
| 188 | }; |
| 189 | } |
| 190 | |
| 191 | void main() { |
| 192 | setUp(() { |
| 193 | SharedPreferences.setMockInitialValues({}); |
| 194 | SharedPreferencesAsyncPlatform.instance = |
| 195 | InMemorySharedPreferencesAsync.withData({}); |
| 196 | String? pending; |
| 197 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger |
| 198 | .setMockMethodCallHandler( |
| 199 | const MethodChannel('lifeguide/local_write_guard'), (call) async { |
| 200 | if (call.method == 'getBlocked') return pending != null; |
| 201 | if (call.method == 'beginWrite') return pending = 'owned-ui-test-token'; |
| 202 | if (call.method == 'completeWrite' && call.arguments == pending) { |
| 203 | pending = null; |
| 204 | return true; |
| 205 | } |
| 206 | throw PlatformException(code: 'local_storage_restart_required'); |
| 207 | }); |
| 208 | }); |
| 209 | |
| 210 | testWidgets('starts in Persian RTL with identity actions', (tester) async { |
| 211 | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
| 212 | expect(find.text('LifeGuide'), findsOneWidget); |
| 213 | expect(find.text('ورود'), findsOneWidget); |
| 214 | expect(find.text('رمز عبور را فراموش کردهام'), findsOneWidget); |
| 215 | }); |
| 216 | |
| 217 | testWidgets('registration explains 10-character password requirement', |
| 218 | (tester) async { |
| 219 | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
| 220 | await tester.tap(find.text('ساخت حساب جدید')); |
| 221 | await tester.pumpAndSettle(); |
| 222 | expect(find.text('حداقل ۱۰ کاراکتر'), findsOneWidget); |
| 223 | }); |
| 224 | } |