import fs from 'node:fs'; import assert from 'node:assert/strict'; import {createHash} from 'node:crypto'; import videos from '../../unreal_tran_web/src/features/virtual-training-scripts/narration-video-manifest.js'; import speech from '../../unreal_tran_web/src/features/virtual-training-scripts/narration-manifest.js'; const origin=process.env.BASE_URL || 'http://127.0.0.1:6180'; const directory=process.env.REPORT_DIR || 'reports/bridge-lecture-polish-20260915/local'; const sha=b=>createHash('sha256').update(b).digest('hex'); const clips=videos.scripts.flatMap(s=>s.steps); const sounds=speech.scripts.flatMap(s=>s.steps.flatMap(c=>[{url:c.url,sha256:c.stepSha256},...(c.safetyUrl?[{url:c.safetyUrl,sha256:c.safetySha256}]:[])])); assert.equal(clips.length,39); for(const pack of speech.scripts)for(const clip of pack.steps)assert.doesNotMatch(clip.text+' '+clip.safetyText,/原稿|原图|没有展开|未展开|没有给出|概括项|本预演|相反描述/); for(const group of [clips,sounds]) { for(let start=0;start{ const r=await fetch(origin+clip.url,{signal:AbortSignal.timeout(60000)}); assert.equal(r.status,200,clip.url); assert.equal(sha(Buffer.from(await r.arrayBuffer())),clip.sha256,clip.url); assert.equal(sha(fs.readFileSync(new URL('../../unreal_tran_web/dist'+clip.url,import.meta.url))),clip.sha256); })); } const range=await fetch(origin+clips[0].url,{headers:{Range:'bytes=0-1023'}}); assert.equal(range.status,206);assert.equal((await range.arrayBuffer()).byteLength,1024); fs.mkdirSync(directory,{recursive:true}); const result={origin,videos:clips.length,audio:sounds.length,allTextsClean:true,exactFiles:true,buildCopiesMatch:true,rangeRequests:true}; fs.writeFileSync(directory+'/delivery.json',JSON.stringify(result,null,2));console.log(JSON.stringify(result));