@@ -115,3 +115,68 @@ def test_slack_quote_keeps_boundaries_around_mentions(before_mention, after_ment
115115 f"Question:\n { before_mention } { after_mention } \n Next paragraph"
116116 )
117117 assert [c .qq for c in components if isinstance (c , At )] == ["UOTHER" ]
118+
119+
120+ @pytest .mark .asyncio
121+ @pytest .mark .parametrize ("style" , ["bullet" , "ordered" ])
122+ async def test_slack_list_preserves_links_and_mentions (style ):
123+ adapter = SlackAdapter (
124+ make_platform_config ("slack" , bot_token = "xoxb-test" , app_token = "xapp-test" ),
125+ {},
126+ asyncio .Queue (),
127+ )
128+ adapter .bot_self_id = "UBOT"
129+ adapter .web_client .users_info = AsyncMock (
130+ return_value = {"user" : {"real_name" : "Tester" }},
131+ )
132+ adapter .web_client .conversations_info = AsyncMock (
133+ return_value = {"channel" : {"is_im" : False , "name" : "test" }},
134+ )
135+ url = "https://example.com/slack-list-8642"
136+ received = await adapter .convert_message (
137+ {
138+ "user" : "UTEST" ,
139+ "channel" : "CTEST" ,
140+ "text" : f"<@UBOT> Link: { url } " ,
141+ "blocks" : [
142+ {
143+ "type" : "rich_text" ,
144+ "elements" : [
145+ {
146+ "type" : "rich_text_list" ,
147+ "style" : style ,
148+ "elements" : [
149+ {
150+ "type" : "rich_text_section" ,
151+ "elements" : [
152+ {"type" : "user" , "user_id" : "UBOT" },
153+ {"type" : "text" , "text" : " Link: " },
154+ {"type" : "link" , "url" : url , "text" : "Probe" },
155+ {"type" : "text" , "text" : " after" },
156+ ],
157+ },
158+ {
159+ "type" : "rich_text_section" ,
160+ "elements" : [{"type" : "link" , "url" : url }],
161+ },
162+ {
163+ "type" : "rich_text_section" ,
164+ "elements" : [{"type" : "user" , "user_id" : "UOTHER" }],
165+ },
166+ {
167+ "type" : "rich_text_section" ,
168+ "elements" : [{"type" : "text" , "text" : "End" }],
169+ },
170+ ],
171+ },
172+ ],
173+ },
174+ ],
175+ },
176+ )
177+
178+ assert [c .qq for c in received .message if isinstance (c , At )] == ["UBOT" , "UOTHER" ]
179+ assert received .message_str == (
180+ f"• Link: [Probe]({ url } ) after\n • [{ url } ]({ url } )\n • \n • End"
181+ )
182+ assert [type (c ) for c in received .message ] == [Plain , At , Plain , At , Plain ]
0 commit comments