@@ -938,3 +938,73 @@ func TestTeamsWorkflows_ActionNonOpenUri(t *testing.T) {
938938 // Non-OpenUri actions should not be converted
939939 assert .Empty (t , card .Actions )
940940}
941+
942+ func TestTeamsWorkflows_RawCardPayload_BuiltIn (t * testing.T ) {
943+ var receivedBody []byte
944+ server := httptest .NewServer (http .HandlerFunc (func (writer http.ResponseWriter , request * http.Request ) {
945+ data , err := io .ReadAll (request .Body )
946+ require .NoError (t , err )
947+ receivedBody = data
948+ writer .WriteHeader (http .StatusOK )
949+ }))
950+ defer server .Close ()
951+
952+ webhookURL := server .URL + "/powerautomate/webhook"
953+
954+ service := NewTeamsWorkflowsService (TeamsWorkflowsOptions {
955+ RecipientUrls : map [string ]string {
956+ "test" : webhookURL ,
957+ },
958+ RawCardPayload : true ,
959+ })
960+
961+ notification := Notification {
962+ TeamsWorkflows : & TeamsWorkflowsNotification {
963+ Title : "Test Title" ,
964+ Text : "Test message body" ,
965+ },
966+ }
967+
968+ err := service .Send (notification , Destination {Recipient : "test" , Service : "teams-workflows" })
969+ require .NoError (t , err )
970+
971+ var root map [string ]any
972+ require .NoError (t , json .Unmarshal (receivedBody , & root ))
973+ assert .Equal (t , "AdaptiveCard" , root ["type" ])
974+ assert .NotContains (t , root , "attachments" )
975+ }
976+
977+ func TestTeamsWorkflows_RawCardPayload_CustomCard (t * testing.T ) {
978+ var receivedBody []byte
979+ server := httptest .NewServer (http .HandlerFunc (func (writer http.ResponseWriter , request * http.Request ) {
980+ data , err := io .ReadAll (request .Body )
981+ require .NoError (t , err )
982+ receivedBody = data
983+ writer .WriteHeader (http .StatusOK )
984+ }))
985+ defer server .Close ()
986+
987+ webhookURL := server .URL + "/powerautomate/webhook"
988+
989+ service := NewTeamsWorkflowsService (TeamsWorkflowsOptions {
990+ RecipientUrls : map [string ]string {
991+ "test" : webhookURL ,
992+ },
993+ RawCardPayload : true ,
994+ })
995+
996+ notification := Notification {
997+ TeamsWorkflows : & TeamsWorkflowsNotification {
998+ AdaptiveCard : `{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"hello"}]}` ,
999+ },
1000+ }
1001+
1002+ err := service .Send (notification , Destination {Recipient : "test" , Service : "teams-workflows" })
1003+ require .NoError (t , err )
1004+
1005+ var root map [string ]any
1006+ require .NoError (t , json .Unmarshal (receivedBody , & root ))
1007+ assert .Equal (t , "AdaptiveCard" , root ["type" ])
1008+ assert .Equal (t , "1.4" , root ["version" ])
1009+ assert .NotContains (t , root , "attachments" )
1010+ }
0 commit comments