LifeMate — Personal, Family & Learning Companion
fix/personal-notification-controls
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_localizations/flutter_localizations.dart'; |
| 3 | import 'package:flutter_test/flutter_test.dart'; |
| 4 | import 'package:lifemate/standalone/personal_date_picker.dart'; |
| 5 | |
| 6 | void main() { |
| 7 | Future<void> choose(WidgetTester tester, String field, String text, |
| 8 | {double delta = -180}) async { |
| 9 | final input = find.byKey(ValueKey('personal-date-$field')); |
| 10 | await tester.ensureVisible(input); |
| 11 | await tester.tap(input); |
| 12 | await tester.pumpAndSettle(); |
| 13 | final option = find.text(text); |
| 14 | if (option.evaluate().isEmpty) { |
| 15 | await tester.scrollUntilVisible(option, delta, |
| 16 | scrollable: find.byType(Scrollable).last, maxScrolls: 100); |
| 17 | } |
| 18 | await tester.ensureVisible(option.last); |
| 19 | await tester.tap(option.last); |
| 20 | await tester.pumpAndSettle(); |
| 21 | } |
| 22 | |
| 23 | Future<void> launch( |
| 24 | WidgetTester tester, DateTime initial, ValueChanged<DateTime?> result, |
| 25 | {DateTime? first, DateTime? last}) async { |
| 26 | await tester.pumpWidget(MaterialApp( |
| 27 | locale: const Locale('fa'), |
| 28 | supportedLocales: const [Locale('fa')], |
| 29 | localizationsDelegates: const [ |
| 30 | GlobalMaterialLocalizations.delegate, |
| 31 | GlobalWidgetsLocalizations.delegate, |
| 32 | GlobalCupertinoLocalizations.delegate, |
| 33 | ], |
| 34 | home: Builder( |
| 35 | builder: (context) => Scaffold( |
| 36 | body: FilledButton( |
| 37 | onPressed: () async => result(await showPersonalDatePicker( |
| 38 | context: context, |
| 39 | initialDate: initial, |
| 40 | firstDate: first ?? DateTime(2020), |
| 41 | lastDate: last ?? DateTime(2100))), |
| 42 | child: const Text('باز کردن')))), |
| 43 | )); |
| 44 | await tester.tap(find.text('باز کردن')); |
| 45 | await tester.pumpAndSettle(); |
| 46 | } |
| 47 | |
| 48 | Future<void> confirm(WidgetTester tester) async { |
| 49 | await tester.tap(find.text('انتخاب تاریخ')); |
| 50 | await tester.pumpAndSettle(); |
| 51 | } |
| 52 | |
| 53 | testWidgets('leap Esfand day30 becomes29 when year changes to nonleap', |
| 54 | (tester) async { |
| 55 | DateTime? selected; |
| 56 | await launch(tester, DateTime(2025, 3, 20), (value) => selected = value); |
| 57 | expect(find.text('۳۰ اسفند ۱۴۰۳ شمسی'), findsOneWidget); |
| 58 | await choose(tester, 'year', '۱۴۰۴'); |
| 59 | expect(find.text('۲۹ اسفند ۱۴۰۴ شمسی'), findsOneWidget); |
| 60 | await confirm(tester); |
| 61 | expect(selected, DateTime(2026, 3, 20)); |
| 62 | expect(selected!.isUtc, isFalse); |
| 63 | expect(tester.takeException(), isNull); |
| 64 | }); |
| 65 | |
| 66 | testWidgets('day31 changes to30 in a thirty-day Persian month', |
| 67 | (tester) async { |
| 68 | DateTime? selected; |
| 69 | await launch(tester, DateTime(2026, 9, 22), (value) => selected = value); |
| 70 | expect(find.text('۳۱ شهریور ۱۴۰۵ شمسی'), findsOneWidget); |
| 71 | await choose(tester, 'month', 'مهر', delta: 180); |
| 72 | expect(find.text('۳۰ مهر ۱۴۰۵ شمسی'), findsOneWidget); |
| 73 | await confirm(tester); |
| 74 | expect(selected, DateTime(2026, 10, 22)); |
| 75 | expect(tester.takeException(), isNull); |
| 76 | }); |
| 77 | |
| 78 | testWidgets('partial first and last month bounds remain inclusive', |
| 79 | (tester) async { |
| 80 | DateTime? selected; |
| 81 | await launch(tester, DateTime(2025, 1, 1), (value) => selected = value, |
| 82 | first: DateTime(2025, 1, 1), last: DateTime(2025, 1, 2)); |
| 83 | expect(find.text('۱۲ دی ۱۴۰۳ شمسی'), findsOneWidget); |
| 84 | await choose(tester, 'day', '۱۳', delta: 180); |
| 85 | await confirm(tester); |
| 86 | expect(selected, DateTime(2025, 1, 2)); |
| 87 | expect(tester.takeException(), isNull); |
| 88 | }); |
| 89 | |
| 90 | testWidgets( |
| 91 | 'existing2020to2100 bounds clamp initial dates without leaving range', |
| 92 | (tester) async { |
| 93 | for (final pair in [ |
| 94 | (DateTime(2019, 12, 31), DateTime(2020)), |
| 95 | (DateTime(2100, 1, 2), DateTime(2100)), |
| 96 | ]) { |
| 97 | DateTime? selected; |
| 98 | await launch(tester, pair.$1, (value) => selected = value); |
| 99 | await confirm(tester); |
| 100 | expect(selected, pair.$2); |
| 101 | expect(tester.takeException(), isNull); |
| 102 | await tester.pumpWidget(const SizedBox()); |
| 103 | } |
| 104 | }); |
| 105 | } |