LifeMate — Personal, Family & Learning Companion
infra/lifeguide-supabase-qa
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 'dart:convert'; |
| 2 | import 'package:flutter_test/flutter_test.dart'; |
| 3 | import 'package:http/http.dart' as http; |
| 4 | import 'package:http/testing.dart'; |
| 5 | import 'package:lifemate/api.dart'; |
| 6 | import 'package:lifemate/notification_delivery.dart'; |
| 7 | import 'package:lifemate/session_store.dart'; |
| 8 | |
| 9 | class _MemorySession implements SessionStore { |
| 10 | String? value; |
| 11 | @override |
| 12 | Future<String?> read() async => value; |
| 13 | @override |
| 14 | Future<void> write(String next) async { |
| 15 | value = next; |
| 16 | } |
| 17 | |
| 18 | @override |
| 19 | Future<void> clear() async { |
| 20 | value = null; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | void main() { |
| 25 | test('polling uses the configured authenticated API, with no push SDK', |
| 26 | () async { |
| 27 | final requests = <http.Request>[]; |
| 28 | final token = 'header.${base64Url.encode(utf8.encode(jsonEncode({ |
| 29 | 'sub': 'synthetic-child' |
| 30 | })))}.signature'; |
| 31 | final client = MockClient((request) async { |
| 32 | requests.add(request); |
| 33 | if (request.url.path.endsWith('/login')) { |
| 34 | return http.Response( |
| 35 | jsonEncode({'accessToken': token, 'refreshToken': 'synthetic'}), |
| 36 | 200, |
| 37 | headers: {'content-type': 'application/json; charset=utf-8'}); |
| 38 | } |
| 39 | return http.Response( |
| 40 | jsonEncode({ |
| 41 | 'notifications': [ |
| 42 | { |
| 43 | 'id': 'notification', |
| 44 | 'payload': {'title': 'ریاضی'} |
| 45 | } |
| 46 | ] |
| 47 | }), |
| 48 | 200, |
| 49 | headers: {'content-type': 'application/json; charset=utf-8'}); |
| 50 | }); |
| 51 | final api = HttpIdentityApi( |
| 52 | baseUrl: 'https://lan.test/api', |
| 53 | client: client, |
| 54 | sessionStore: _MemorySession()); |
| 55 | await api.login('synthetic@example.test', 'SyntheticPass!123'); |
| 56 | final port = PollingInAppNotificationDelivery(api); |
| 57 | expect(port.supportsBackgroundPush, isFalse); |
| 58 | expect((await port.fetch()).single['id'], 'notification'); |
| 59 | expect(requests.last.url.toString(), |
| 60 | 'https://lan.test/api/v1/notification-outbox'); |
| 61 | expect(requests.last.headers['authorization'], 'Bearer $token'); |
| 62 | api.close(); |
| 63 | }); |
| 64 | } |