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
sql 60 lines 3.32 KB
Raw
1 -- Synthetic-only DB acceptance. Execute ONLY against isolated Supabase project
2 -- LifeGuide-QA / iqkrwxeprxvdiubdfcrb. Never run against Finora or any real user DB.
3 -- All writes and relationship changes are intentionally ROLLED BACK.
4 begin;
5 set local search_path=lifeguide_qa,extensions,pg_catalog;
6 do $qa_guardian_test$
7 declare
8 parent_a uuid := gen_random_uuid();
9 parent_b uuid := gen_random_uuid();
10 child_a uuid := gen_random_uuid();
11 outsider uuid := gen_random_uuid();
12 fam uuid := gen_random_uuid();
13 shared_task uuid := gen_random_uuid();
14 private_task uuid := gen_random_uuid();
15 study_id uuid := gen_random_uuid();
16 seconds int;
17 begin
18 insert into lifeguide_qa.app_user(id,identity_subject,email_normalized) values
19 (parent_a,'qa:mother:'||parent_a::text,'mother-'||parent_a::text||'@example.invalid'),
20 (parent_b,'qa:father:'||parent_b::text,'father-'||parent_b::text||'@example.invalid'),
21 (child_a,'qa:child:'||child_a::text,'child-'||child_a::text||'@example.invalid'),
22 (outsider,'qa:outsider:'||outsider::text,'outsider-'||outsider::text||'@example.invalid');
23 insert into lifeguide_qa.family_workspace(id,name,created_by)
24 values (fam,'Synthetic LifeGuide QA Family',parent_a);
25 insert into lifeguide_qa.family_membership(family_id,user_id,role,is_admin) values
26 (fam,parent_a,'parent_guardian',true),
27 (fam,parent_b,'parent_guardian',false),
28 (fam,child_a,'teen_minor',false);
29 insert into lifeguide_qa.guardian_relationship(family_id,guardian_user_id,minor_user_id)
30 values (fam,parent_a,child_a),(fam,parent_b,child_a);
31 if not lifeguide_qa.is_active_guardian(fam,parent_a,child_a)
32 or not lifeguide_qa.is_active_guardian(fam,parent_b,child_a)
33 or lifeguide_qa.is_active_guardian(fam,outsider,child_a)
34 or not lifeguide_qa.can_view_student_academic(parent_a,child_a)
35 or lifeguide_qa.can_view_student_academic(outsider,child_a)
36 then raise exception 'qa_guardian_visibility_failed'; end if;
37 insert into lifeguide_qa.plan_item(id,owner_user_id,family_id,kind,title,visibility)
38 values (shared_task,child_a,fam,'assignment','Synthetic math task','parent_guardian'),
39 (private_task,child_a,fam,'task','Synthetic private task','private');
40 if not lifeguide_qa.can_view_plan_item(parent_a,shared_task)
41 or not lifeguide_qa.can_view_plan_item(parent_b,shared_task)
42 or lifeguide_qa.can_view_plan_item(outsider,shared_task)
43 or lifeguide_qa.can_view_plan_item(parent_a,private_task)
44 or not lifeguide_qa.can_view_plan_item(child_a,private_task)
45 then raise exception 'qa_plan_privacy_failed'; end if;
46 insert into lifeguide_qa.study_session(
47 id,child_user_id,plan_item_id,source,status,started_at,ended_at,last_event_at,recorded_duration_seconds)
48 values (study_id,child_a,shared_task,'timer','completed',
49 now()-interval '4 seconds',now(),now(),4);
50 select recorded_duration_seconds into seconds
51 from lifeguide_qa.study_session where id=study_id;
52 if seconds<>4 then raise exception 'qa_study_seconds_failed'; end if;
53 update lifeguide_qa.guardian_relationship set active=false
54 where family_id=fam and guardian_user_id=parent_b and minor_user_id=child_a;
55 if lifeguide_qa.is_active_guardian(fam,parent_b,child_a)
56 or lifeguide_qa.can_view_plan_item(parent_b,shared_task)
57 or not lifeguide_qa.can_view_plan_item(parent_a,shared_task)
58 then raise exception 'qa_guardian_revocation_failed'; end if;
59 end $qa_guardian_test$;
60 rollback;