LifeMate — Personal, Family & Learning Companion

fix/local-task-persistence
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
dart 81 lines 2.97 KB
Raw
1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart';
3 import 'package:lifemate/role_entry_main.dart';
4 import 'local_test_preferences.dart';
5
6 void main() {
7 setUp(() {
8 resetLocalPreferences();
9 });
10
11 testWidgets('first run offers exactly girl child, boy child, and adult',
12 (tester) async {
13 await tester.pumpWidget(const LifeGuideRoleTestApp());
14 await tester.pumpAndSettle();
15
16 expect(find.text('Life Guide'), findsOneWidget);
17 expect(find.text('چه کسی وارد می‌شود؟'), findsOneWidget);
18 expect(find.text('فرزند دختر'), findsOneWidget);
19 expect(find.text('فرزند پسر'), findsOneWidget);
20 expect(find.text('بزرگسال'), findsOneWidget);
21 expect(find.text('فرزند / دانش‌آموز'), findsNothing);
22 expect(find.text('مادر'), findsNothing);
23 expect(find.text('پدر'), findsNothing);
24 expect(find.text('ورود'), findsNothing);
25 });
26
27 test('local profile store persists category and edited display name',
28 () async {
29 final store = LocalTestProfileStore();
30 await store.save(const LocalTestProfile(
31 category: 'girl_minor',
32 displayName: 'آرام',
33 ));
34
35 final restored = await LocalTestProfileStore().load();
36 expect(restored?.category, 'girl_minor');
37 expect(restored?.displayName, 'آرام');
38 });
39
40 test('local profile rejects an empty display name', () async {
41 final store = LocalTestProfileStore();
42 expect(
43 () => store.save(const LocalTestProfile(
44 category: 'girl_minor',
45 displayName: ' ',
46 )),
47 throwsArgumentError,
48 );
49 });
50
51 testWidgets('named entry survives complete widget app recreation',
52 (tester) async {
53 await tester.pumpWidget(const LifeGuideRoleTestApp());
54 await tester.pumpAndSettle();
55 await tester.tap(find.text('فرزند دختر'));
56 await tester.pumpAndSettle();
57 await tester.enterText(find.byType(TextField), 'سارا');
58 await tester.tap(find.text('ادامه'));
59 await tester.pumpAndSettle();
60 expect(find.text('سارا'), findsOneWidget);
61 expect(find.text('حالت محلی · فقط روی این دستگاه'), findsOneWidget);
62 await tester.pumpWidget(const SizedBox.shrink());
63 await tester.pumpAndSettle();
64 await tester.pumpWidget(const LifeGuideRoleTestApp());
65 await tester.pumpAndSettle();
66 expect(find.text('سارا'), findsOneWidget);
67 expect(find.text('چه کسی وارد می‌شود؟'), findsNothing);
68 });
69
70 testWidgets('legacy adult selection resumes in adult space', (tester) async {
71 resetLocalPreferences({
72 'lifeguide.local_profile.category': 'adult',
73 'lifeguide.local_profile.display_name': 'داوود',
74 });
75 await tester.pumpWidget(const LifeGuideRoleTestApp());
76 await tester.pumpAndSettle();
77 expect(find.text('داوود'), findsOneWidget);
78 expect(find.text('من'), findsOneWidget);
79 expect(find.text('چه کسی وارد می‌شود؟'), findsNothing);
80 });
81 }