← Files ProdVerityARCHIVED FILE
source/scripts/prodverity-ai-video.test.mjs
1.8 KB · Nov 29, 2026 · 00:48 UTC
import test from 'node:test'
import assert from 'node:assert/strict'
import {readFile} from 'node:fs/promises'
import ts from 'typescript'
const transpile=async path=>ts.transpileModule(await readFile(new URL(path,import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.ESNext,target:ts.ScriptTarget.ES2022}}).outputText
const data=code=>'data:text/javascript;base64,'+Buffer.from(code).toString('base64')
const resource=data(await transpile('../worker/prodverity-ai/resource-policy.ts'))
const video=data((await transpile('../worker/prodverity-ai/video-policy.ts')).replace("from './resource-policy'","from '"+resource+"'"))
const render=data((await transpile('../worker/prodverity-ai/video-render-plan.ts')).replace("from './video-policy'","from '"+video+"'"))
const {planVideoRender}=await import(render)
const source={url:'https://example.org/oer',title:'Open guide',license:'CC0',retrievedAt:'2026-10-02',commercialUse:true,derivativeAllowed:true}
const job={projectId:'alpha',outputPrefix:'alpha/lesson-1',voiceId:'licensed_voice',language:'fr-CA',draft:{title:'Lesson',resources:[source],scenes:[{sourceUrl:source.url,narration:'Bienvenue',visualDescription:'Animated concept',durationSeconds:20}],voice:{engine:'licensed-local',licenseVerified:true,impersonatesRealPerson:false},captions:true,reviewedByHuman:false}}
test('licensed video can be planned but cannot publish without review',()=>{const r=planVideoRender(job);assert.equal(r.accepted,true);assert.equal(r.publishable,false);assert.equal(r.renderManifest.format,'mp4')})
test('unlicensed voice blocks rendering',()=>assert.equal(planVideoRender({...job,draft:{...job.draft,voice:{...job.draft.voice,licenseVerified:false}}}).accepted,false))
test('path traversal in output blocked',()=>assert.equal(planVideoRender({...job,outputPrefix:'../secrets'}).accepted,false))
SHA-256: 42e2911a68e972345b16514e4c309fb6b5be91ac3c82db325538aef9a2ea72a5