@@ -149,6 +149,18 @@ function maybeLoadShellEnvForVideoProviders(providerIds: string[]): void {
149149 } ) ;
150150}
151151
152+ function expectBufferedVideo (
153+ video : { buffer ?: Buffer ; mimeType : string ; fileName ?: string } | undefined ,
154+ ) : { buffer : Buffer ; mimeType : string ; fileName ?: string } {
155+ expect ( video ) . toBeDefined ( ) ;
156+ expect ( video ?. mimeType . startsWith ( "video/" ) ) . toBe ( true ) ;
157+ if ( ! video ?. buffer ) {
158+ throw new Error ( "expected generated video buffer" ) ;
159+ }
160+ expect ( video . buffer . byteLength ) . toBeGreaterThan ( 1024 ) ;
161+ return video ;
162+ }
163+
152164describeLive ( "video generation provider live" , ( ) => {
153165 it (
154166 "covers declared video-generation modes with shell/profile auth" ,
@@ -238,9 +250,7 @@ describeLive("video generation provider live", () => {
238250 } ) ;
239251
240252 expect ( result . videos . length ) . toBeGreaterThan ( 0 ) ;
241- expect ( result . videos [ 0 ] ?. mimeType . startsWith ( "video/" ) ) . toBe ( true ) ;
242- expect ( result . videos [ 0 ] ?. buffer . byteLength ) . toBeGreaterThan ( 1024 ) ;
243- generatedVideo = result . videos [ 0 ] ?? null ;
253+ generatedVideo = expectBufferedVideo ( result . videos [ 0 ] ) ;
244254 attempted . push ( `${ testCase . providerId } :generate:${ providerModel } (${ authLabel } )` ) ;
245255 console . error (
246256 `${ logPrefix } mode=generate done ms=${ Date . now ( ) - startedAt } videos=${ result . videos . length } ` ,
@@ -298,8 +308,7 @@ describeLive("video generation provider live", () => {
298308 } ) ;
299309
300310 expect ( result . videos . length ) . toBeGreaterThan ( 0 ) ;
301- expect ( result . videos [ 0 ] ?. mimeType . startsWith ( "video/" ) ) . toBe ( true ) ;
302- expect ( result . videos [ 0 ] ?. buffer . byteLength ) . toBeGreaterThan ( 1024 ) ;
311+ expectBufferedVideo ( result . videos [ 0 ] ) ;
303312 attempted . push ( `${ testCase . providerId } :imageToVideo:${ providerModel } (${ authLabel } )` ) ;
304313 console . error (
305314 `${ logPrefix } mode=imageToVideo done ms=${ Date . now ( ) - startedAt } videos=${ result . videos . length } ` ,
@@ -348,8 +357,7 @@ describeLive("video generation provider live", () => {
348357 } ) ;
349358
350359 expect ( result . videos . length ) . toBeGreaterThan ( 0 ) ;
351- expect ( result . videos [ 0 ] ?. mimeType . startsWith ( "video/" ) ) . toBe ( true ) ;
352- expect ( result . videos [ 0 ] ?. buffer . byteLength ) . toBeGreaterThan ( 1024 ) ;
360+ expectBufferedVideo ( result . videos [ 0 ] ) ;
353361 attempted . push ( `${ testCase . providerId } :videoToVideo:${ providerModel } (${ authLabel } )` ) ;
354362 console . error (
355363 `${ logPrefix } mode=videoToVideo done ms=${ Date . now ( ) - startedAt } videos=${ result . videos . length } ` ,
0 commit comments