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
js 26 lines 2.1 KB
Raw
1 import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import crypto from 'node:crypto';
4 import {localContentReviewConnection,normalizePublicationOperation} from '../src/content_publication.js';
5
6 test('publication operator rejects remote/default/runtime configuration and accepts only explicit loopback test URL',()=>{
7 for(const env of [{},{DATABASE_URL:'postgres://local@127.0.0.1/lifeguide_test'},
8 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@127.0.0.1/production',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'},
9 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@remote.example/lifeguide_test',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'},
10 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@127.0.0.1/lifeguide_test?host=remote.example',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'},
11 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@127.0.0.1/lifeguide_test?sslkey=/private/path',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'},
12 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@127.0.0.1/lifeguide_test'},
13 {CONTENT_REVIEW_DATABASE_URL:'postgres://local@127.0.0.1/contest',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'}]) {
14 assert.throws(()=>localContentReviewConnection(env));
15 }
16 assert.equal(new URL(localContentReviewConnection({CONTENT_REVIEW_DATABASE_URL:'postgres://operator@127.0.0.1/lifeguide_publication_test',CONTENT_REVIEW_SYNTHETIC_ONLY:'true'})).hostname,'127.0.0.1');
17 });
18
19 test('publication manifest accepts exact typed operation fields and refuses private or unbounded content',()=>{
20 const base={schemaVersion:1,mutationId:crypto.randomUUID(),entityType:'video',entityId:crypto.randomUUID(),operation:'withdraw',
21 expectedStatus:'published',expectedContentHash:'a'.repeat(64),expectedContextHash:'b'.repeat(64)};
22 assert.equal(normalizePublicationOperation(base).operation,'withdraw');
23 for(const value of [null,[],{...base,ownerUserId:crypto.randomUUID()},{...base,privateChat:'PRIVATE'},
24 {...base,review:{watchedEntireVideo:'true'}},{...base,expectedContentHash:'wrong'},
25 {...base,expectedVersion:1},{...base,operation:'deploy'},{...base,entityId:'wrong'}]) assert.throws(()=>normalizePublicationOperation(value));
26 });