@@ -181,7 +181,7 @@ describe("Feishu card-action lifecycle", () => {
181181 expect . objectContaining ( {
182182 accountId : "acct-card" ,
183183 chatId : "p2p:ou_user1" ,
184- replyToMessageId : "card-action-tok-card-once" ,
184+ replyToMessageId : undefined ,
185185 } ) ,
186186 ) ;
187187 expect ( finalizeInboundContextMock ) . toHaveBeenCalledWith (
@@ -233,7 +233,12 @@ describe("Feishu card-action lifecycle", () => {
233233 expect . objectContaining ( {
234234 accountId : "acct-card" ,
235235 chatId,
236- replyToMessageId : "card-action-tok-card-v2-context" ,
236+ replyToMessageId : "om_card_v2" ,
237+ } ) ,
238+ ) ;
239+ expect ( finalizeInboundContextMock ) . toHaveBeenCalledWith (
240+ expect . objectContaining ( {
241+ MessageSid : "card-action-tok-card-v2-context" ,
237242 } ) ,
238243 ) ;
239244 } ) ;
@@ -261,7 +266,42 @@ describe("Feishu card-action lifecycle", () => {
261266 expect . objectContaining ( {
262267 accountId : "acct-card" ,
263268 chatId : "ou_user1" ,
264- replyToMessageId : "card-action-tok-card-sdk-flat" ,
269+ replyToMessageId : "om_sdk_card" ,
270+ } ) ,
271+ ) ;
272+ expect ( finalizeInboundContextMock ) . toHaveBeenCalledWith (
273+ expect . objectContaining ( {
274+ MessageSid : "card-action-tok-card-sdk-flat" ,
275+ } ) ,
276+ ) ;
277+ } ) ;
278+
279+ it ( "plain-sends card action replies when Feishu provides no real message id" , async ( ) => {
280+ const onCardAction = await setupLifecycleMonitor ( ) ;
281+
282+ await onCardAction ( {
283+ open_id : "ou_user1" ,
284+ token : "tok-card-no-reply-target" ,
285+ action : {
286+ tag : "button" ,
287+ value : {
288+ command : "/help" ,
289+ } ,
290+ } ,
291+ } ) ;
292+
293+ expect ( lastRuntime ?. error ) . not . toHaveBeenCalled ( ) ;
294+ expect ( dispatchReplyFromConfigMock ) . toHaveBeenCalledTimes ( 1 ) ;
295+ expect ( createFeishuReplyDispatcherMock ) . toHaveBeenCalledWith (
296+ expect . objectContaining ( {
297+ accountId : "acct-card" ,
298+ chatId : "ou_user1" ,
299+ replyToMessageId : undefined ,
300+ } ) ,
301+ ) ;
302+ expect ( finalizeInboundContextMock ) . toHaveBeenCalledWith (
303+ expect . objectContaining ( {
304+ MessageSid : "card-action-tok-card-no-reply-target" ,
265305 } ) ,
266306 ) ;
267307 } ) ;
0 commit comments