23 lines
2.2 KiB
TypeScript
23 lines
2.2 KiB
TypeScript
import {describe,it,expect} from "vitest";
|
|
import {bindRecipe} from "../src/media/recipe-binding.js";
|
|
const source={episodeId:"episode_real",episodeNo:1,source:"/private/authorized/episode.mp4",duration:20};
|
|
function recipe(){return {schema_version:"2.0",analysis_id:"analysis_real",drama_id:"drama_real",duration_strategy:"content_led",withheld_information:["An answer"],ending:{cutoff_reason:"Question remains",before_withheld_reveal:true},segments:[{id:"one",hook_id:"hook",episode_id:"episode_real",episode:1,source:"/etc/passwd",source_start:1,source_end:11,target_start:0,target_end:10,semantic_role:"Question",continuity_group:"scene",source_gap_before:0,confidence:"high",reveal_risk:"low",cut_reason:"Complete exchange"}]};}
|
|
const binding={analysisId:"analysis_real",dramaId:"drama_real",analysisPath:"/private/job/target-drama-analysis.json",withheldInformation:["An answer"],sources:[source]};
|
|
describe("authorized ten-second recipe",()=>{
|
|
it("resolves source and analysis paths on the server instead of accepting model-supplied paths",()=>{
|
|
const bound=bindRecipe(recipe(),binding);
|
|
expect(bound.segments[0]?.source).toBe(source.source);expect(bound.target_analysis_path).toBe(binding.analysisPath);
|
|
});
|
|
it("rejects wrong identities, wrong episodes, out-of-source ranges and non-frame-aligned cuts",()=>{
|
|
const foreign=recipe();foreign.drama_id="other";expect(()=>bindRecipe(foreign,binding)).toThrow();
|
|
const episode=recipe();episode.segments[0]!.episode_id="other";expect(()=>bindRecipe(episode,binding)).toThrow();
|
|
const range=recipe();range.segments[0]!.source_end=30;expect(()=>bindRecipe(range,binding)).toThrow();
|
|
const boundary=recipe();boundary.segments[0]!.source_start=1.01;expect(()=>bindRecipe(boundary,binding)).toThrow();
|
|
const reveal=recipe();reveal.withheld_information=["Different answer"];expect(()=>bindRecipe(reveal,binding)).toThrow();
|
|
});
|
|
it("rejects non-ten-second output and arbitrary subtitle input paths",()=>{
|
|
const long=recipe();long.segments[0]!.source_end=12;long.segments[0]!.target_end=11;expect(()=>bindRecipe(long,binding)).toThrow();
|
|
expect(()=>bindRecipe({...recipe(),subtitle_path:"/private/secret.srt"},binding)).toThrow();
|
|
});
|
|
});
|