@@ -168,6 +168,92 @@ describe("message tool agent routing", () => {
168168 } ) ,
169169 } ) ;
170170 } ) ;
171+
172+ it ( "does not flag missing delivery result on dry-run sends" , async ( ) => {
173+ mocks . runMessageAction . mockClear ( ) ;
174+ mocks . runMessageAction . mockResolvedValue ( {
175+ kind : "send" ,
176+ action : "send" ,
177+ channel : "feishu" ,
178+ to : "chat:oc_dryrun" ,
179+ handledBy : "core" ,
180+ payload : {
181+ channel : "feishu" ,
182+ to : "chat:oc_dryrun" ,
183+ via : "direct" ,
184+ mediaUrl : null ,
185+ } ,
186+ sendResult : {
187+ channel : "feishu" ,
188+ to : "chat:oc_dryrun" ,
189+ via : "direct" ,
190+ mediaUrl : null ,
191+ } ,
192+ dryRun : true ,
193+ } satisfies MessageActionRunResult ) ;
194+
195+ const result = await executeMessageTool ( {
196+ action : {
197+ action : "send" ,
198+ channel : "feishu" ,
199+ target : "chat:oc_dryrun" ,
200+ message : "hi" ,
201+ dryRun : true ,
202+ } ,
203+ } ) ;
204+
205+ expect ( result ) . toMatchObject ( {
206+ details : expect . objectContaining ( {
207+ channel : "feishu" ,
208+ to : "chat:oc_dryrun" ,
209+ } ) ,
210+ } ) ;
211+ expect ( ( result as { details ?: { status ?: unknown } } ) . details ?. status ) . not . toBe ( "error" ) ;
212+ } ) ;
213+
214+ it ( "returns the payload as-is when delivery yields a concrete messageId" , async ( ) => {
215+ mocks . runMessageAction . mockClear ( ) ;
216+ mocks . runMessageAction . mockResolvedValue ( {
217+ kind : "send" ,
218+ action : "send" ,
219+ channel : "feishu" ,
220+ to : "chat:oc_ok" ,
221+ handledBy : "core" ,
222+ payload : {
223+ channel : "feishu" ,
224+ to : "chat:oc_ok" ,
225+ via : "direct" ,
226+ mediaUrl : null ,
227+ result : { messageId : "om_delivered_42" } ,
228+ } ,
229+ sendResult : {
230+ channel : "feishu" ,
231+ to : "chat:oc_ok" ,
232+ via : "direct" ,
233+ mediaUrl : null ,
234+ result : { messageId : "om_delivered_42" } ,
235+ } ,
236+ dryRun : false ,
237+ } satisfies MessageActionRunResult ) ;
238+
239+ const result = await executeMessageTool ( {
240+ action : {
241+ action : "send" ,
242+ channel : "feishu" ,
243+ target : "chat:oc_ok" ,
244+ message : "hi" ,
245+ } ,
246+ } ) ;
247+
248+ expect ( result ) . toMatchObject ( {
249+ details : expect . objectContaining ( {
250+ channel : "feishu" ,
251+ to : "chat:oc_ok" ,
252+ result : expect . objectContaining ( { messageId : "om_delivered_42" } ) ,
253+ } ) ,
254+ } ) ;
255+ expect ( ( result as { details ?: { status ?: unknown } } ) . details ?. status ) . not . toBe ( "error" ) ;
256+ } ) ;
171257} ) ;
172258
173259describe ( "message tool path passthrough" , ( ) => {
0 commit comments