@@ -683,6 +683,55 @@ func TestDraftUpdateSendsStringVersion(t *testing.T) {
683683 }
684684}
685685
686+ func TestDraftUpdateSendsChannelIDWhenProvided (t * testing.T ) {
687+ t .Setenv ("HOME" , t .TempDir ())
688+
689+ var gotBody map [string ]any
690+
691+ srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
692+ if err := json .NewDecoder (r .Body ).Decode (& gotBody ); err != nil {
693+ t .Fatalf ("decode request body: %v" , err )
694+ }
695+
696+ w .Header ().Set ("Content-Type" , "application/json" )
697+ _ , _ = io .WriteString (w , `{
698+ "id":"msg_draft_123",
699+ "type":"email",
700+ "is_inbound":false,
701+ "draft_mode":"shared",
702+ "version":"draft-ver-456",
703+ "created_at":1710000000,
704+ "body":"updated body",
705+ "text":"updated body",
706+ "subject":"Updated draft"
707+ }` )
708+ }))
709+ defer srv .Close ()
710+
711+ old := newClientFromAuth
712+ newClientFromAuth = func (_ , _ string ) (* api.Client , error ) {
713+ return api .NewClientWithBaseURL (oauth2 .StaticTokenSource (& oauth2.Token {AccessToken : "token" }), srv .URL ), nil
714+ }
715+ t .Cleanup (func () { newClientFromAuth = old })
716+
717+ cmd := DraftUpdateCmd {
718+ ID : "msg_draft_123" ,
719+ Channel : "cha_v4x" ,
720+ DraftVersion : "draft-ver-123" ,
721+ Body : "updated body" ,
722+ }
723+ flags := & RootFlags {JSON : true , Account : "test@example.com" }
724+
725+ if err := cmd .Run (flags ); err != nil {
726+ t .Fatalf ("Run: %v" , err )
727+ }
728+
729+ channelID , ok := gotBody ["channel_id" ].(string )
730+ if ! ok || channelID != "cha_v4x" {
731+ t .Fatalf ("expected channel_id in request body, got %#v" , gotBody ["channel_id" ])
732+ }
733+ }
734+
686735func TestDraftUpdateHumanOutputUsesStringVersion (t * testing.T ) {
687736 t .Setenv ("HOME" , t .TempDir ())
688737
0 commit comments