@@ -22,6 +22,8 @@ import {
2222 dismissBranchMismatchForSession ,
2323 ENVIRONMENT_RECONNECT_WARNING_GRACE_MS ,
2424 getStartedThreadModelChangeBlockReason ,
25+ loadVideoPreviewUrl ,
26+ isVideoPreviewRequestCurrent ,
2527 hasEnvironmentReconnectWarningGraceElapsed ,
2628 hasServerAcknowledgedLocalDispatch ,
2729 isBranchMismatchDismissedForSession ,
@@ -42,6 +44,31 @@ import {
4244 shouldWriteThreadErrorToCurrentServerThread ,
4345} from "./ChatView.logic" ;
4446
47+ describe ( "loadVideoPreviewUrl" , ( ) => {
48+ it ( "loads video bytes into an object URL" , async ( ) => {
49+ const objectUrl = await loadVideoPreviewUrl ( "data:video/mp4;base64,AA==" ) ;
50+ expect ( objectUrl ) . toMatch ( / ^ b l o b : / ) ;
51+ URL . revokeObjectURL ( objectUrl ) ;
52+ } ) ;
53+
54+ it ( "stops loading when the preview request is cancelled" , async ( ) => {
55+ const controller = new AbortController ( ) ;
56+ controller . abort ( ) ;
57+
58+ await expect (
59+ loadVideoPreviewUrl ( "data:video/mp4;base64,AA==" , controller . signal ) ,
60+ ) . rejects . toMatchObject ( { name : "AbortError" } ) ;
61+ } ) ;
62+ } ) ;
63+
64+ describe ( "isVideoPreviewRequestCurrent" , ( ) => {
65+ it ( "rejects changed threads and replaced previews" , ( ) => {
66+ expect ( isVideoPreviewRequestCurrent ( "thread-1" , "thread-2" , 1 , 1 ) ) . toBe ( false ) ;
67+ expect ( isVideoPreviewRequestCurrent ( "thread-1" , "thread-1" , 1 , 2 ) ) . toBe ( false ) ;
68+ expect ( isVideoPreviewRequestCurrent ( "thread-1" , "thread-1" , 2 , 2 ) ) . toBe ( true ) ;
69+ } ) ;
70+ } ) ;
71+
4572const environmentId = EnvironmentId . make ( "environment-local" ) ;
4673const projectId = ProjectId . make ( "project-1" ) ;
4774const threadId = ThreadId . make ( "thread-1" ) ;
0 commit comments