@@ -1593,6 +1593,96 @@ def test_transform_content(self, mocker, raw_html, expected_content):
1593
1593
rendered_text = Text (content )
1594
1594
assert rendered_text .text == expected_content
1595
1595
1596
+ @pytest .mark .parametrize (
1597
+ "raw_html, expected_message_links" ,
1598
+ [
1599
+ (
1600
+ """
1601
+ <p><a href="https://github.com/zulip/zulip-terminal/pull/1">https://github.com/zulip/zulip-terminal/pull/1</a></p>
1602
+ """ ,
1603
+ {
1604
+ "https://github.com/zulip/zulip-terminal/pull/1" : (
1605
+ "github.com" ,
1606
+ 1 ,
1607
+ True ,
1608
+ )
1609
+ },
1610
+ ),
1611
+ (
1612
+ """
1613
+ <p><a href="https://foo.com">https://foo.com</a></p>
1614
+ """ ,
1615
+ {"https://foo.com" : ("https://foo.com" , 1 , False )},
1616
+ ),
1617
+ (
1618
+ """
1619
+ <p><a href="#narrow/stream/206-zulip-terminal/topic/announce">https://chat.zulip.zulip/#narrow/stream/206-zulip-terminal/topic/announce</a></p>
1620
+ """ ,
1621
+ {
1622
+ "https://chat.zulip.zulip#narrow/stream/206-zulip-terminal/topic/announce" : ( # noqa: E501
1623
+ "https://chat.zulip.zulip/#narrow/stream/206-zulip-terminal/topic/announce" ,
1624
+ 1 ,
1625
+ True ,
1626
+ )
1627
+ },
1628
+ ),
1629
+ ],
1630
+ )
1631
+ def test_transform_content_message_links (
1632
+ self , mocker , raw_html , expected_message_links
1633
+ ):
1634
+ _ , message_links , * _ = MessageBox .transform_content (raw_html , SERVER_URL )
1635
+
1636
+ assert message_links == expected_message_links
1637
+
1638
+ @pytest .mark .parametrize (
1639
+ "raw_html, expected_time_mentions" ,
1640
+ [
1641
+ (
1642
+ """
1643
+ <p><time datetime="2024-05-29T11:30:00Z">2024-05-29T17:00:00+05:30</time></p>
1644
+ """ , # noqa: E501
1645
+ [
1646
+ (
1647
+ "Wed, May 29 2024, 17:00 (IST)" ,
1648
+ "Original text was 2024-05-29T17:00:00+05:30" ,
1649
+ )
1650
+ ],
1651
+ ),
1652
+ (
1653
+ """
1654
+ <p><time datetime="3000-06-01T14:00:00Z">3000-06-01T19:30:00+05:30</time></p>
1655
+ """ , # noqa: E501
1656
+ [
1657
+ (
1658
+ "Sun, Jun 1 3000, 19:30 (IST)" ,
1659
+ "Original text was 3000-06-01T19:30:00+05:30" ,
1660
+ )
1661
+ ],
1662
+ ),
1663
+ (
1664
+ """
1665
+ <p><time datetime="1947-08-14T19:47:00Z">1947-08-15T01:17:00+05:30</time></p>
1666
+ """ , # noqa: E501
1667
+ [
1668
+ (
1669
+ "Fri, Aug 15 1947, 1:17 (IST)" ,
1670
+ "Original text was 1947-08-15T01:17:00+05:30" ,
1671
+ )
1672
+ ],
1673
+ ),
1674
+ ],
1675
+ )
1676
+ def test_transform_content_time_mentions (
1677
+ self , mocker , raw_html , expected_time_mentions
1678
+ ):
1679
+ mocker .patch (
1680
+ MODULE + ".get_localzone" , return_value = pytz .timezone ("Asia/Kolkata" )
1681
+ )
1682
+ _ , _ , time_mentions , * _ = MessageBox .transform_content (raw_html , SERVER_URL )
1683
+
1684
+ assert time_mentions == expected_time_mentions
1685
+
1596
1686
# FIXME This is the same parametrize as MsgInfoView:test_height_reactions
1597
1687
@pytest .mark .parametrize (
1598
1688
"to_vary_in_each_message, expected_text, expected_attributes" ,
0 commit comments