LifeMate — Personal, Family & Learning Companion
feat/weekly-planner-android
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/services.dart'; |
| 3 | import 'package:flutter_test/flutter_test.dart'; |
| 4 | import 'package:lifemate/main.dart'; |
| 5 | import 'package:lifemate/api.dart'; |
| 6 | import 'package:lifemate/phase3_ui.dart'; |
| 7 | import 'package:lifemate/education_ui.dart'; |
| 8 | import 'package:lifemate/study_ui.dart'; |
| 9 | import 'package:lifemate/dashboard_ui.dart'; |
| 10 | import 'package:shared_preferences/shared_preferences.dart'; |
| 11 | import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; |
| 12 | import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; |
| 13 | |
| 14 | import 'app_test.dart' show FakeApi; |
| 15 | |
| 16 | class MenuApi extends FakeApi { |
| 17 | MenuApi({this.category = 'girl_minor'}); |
| 18 | final String category; |
| 19 | bool failProfile = false; |
| 20 | bool offlineProfile = false; |
| 21 | @override |
| 22 | Future<Map<String, dynamic>> getProfile() async { |
| 23 | if (offlineProfile) throw const ApiException(0, 'network_unavailable'); |
| 24 | if (failProfile) throw const ApiException(503, 'profile_unavailable'); |
| 25 | return { |
| 26 | 'user_id': 'synthetic-menu-user', |
| 27 | 'display_name': 'کاربر نمونه', |
| 28 | 'profile_category': category, |
| 29 | 'theme_preference': 'adult_blue', |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | @override |
| 34 | Future<List<Map<String, dynamic>>> listFamilies() async => []; |
| 35 | } |
| 36 | |
| 37 | void main() { |
| 38 | TestWidgetsFlutterBinding.ensureInitialized(); |
| 39 | setUpAll(() async { |
| 40 | final fonts = FontLoader('LifeGuidePersian') |
| 41 | ..addFont(rootBundle.load('assets/fonts/LifeGuidePersian.ttf')); |
| 42 | await fonts.load(); |
| 43 | WidgetController.hitTestWarningShouldBeFatal = true; |
| 44 | }); |
| 45 | |
| 46 | setUp(() { |
| 47 | String? token; |
| 48 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger |
| 49 | .setMockMethodCallHandler( |
| 50 | const MethodChannel('lifeguide/local_write_guard'), (call) async { |
| 51 | if (call.method == 'getBlocked') return token != null; |
| 52 | if (call.method == 'beginWrite') return token = 'synthetic-menu-write'; |
| 53 | if (call.method == 'completeWrite' && call.arguments == token) { |
| 54 | token = null; |
| 55 | return true; |
| 56 | } |
| 57 | throw PlatformException(code: 'local_storage_restart_required'); |
| 58 | }); |
| 59 | SharedPreferences.setMockInitialValues({}); |
| 60 | SharedPreferencesAsyncPlatform.instance = |
| 61 | InMemorySharedPreferencesAsync.withData({}); |
| 62 | }); |
| 63 | Future<void> shell(WidgetTester tester, MenuApi api) async { |
| 64 | await tester.pumpWidget(MaterialApp( |
| 65 | theme: ThemeData(fontFamily: 'LifeGuidePersian'), |
| 66 | home: Directionality( |
| 67 | textDirection: TextDirection.rtl, child: HomeShell(api: api)))); |
| 68 | await tester.pumpAndSettle(); |
| 69 | } |
| 70 | |
| 71 | for (final size in [const Size(390, 844), const Size(320, 740)]) { |
| 72 | testWidgets( |
| 73 | 'today home and bottom destinations open separate pages at $size', |
| 74 | (tester) async { |
| 75 | tester.view.physicalSize = size; |
| 76 | tester.view.devicePixelRatio = 1; |
| 77 | addTearDown(tester.view.resetPhysicalSize); |
| 78 | addTearDown(tester.view.resetDevicePixelRatio); |
| 79 | await shell(tester, MenuApi()); |
| 80 | expect(find.textContaining('کاربر نمونه'), findsOneWidget); |
| 81 | expect(find.text('قدم بعدی'), findsOneWidget); |
| 82 | for (final entry in { |
| 83 | 'برنامه': PlannerPage, |
| 84 | 'درسها': EducationLibraryPage, |
| 85 | 'تمرکز': StudyHub, |
| 86 | 'خانواده': ProfileFamilyPage |
| 87 | }.entries) { |
| 88 | final menu = find.descendant( |
| 89 | of: find.byType(NavigationBar), matching: find.text(entry.key)); |
| 90 | expect(menu.hitTestable(), findsOneWidget); |
| 91 | await tester.tap(menu); |
| 92 | await tester.pumpAndSettle(); |
| 93 | expect(find.byType(entry.value), findsOneWidget); |
| 94 | expect(find.byKey(const ValueKey('home-plan')), findsNothing); |
| 95 | await tester.tap(find.byTooltip('برگشت به خانه')); |
| 96 | await tester.pumpAndSettle(); |
| 97 | expect(find.byKey(const ValueKey('home-plan')), findsOneWidget); |
| 98 | } |
| 99 | await tester.tap(find.byTooltip('یادآوریها')); |
| 100 | await tester.pumpAndSettle(); |
| 101 | expect(find.byKey(const ValueKey('home-plan')), findsNothing); |
| 102 | await tester.tap(find.byTooltip('برگشت به خانه')); |
| 103 | await tester.pumpAndSettle(); |
| 104 | expect(tester.takeException(), isNull); |
| 105 | await tester.pumpWidget(const SizedBox()); |
| 106 | }); |
| 107 | } |
| 108 | testWidgets('large text remains reachable without layout overflow', |
| 109 | (tester) async { |
| 110 | tester.view.physicalSize = const Size(320, 740); |
| 111 | tester.view.devicePixelRatio = 1; |
| 112 | addTearDown(tester.view.resetPhysicalSize); |
| 113 | addTearDown(tester.view.resetDevicePixelRatio); |
| 114 | await tester.pumpWidget(MaterialApp( |
| 115 | theme: ThemeData(fontFamily: 'LifeGuidePersian'), |
| 116 | home: MediaQuery( |
| 117 | data: const MediaQueryData( |
| 118 | size: Size(320, 740), textScaler: TextScaler.linear(1.6)), |
| 119 | child: Directionality( |
| 120 | textDirection: TextDirection.rtl, |
| 121 | child: HomeShell(api: MenuApi()))))); |
| 122 | await tester.pumpAndSettle(); |
| 123 | await tester.scrollUntilVisible( |
| 124 | find.byKey(const ValueKey('home-plan')), 150); |
| 125 | expect( |
| 126 | find.byKey(const ValueKey('home-plan')).hitTestable(), findsOneWidget); |
| 127 | expect(tester.takeException(), isNull); |
| 128 | await tester.pumpWidget(const SizedBox()); |
| 129 | }); |
| 130 | testWidgets( |
| 131 | 'adult home does not depend on family membership or grant parent access', |
| 132 | (tester) async { |
| 133 | await shell(tester, MenuApi(category: 'adult')); |
| 134 | expect(find.byKey(const ValueKey('home-family')), findsOneWidget); |
| 135 | expect(find.byKey(const ValueKey('home-report')), findsOneWidget); |
| 136 | expect(find.byKey(const ValueKey('home-courses')), findsNothing); |
| 137 | await tester.tap(find.byKey(const ValueKey('home-report'))); |
| 138 | await tester.pumpAndSettle(); |
| 139 | expect(find.byType(ParentFamilyDashboard), findsOneWidget); |
| 140 | expect(find.byType(LearningReportPage), findsNothing); |
| 141 | await tester.pumpWidget(const SizedBox()); |
| 142 | }); |
| 143 | testWidgets( |
| 144 | 'same-account offline profile refresh preserves cached planner access', |
| 145 | (tester) async { |
| 146 | final api = MenuApi(); |
| 147 | await shell(tester, api); |
| 148 | await tester.tap(find.descendant( |
| 149 | of: find.byType(NavigationBar), matching: find.text('خانواده'))); |
| 150 | await tester.pumpAndSettle(); |
| 151 | api.offlineProfile = true; |
| 152 | await tester.tap(find.byTooltip('برگشت به خانه')); |
| 153 | await tester.pumpAndSettle(); |
| 154 | expect( |
| 155 | find.byKey(const ValueKey('home-plan')).hitTestable(), findsOneWidget); |
| 156 | await tester.tap(find.byKey(const ValueKey('home-plan'))); |
| 157 | await tester.pumpAndSettle(); |
| 158 | expect(find.byType(PlannerPage), findsOneWidget); |
| 159 | await tester.pumpWidget(const SizedBox()); |
| 160 | }); |
| 161 | testWidgets( |
| 162 | 'profile failure does not guess a child or parent home and can retry', |
| 163 | (tester) async { |
| 164 | final api = MenuApi()..failProfile = true; |
| 165 | await shell(tester, api); |
| 166 | expect(find.byKey(const ValueKey('home-plan')), findsNothing); |
| 167 | api.failProfile = false; |
| 168 | await tester.tap(find.text('تلاش دوباره').first); |
| 169 | await tester.pumpAndSettle(); |
| 170 | expect(find.byKey(const ValueKey('home-plan')), findsOneWidget); |
| 171 | await tester.pumpWidget(const SizedBox()); |
| 172 | }); |
| 173 | } |