@@ -120,6 +120,46 @@ describe("useEditQueuedMessage / useCancelQueuedMessageEdit", () => {
120120 expect ( pendingFor ( TASK ) ) . toEqual ( { segments : [ ] } ) ;
121121 } ) ;
122122
123+ it . each ( [
124+ { variant : "local" , isCloud : false , message : QUEUED } ,
125+ {
126+ variant : "cloud" ,
127+ isCloud : true ,
128+ message : {
129+ id : "q-1" ,
130+ content : "queued body" ,
131+ rawPrompt : [ { type : "text" as const , text : "queued body" } ] ,
132+ queuedAt : 1 ,
133+ } ,
134+ } ,
135+ ] ) (
136+ "loads a $variant queued message into the composer and marks it as the edit target" ,
137+ ( { isCloud, message } ) => {
138+ cloudState . isCloud = isCloud ;
139+
140+ const { result : edit } = renderHook ( ( ) => useEditQueuedMessage ( TASK ) ) ;
141+ act ( ( ) => edit . current ( message ) ) ;
142+
143+ expect ( sessionService . setEditingQueuedMessage ) . toHaveBeenCalledWith (
144+ TASK ,
145+ "q-1" ,
146+ ) ;
147+ expect ( pendingFor ( TASK ) ?. segments ) . toEqual ( [
148+ { type : "text" , text : "queued body" } ,
149+ ] ) ;
150+ } ,
151+ ) ;
152+
153+ it ( "does not start an edit when a cloud message has no loadable content" , ( ) => {
154+ cloudState . isCloud = true ;
155+
156+ const { result : edit } = renderHook ( ( ) => useEditQueuedMessage ( TASK ) ) ;
157+ act ( ( ) => edit . current ( { id : "q-1" , content : "" , queuedAt : 1 } ) ) ;
158+
159+ expect ( sessionService . setEditingQueuedMessage ) . not . toHaveBeenCalled ( ) ;
160+ expect ( pendingFor ( TASK ) ) . toBeUndefined ( ) ;
161+ } ) ;
162+
123163 it ( "snapshots fresh each edit, so a stale draft is not restored later" , ( ) => {
124164 const { result : edit } = renderHook ( ( ) => useEditQueuedMessage ( TASK ) ) ;
125165 const { result : cancel } = renderHook ( ( ) =>
0 commit comments