@@ -1710,40 +1710,53 @@ def test_redact_parent_thread(self) -> None:
17101710
17111711
17121712class  ThreadsTestCase (BaseRelationsTestCase ):
1713-     @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }}) 
1713+     def  _get_threads (self , body : JsonDict ) ->  List [Tuple [str , str ]]:
1714+         return  [
1715+             (
1716+                 ev ["event_id" ],
1717+                 ev ["unsigned" ]["m.relations" ]["m.thread" ]["latest_event" ]["event_id" ],
1718+             )
1719+             for  ev  in  body ["chunk" ]
1720+         ]
1721+ 
17141722    def  test_threads (self ) ->  None :
17151723        """Create threads and ensure the ordering is due to their latest event.""" 
17161724        # Create 2 threads. 
17171725        thread_1  =  self .parent_id 
17181726        res  =  self .helper .send (self .room , body = "Thread Root!" , tok = self .user_token )
17191727        thread_2  =  res ["event_id" ]
17201728
1721-         self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1722-         self ._send_relation (RelationTypes .THREAD , "m.room.test" , parent_id = thread_2 )
1729+         channel  =  self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1730+         reply_1  =  channel .json_body ["event_id" ]
1731+         channel  =  self ._send_relation (
1732+             RelationTypes .THREAD , "m.room.test" , parent_id = thread_2 
1733+         )
1734+         reply_2  =  channel .json_body ["event_id" ]
17231735
17241736        # Request the threads in the room. 
17251737        channel  =  self .make_request (
17261738            "GET" ,
1727-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads" ,
1739+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads" ,
17281740            access_token = self .user_token ,
17291741        )
17301742        self .assertEquals (200 , channel .code , channel .json_body )
1731-         thread_roots  =  [ ev [ "event_id" ]  for   ev   in   channel .json_body [ "chunk" ]] 
1732-         self .assertEqual (thread_roots , [thread_2 , thread_1 ])
1743+         threads  =  self . _get_threads ( channel .json_body ) 
1744+         self .assertEqual (threads , [( thread_2 , reply_2 ), ( thread_1 ,  reply_1 ) ])
17331745
17341746        # Update the first thread, the ordering should swap. 
1735-         self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1747+         channel  =  self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1748+         reply_3  =  channel .json_body ["event_id" ]
17361749
17371750        channel  =  self .make_request (
17381751            "GET" ,
1739-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads" ,
1752+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads" ,
17401753            access_token = self .user_token ,
17411754        )
17421755        self .assertEquals (200 , channel .code , channel .json_body )
1743-         thread_roots  =  [ev ["event_id" ] for  ev  in  channel .json_body ["chunk" ]]
1744-         self .assertEqual (thread_roots , [thread_1 , thread_2 ])
1756+         # Tuple of (thread ID, latest event ID) for each thread. 
1757+         threads  =  self ._get_threads (channel .json_body )
1758+         self .assertEqual (threads , [(thread_1 , reply_3 ), (thread_2 , reply_2 )])
17451759
1746-     @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }}) 
17471760    def  test_pagination (self ) ->  None :
17481761        """Create threads and paginate through them.""" 
17491762        # Create 2 threads. 
@@ -1757,7 +1770,7 @@ def test_pagination(self) -> None:
17571770        # Request the threads in the room. 
17581771        channel  =  self .make_request (
17591772            "GET" ,
1760-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads?limit=1" ,
1773+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads?limit=1" ,
17611774            access_token = self .user_token ,
17621775        )
17631776        self .assertEquals (200 , channel .code , channel .json_body )
@@ -1771,7 +1784,7 @@ def test_pagination(self) -> None:
17711784
17721785        channel  =  self .make_request (
17731786            "GET" ,
1774-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads?limit=1&from={ next_batch }  " ,
1787+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads?limit=1&from={ next_batch }  " ,
17751788            access_token = self .user_token ,
17761789        )
17771790        self .assertEquals (200 , channel .code , channel .json_body )
@@ -1780,7 +1793,6 @@ def test_pagination(self) -> None:
17801793
17811794        self .assertNotIn ("next_batch" , channel .json_body , channel .json_body )
17821795
1783-     @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }}) 
17841796    def  test_include (self ) ->  None :
17851797        """Filtering threads to all or participated in should work.""" 
17861798        # Thread 1 has the user as the root event. 
@@ -1807,7 +1819,7 @@ def test_include(self) -> None:
18071819        # All threads in the room. 
18081820        channel  =  self .make_request (
18091821            "GET" ,
1810-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads" ,
1822+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads" ,
18111823            access_token = self .user_token ,
18121824        )
18131825        self .assertEquals (200 , channel .code , channel .json_body )
@@ -1819,14 +1831,13 @@ def test_include(self) -> None:
18191831        # Only participated threads. 
18201832        channel  =  self .make_request (
18211833            "GET" ,
1822-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads?include=participated" ,
1834+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads?include=participated" ,
18231835            access_token = self .user_token ,
18241836        )
18251837        self .assertEquals (200 , channel .code , channel .json_body )
18261838        thread_roots  =  [ev ["event_id" ] for  ev  in  channel .json_body ["chunk" ]]
18271839        self .assertEqual (thread_roots , [thread_2 , thread_1 ], channel .json_body )
18281840
1829-     @unittest .override_config ({"experimental_features" : {"msc3856_enabled" : True }}) 
18301841    def  test_ignored_user (self ) ->  None :
18311842        """Events from ignored users should be ignored.""" 
18321843        # Thread 1 has a reply from an ignored user. 
@@ -1852,7 +1863,7 @@ def test_ignored_user(self) -> None:
18521863        # Only thread 1 is returned. 
18531864        channel  =  self .make_request (
18541865            "GET" ,
1855-             f"/_matrix/client/unstable/org.matrix.msc3856 /rooms/{ self .room }  /threads" ,
1866+             f"/_matrix/client/v1 /rooms/{ self .room }  /threads" ,
18561867            access_token = self .user_token ,
18571868        )
18581869        self .assertEquals (200 , channel .code , channel .json_body )
0 commit comments