LifeMate — Personal, Family & Learning Companion

docs/child-education-access-decision
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
js 21 lines 1.32 KB
Raw
1 import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import crypto from 'node:crypto';
4 import { normalizeReviewMutation, normalizeBriefRequest } from '../src/content_review.js';
5
6 test('review mutations allow only explicit statuses and reject inferred identities or text', () => {
7 const body={mutationId:crypto.randomUUID(),expectedVersion:1,status:'triaged'};
8 assert.deepEqual(normalizeReviewMutation(body),body);
9 for(const extra of [{status:'released'},{status:'received'},{expectedVersion:0},
10 {expectedVersion:'1'},{mutationId:'bad'},{ownerUserId:crypto.randomUUID()},
11 {summary:'copied text'},{role:'admin'}]) assert.equal(normalizeReviewMutation({...body,...extra}),null);
12 });
13
14 test('brief requests are bounded source/version references, never private text', () => {
15 const body={mutationId:crypto.randomUUID(),feedback:[{id:crypto.randomUUID(),expectedVersion:2}]};
16 assert.deepEqual(normalizeBriefRequest(body),body);
17 for(const extra of [{feedback:[]},{feedback:Array.from({length:21},()=>({id:crypto.randomUUID(),expectedVersion:1}))},
18 {feedback:[body.feedback[0],body.feedback[0]]},{summary:'private text'},
19 {feedback:[{...body.feedback[0],ownerUserId:crypto.randomUUID()}]},
20 {feedback:[{...body.feedback[0],expectedVersion:'2'}]}]) assert.equal(normalizeBriefRequest({...body,...extra}),null);
21 });