@@ -919,6 +919,48 @@ describe("discord component interactions", () => {
919919 expect ( dispatchReplyMock ) . not . toHaveBeenCalled ( ) ;
920920 } ) ;
921921
922+ it . each ( [
923+ { visibility : "private" , ephemeral : true } ,
924+ { visibility : "public" , ephemeral : false } ,
925+ { visibility : "default-private" , ephemeral : undefined } ,
926+ ] ) (
927+ "sends $visibility plugin replies as new messages after component acknowledgment" ,
928+ async ( { ephemeral } ) => {
929+ registerDiscordComponentEntries ( {
930+ entries : [ createButtonEntry ( { callbackData : "codex:approve" } ) ] ,
931+ modals : [ ] ,
932+ } ) ;
933+ dispatchPluginInteractiveHandlerMock . mockImplementation ( async ( params : unknown ) => {
934+ const typedParams = params as {
935+ onMatched : ( ) => Promise < void > ;
936+ respond : { reply : ( payload : { text : string ; ephemeral ?: boolean } ) => Promise < void > } ;
937+ } ;
938+ await typedParams . onMatched ( ) ;
939+ await typedParams . respond . reply ( {
940+ text : "Plugin result" ,
941+ ...( ephemeral === undefined ? { } : { ephemeral } ) ,
942+ } ) ;
943+ return { matched : true , handled : true , duplicate : false } ;
944+ } ) ;
945+
946+ const acknowledge = vi . fn ( ) . mockResolvedValue ( undefined ) ;
947+ const followUp = vi . fn ( ) . mockResolvedValue ( undefined ) ;
948+ const reply = vi . fn ( ) . mockResolvedValue ( undefined ) ;
949+ const button = createDiscordComponentButton ( createComponentContext ( ) ) ;
950+ const { interaction } = createComponentButtonInteraction ( { acknowledge, followUp, reply } ) ;
951+
952+ await button . run ( interaction , { cid : "btn_1" } as ComponentData ) ;
953+
954+ expect ( acknowledge ) . toHaveBeenCalledTimes ( 1 ) ;
955+ expect ( followUp ) . toHaveBeenCalledWith ( {
956+ content : "Plugin result" ,
957+ ephemeral : ephemeral ?? true ,
958+ } ) ;
959+ expect ( reply ) . not . toHaveBeenCalled ( ) ;
960+ expect ( dispatchReplyMock ) . not . toHaveBeenCalled ( ) ;
961+ } ,
962+ ) ;
963+
922964 it ( "lets plugin Discord interactions clear components after acknowledging" , async ( ) => {
923965 registerDiscordComponentEntries ( {
924966 entries : [ createButtonEntry ( { callbackData : "codex:approve" } ) ] ,
0 commit comments