@@ -103,8 +103,6 @@ def build_test_message_blocks(
103
103
else :
104
104
title_link += f"&alert_rule_id={ rule .id } &alert_type=issue"
105
105
106
- title_text = f":red_circle: <{ title_link } |*{ formatted_title } *>"
107
-
108
106
if rule :
109
107
if legacy_rule_id :
110
108
block_id = f'{{"issue":{ group .id } ,"rule":{ legacy_rule_id } }}'
@@ -115,8 +113,22 @@ def build_test_message_blocks(
115
113
116
114
blocks : list [dict [str , Any ]] = [
117
115
{
118
- "type" : "section" ,
119
- "text" : {"type" : "mrkdwn" , "text" : title_text },
116
+ "type" : "rich_text" ,
117
+ "elements" : [
118
+ {
119
+ "type" : "rich_text_section" ,
120
+ "elements" : [
121
+ {"type" : "emoji" , "name" : "red_circle" },
122
+ {"type" : "text" , "text" : " " },
123
+ {
124
+ "type" : "link" ,
125
+ "url" : title_link ,
126
+ "text" : formatted_title ,
127
+ "style" : {"bold" : True },
128
+ },
129
+ ],
130
+ }
131
+ ],
120
132
"block_id" : block_id ,
121
133
},
122
134
]
@@ -848,7 +860,8 @@ def test_build_performance_issue(self):
848
860
with self .feature ("organizations:performance-issues" ):
849
861
blocks = SlackIssuesMessageBuilder (event .group , event ).build ()
850
862
assert isinstance (blocks , dict )
851
- assert "N+1 Query" in blocks ["blocks" ][0 ]["text" ]["text" ]
863
+ title_text = blocks ["blocks" ][0 ]["elements" ][0 ]["elements" ][- 1 ]["text" ]
864
+ assert "N+1 Query" in title_text
852
865
assert (
853
866
"db - SELECT `books_author`.`id`, `books_author`.`name` FROM `books_author` WHERE `books_author`.`id` = %s LIMIT 21"
854
867
in blocks ["blocks" ][2 ]["text" ]["text" ]
@@ -996,8 +1009,9 @@ def test_build_group_block_with_ai_summary_with_feature_flag(
996
1009
mock_get_summary .assert_called_once_with (group , source = "alert" )
997
1010
998
1011
# Verify that the original title is \\ present
999
- assert "IntegrationError" in blocks ["blocks" ][0 ]["text" ]["text" ]
1000
- assert "Identity not found" in blocks ["blocks" ][0 ]["text" ]["text" ]
1012
+ title_text = blocks ["blocks" ][0 ]["elements" ][0 ]["elements" ][- 1 ]["text" ]
1013
+ assert "IntegrationError" in title_text
1014
+ assert "Identity not found" in title_text
1001
1015
1002
1016
# Verify that the AI content is used in the context block
1003
1017
content_block = blocks ["blocks" ][1 ]["elements" ][0 ]["text" ]
@@ -1042,7 +1056,8 @@ def test_build_group_block_with_ai_summary_without_feature_flag(
1042
1056
with patch (patch_path ) as mock_get_summary :
1043
1057
mock_get_summary .assert_not_called ()
1044
1058
blocks = SlackIssuesMessageBuilder (group ).build ()
1045
- assert "IntegrationError" in blocks ["blocks" ][0 ]["text" ]["text" ]
1059
+ title_text = blocks ["blocks" ][0 ]["elements" ][0 ]["elements" ][- 1 ]["text" ]
1060
+ assert "IntegrationError" in title_text
1046
1061
1047
1062
@override_options ({"alerts.issue_summary_timeout" : 5 })
1048
1063
@with_feature ({"organizations:gen-ai-features" , "projects:trigger-issue-summary-on-alerts" })
@@ -1126,7 +1141,7 @@ def test_build_group_block_with_ai_summary_text_truncation(
1126
1141
):
1127
1142
mock_get_summary .return_value = (mock_summary , 200 )
1128
1143
blocks = SlackIssuesMessageBuilder (group1 , event1 .for_group (group1 )).build ()
1129
- title_text = blocks ["blocks" ][0 ]["text" ]["text" ]
1144
+ title_text = blocks ["blocks" ][0 ]["elements" ][ 0 ][ "elements" ][ - 1 ]["text" ]
1130
1145
1131
1146
assert "First line of text..." in title_text
1132
1147
assert "Second line" not in title_text
@@ -1138,7 +1153,7 @@ def test_build_group_block_with_ai_summary_text_truncation(
1138
1153
):
1139
1154
mock_get_summary .return_value = (mock_summary , 200 )
1140
1155
blocks = SlackIssuesMessageBuilder (group2 , event2 .for_group (group2 )).build ()
1141
- title_text = blocks ["blocks" ][0 ]["text" ]["text" ]
1156
+ title_text = blocks ["blocks" ][0 ]["elements" ][ 0 ][ "elements" ][ - 1 ]["text" ]
1142
1157
1143
1158
expected_truncated = long_text [:MAX_SUMMARY_HEADLINE_LENGTH ] + "..."
1144
1159
assert expected_truncated in title_text
@@ -1181,8 +1196,8 @@ def test_build_group_block_with_ai_summary_text_truncation(
1181
1196
):
1182
1197
mock_get_summary .return_value = (mock_summary , 200 )
1183
1198
blocks = SlackIssuesMessageBuilder (group_lb , event_lb .for_group (group_lb )).build ()
1184
- title_block = blocks ["blocks" ][0 ]["text" ]["text" ]
1185
- assert f": { expected_headline_part } *> " in title_block , f"Failed for { name } "
1199
+ title_block = blocks ["blocks" ][0 ]["elements" ][ 0 ][ "elements" ][ - 1 ]["text" ]
1200
+ assert f": { expected_headline_part } " in title_block , f"Failed for { name } "
1186
1201
1187
1202
@override_options ({"alerts.issue_summary_timeout" : 5 })
1188
1203
@patch (
@@ -1214,7 +1229,8 @@ def test_build_group_block_with_ai_summary_without_org_acknowledgement(
1214
1229
mock_get_issue_summary .assert_not_called ()
1215
1230
1216
1231
blocks = SlackIssuesMessageBuilder (group ).build ()
1217
- assert "IntegrationError" in blocks ["blocks" ][0 ]["text" ]["text" ]
1232
+ title_text = blocks ["blocks" ][0 ]["elements" ][0 ]["elements" ][- 1 ]["text" ]
1233
+ assert "IntegrationError" in title_text
1218
1234
1219
1235
1220
1236
class BuildGroupAttachmentReplaysTest (TestCase ):
0 commit comments