@@ -2364,6 +2364,55 @@ describe("handleDiscordMessagingAction", () => {
23642364 } ) ;
23652365 } ) ;
23662366
2367+ it . each ( [
2368+ { label : "forum message" , parentType : ChannelType . GuildForum , components : false } ,
2369+ { label : "media message" , parentType : ChannelType . GuildMedia , components : false } ,
2370+ { label : "forum component media" , parentType : ChannelType . GuildForum , components : true } ,
2371+ { label : "media component media" , parentType : ChannelType . GuildMedia , components : true } ,
2372+ ] ) ( "renames the newly created $label thread" , async ( { parentType, components } ) => {
2373+ const sender = components ? sendDiscordComponentMessage : sendMessageDiscord ;
2374+ sender . mockResolvedValueOnce ( {
2375+ messageId : "M1" ,
2376+ channelId : "T1" ,
2377+ receipt : { threadId : "T1" } ,
2378+ } ) ;
2379+ fetchChannelInfoDiscord . mockImplementation ( async ( channelId ) => ( {
2380+ id : channelId ,
2381+ type : channelId === "P1" ? parentType : ChannelType . PublicThread ,
2382+ } ) ) ;
2383+ editChannelDiscord . mockResolvedValueOnce ( {
2384+ id : "T1" ,
2385+ name : "chosen-thread" ,
2386+ } ) ;
2387+
2388+ const result = await handleMessagingAction (
2389+ "sendMessage" ,
2390+ {
2391+ to : "channel:P1" ,
2392+ content : "A generated thread title" ,
2393+ threadName : "chosen-thread" ,
2394+ ...( components
2395+ ? {
2396+ components : { blocks : [ { type : "text" , text : "A generated thread title" } ] } ,
2397+ mediaUrl : "/tmp/image.png" ,
2398+ }
2399+ : { } ) ,
2400+ } ,
2401+ enableAllActions ,
2402+ ) ;
2403+
2404+ expect ( fetchChannelInfoDiscord ) . toHaveBeenCalledWith ( "T1" , { cfg : DISCORD_TEST_CFG } ) ;
2405+ expect ( editChannelDiscord ) . toHaveBeenCalledWith (
2406+ { channelId : "T1" , name : "chosen-thread" } ,
2407+ { cfg : DISCORD_TEST_CFG } ,
2408+ ) ;
2409+ expect ( result . details ) . toMatchObject ( {
2410+ ok : true ,
2411+ result : { channelId : "T1" , receipt : { threadId : "T1" } } ,
2412+ threadRename : { ok : true , channelId : "T1" , name : "chosen-thread" } ,
2413+ } ) ;
2414+ } ) ;
2415+
23672416 it ( "forwards sendMessage suppressEmbeds overrides" , async ( ) => {
23682417 sendMessageDiscord . mockClear ( ) ;
23692418
0 commit comments