LifeMate — Personal, Family & Learning Companion
phase-2/product-foundation-identity
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/material.dart'; |
| 2 | import 'package:flutter_test/flutter_test.dart'; |
| 3 | import 'package:lifemate/api.dart'; |
| 4 | import 'package:lifemate/main.dart'; |
| 5 | |
| 6 | class FakeApi implements IdentityApi { |
| 7 | FakeApi({ |
| 8 | this.role = 'teen_minor', |
| 9 | this.themePreference = 'girl_pink', |
| 10 | }); |
| 11 | |
| 12 | final String role; |
| 13 | final String themePreference; |
| 14 | |
| 15 | @override |
| 16 | String? accessToken; |
| 17 | |
| 18 | @override |
| 19 | Future<void> login(String email, String password) async { |
| 20 | accessToken = 'test-token'; |
| 21 | } |
| 22 | |
| 23 | @override |
| 24 | Future<void> register({ |
| 25 | required String displayName, |
| 26 | required String email, |
| 27 | required String password, |
| 28 | }) async {} |
| 29 | |
| 30 | @override |
| 31 | Future<void> verifyEmail(String token) async {} |
| 32 | |
| 33 | @override |
| 34 | Future<void> forgotPassword(String email) async {} |
| 35 | |
| 36 | @override |
| 37 | Future<void> resetPassword(String token, String newPassword) async {} |
| 38 | |
| 39 | @override |
| 40 | Future<void> changePassword( |
| 41 | String currentPassword, |
| 42 | String newPassword, |
| 43 | ) async {} |
| 44 | |
| 45 | @override |
| 46 | Future<Map<String, dynamic>> getProfile() async => { |
| 47 | 'display_name': role == 'teen_minor' ? 'آرام' : 'والد', |
| 48 | 'email_normalized': 'user@example.test', |
| 49 | 'theme_preference': themePreference, |
| 50 | }; |
| 51 | |
| 52 | @override |
| 53 | Future<Map<String, dynamic>> updateProfile({ |
| 54 | String? displayName, |
| 55 | String? birthDate, |
| 56 | String? themePreference, |
| 57 | }) async => |
| 58 | { |
| 59 | 'display_name': displayName ?? 'والد', |
| 60 | 'theme_preference': themePreference ?? 'adult_blue', |
| 61 | }; |
| 62 | |
| 63 | @override |
| 64 | Future<List<Map<String, dynamic>>> listFamilies() async => [ |
| 65 | { |
| 66 | 'id': 'family-1', |
| 67 | 'name': 'خانواده', |
| 68 | 'role': role, |
| 69 | 'is_admin': role == 'parent_guardian', |
| 70 | } |
| 71 | ]; |
| 72 | |
| 73 | @override |
| 74 | Future<List<Map<String, dynamic>>> listFamilyMembers(String familyId) async => |
| 75 | []; |
| 76 | |
| 77 | @override |
| 78 | Future<Map<String, dynamic>> createFamily( |
| 79 | String name, { |
| 80 | String? role, |
| 81 | }) async => |
| 82 | {'id': 'family-1', 'name': name}; |
| 83 | |
| 84 | @override |
| 85 | Future<void> inviteMember({ |
| 86 | required String familyId, |
| 87 | required String email, |
| 88 | required String role, |
| 89 | String? themePreference, |
| 90 | }) async {} |
| 91 | |
| 92 | @override |
| 93 | Future<void> acceptInvitation(String token) async {} |
| 94 | |
| 95 | @override |
| 96 | Future<void> setGuardian({ |
| 97 | required String familyId, |
| 98 | required String guardianUserId, |
| 99 | required String minorUserId, |
| 100 | }) async {} |
| 101 | } |
| 102 | |
| 103 | void main() { |
| 104 | testWidgets('starts in Persian RTL with identity actions', (tester) async { |
| 105 | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
| 106 | |
| 107 | expect(find.text('LifeMate'), findsOneWidget); |
| 108 | expect(find.text('ورود'), findsOneWidget); |
| 109 | expect(find.text('رمز عبور را فراموش کردهام'), findsOneWidget); |
| 110 | |
| 111 | final directionality = |
| 112 | tester.widget<Directionality>(find.byType(Directionality).last); |
| 113 | expect(directionality.textDirection, TextDirection.rtl); |
| 114 | }); |
| 115 | |
| 116 | testWidgets('opens recovery flow', (tester) async { |
| 117 | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
| 118 | |
| 119 | await tester.tap(find.text('رمز عبور را فراموش کردهام')); |
| 120 | await tester.pumpAndSettle(); |
| 121 | |
| 122 | expect(find.text('بازیابی رمز عبور'), findsOneWidget); |
| 123 | expect(find.text('ارسال لینک بازیابی'), findsOneWidget); |
| 124 | }); |
| 125 | |
| 126 | testWidgets('teen login opens MyStudyLife-inspired student shell', |
| 127 | (tester) async { |
| 128 | await tester.pumpWidget( |
| 129 | LifeMateApp( |
| 130 | api: FakeApi(role: 'teen_minor', themePreference: 'girl_pink'), |
| 131 | ), |
| 132 | ); |
| 133 | |
| 134 | await tester.enterText( |
| 135 | find.widgetWithText(TextField, 'ایمیل'), |
| 136 | 'parent@example.test', |
| 137 | ); |
| 138 | await tester.enterText( |
| 139 | find.widgetWithText(TextField, 'رمز عبور'), |
| 140 | 'StrongPass!123', |
| 141 | ); |
| 142 | await tester.tap(find.text('ورود')); |
| 143 | await tester.pumpAndSettle(); |
| 144 | |
| 145 | expect(find.text('امروز'), findsWidgets); |
| 146 | expect(find.text('برنامه'), findsOneWidget); |
| 147 | expect(find.text('تقویم'), findsOneWidget); |
| 148 | expect(find.text('کارها'), findsOneWidget); |
| 149 | expect(find.text('امتحانها'), findsOneWidget); |
| 150 | }); |
| 151 | |
| 152 | testWidgets('parent login opens parent-focused family shell', (tester) async { |
| 153 | await tester.pumpWidget( |
| 154 | LifeMateApp( |
| 155 | api: FakeApi( |
| 156 | role: 'parent_guardian', |
| 157 | themePreference: 'adult_blue', |
| 158 | ), |
| 159 | ), |
| 160 | ); |
| 161 | |
| 162 | await tester.enterText( |
| 163 | find.widgetWithText(TextField, 'ایمیل'), |
| 164 | 'parent@example.test', |
| 165 | ); |
| 166 | await tester.enterText( |
| 167 | find.widgetWithText(TextField, 'رمز عبور'), |
| 168 | 'StrongPass!123', |
| 169 | ); |
| 170 | await tester.tap(find.text('ورود')); |
| 171 | await tester.pumpAndSettle(); |
| 172 | |
| 173 | expect(find.text('امروز'), findsWidgets); |
| 174 | expect(find.text('برنامهریز'), findsOneWidget); |
| 175 | expect(find.text('خانواده'), findsOneWidget); |
| 176 | expect(find.text('راهنما'), findsOneWidget); |
| 177 | expect(find.text('من'), findsOneWidget); |
| 178 | expect(find.text('امتحانها'), findsNothing); |
| 179 | }); |
| 180 | } |