fix(web-test): stopRecording/addNarration return stub when not recording

Enables --no-record dry-run of video scripts without errors. stopRecording()
returns { file: null, duration: 0, size: 0 } instead of throwing, and
addNarration(null) returns a matching stub.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-15 17:36:19 +03:00
parent 26c5e849a5
commit 6667ab38ee
+2 -1
View File
@@ -3639,7 +3639,7 @@ export async function startRecording(outputPath, opts = {}) {
* @returns {{ file: string, duration: number, size: number }}
*/
export async function stopRecording() {
if (!recorder) throw new Error('Not recording. Call startRecording() first.');
if (!recorder) return { file: null, duration: 0, size: 0 };
const { cdp, ffmpeg, startTime, outputPath } = recorder;
@@ -3790,6 +3790,7 @@ export function getCaptions() {
* @returns {{ file: string, duration: number, size: number, captions: number, warnings?: string[] }}
*/
export async function addNarration(videoPath, opts = {}) {
if (!videoPath) return { file: null, duration: 0, size: 0, captions: 0 };
const ffmpegPath = resolveFfmpeg(opts.ffmpegPath);
const ttsProvider = getTtsProvider(opts.provider || 'edge');
const ttsOpts = { voice: opts.voice, apiKey: opts.apiKey, apiUrl: opts.apiUrl, model: opts.model };