@@ -560,43 +560,6 @@ def test_edit_reply(self) -> None:
560
560
{"event_id" : edit_event_id , "sender" : self .user_id }, m_replace_dict
561
561
)
562
562
563
- def test_edit_thread (self ) -> None :
564
- """Test that editing a thread works."""
565
-
566
- # Create a thread and edit the last event.
567
- channel = self ._send_relation (
568
- RelationTypes .THREAD ,
569
- "m.room.message" ,
570
- content = {"msgtype" : "m.text" , "body" : "A threaded reply!" },
571
- )
572
- threaded_event_id = channel .json_body ["event_id" ]
573
-
574
- new_body = {"msgtype" : "m.text" , "body" : "I've been edited!" }
575
- self ._send_relation (
576
- RelationTypes .REPLACE ,
577
- "m.room.message" ,
578
- content = {"msgtype" : "m.text" , "body" : "foo" , "m.new_content" : new_body },
579
- parent_id = threaded_event_id ,
580
- )
581
-
582
- # Fetch the thread root, to get the bundled aggregation for the thread.
583
- channel = self .make_request (
584
- "GET" ,
585
- f"/rooms/{ self .room } /event/{ self .parent_id } " ,
586
- access_token = self .user_token ,
587
- )
588
- self .assertEqual (200 , channel .code , channel .json_body )
589
-
590
- # We expect that the edit message appears in the thread summary in the
591
- # unsigned relations section.
592
- relations_dict = channel .json_body ["unsigned" ].get ("m.relations" )
593
- self .assertIn (RelationTypes .THREAD , relations_dict )
594
-
595
- thread_summary = relations_dict [RelationTypes .THREAD ]
596
- self .assertIn ("latest_event" , thread_summary )
597
- latest_event_in_thread = thread_summary ["latest_event" ]
598
- self .assertEqual (latest_event_in_thread ["content" ]["body" ], "I've been edited!" )
599
-
600
563
def test_edit_edit (self ) -> None :
601
564
"""Test that an edit cannot be edited."""
602
565
new_body = {"msgtype" : "m.text" , "body" : "Initial edit" }
@@ -1047,7 +1010,7 @@ def test_thread(self) -> None:
1047
1010
channel = self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1048
1011
thread_2 = channel .json_body ["event_id" ]
1049
1012
1050
- def assert_annotations (bundled_aggregations : JsonDict ) -> None :
1013
+ def assert_thread (bundled_aggregations : JsonDict ) -> None :
1051
1014
self .assertEqual (2 , bundled_aggregations .get ("count" ))
1052
1015
self .assertTrue (bundled_aggregations .get ("current_user_participated" ))
1053
1016
# The latest thread event has some fields that don't matter.
@@ -1066,7 +1029,38 @@ def assert_annotations(bundled_aggregations: JsonDict) -> None:
1066
1029
bundled_aggregations .get ("latest_event" ),
1067
1030
)
1068
1031
1069
- self ._test_bundled_aggregations (RelationTypes .THREAD , assert_annotations , 9 )
1032
+ self ._test_bundled_aggregations (RelationTypes .THREAD , assert_thread , 9 )
1033
+
1034
+ def test_thread_edit_latest_event (self ) -> None :
1035
+ """Test that editing the latest event in a thread works."""
1036
+
1037
+ # Create a thread and edit the last event.
1038
+ channel = self ._send_relation (
1039
+ RelationTypes .THREAD ,
1040
+ "m.room.message" ,
1041
+ content = {"msgtype" : "m.text" , "body" : "A threaded reply!" },
1042
+ )
1043
+ threaded_event_id = channel .json_body ["event_id" ]
1044
+
1045
+ new_body = {"msgtype" : "m.text" , "body" : "I've been edited!" }
1046
+ channel = self ._send_relation (
1047
+ RelationTypes .REPLACE ,
1048
+ "m.room.message" ,
1049
+ content = {"msgtype" : "m.text" , "body" : "foo" , "m.new_content" : new_body },
1050
+ parent_id = threaded_event_id ,
1051
+ )
1052
+
1053
+ # Fetch the thread root, to get the bundled aggregation for the thread.
1054
+ relations_dict = self ._get_bundled_aggregations ()
1055
+
1056
+ # We expect that the edit message appears in the thread summary in the
1057
+ # unsigned relations section.
1058
+ self .assertIn (RelationTypes .THREAD , relations_dict )
1059
+
1060
+ thread_summary = relations_dict [RelationTypes .THREAD ]
1061
+ self .assertIn ("latest_event" , thread_summary )
1062
+ latest_event_in_thread = thread_summary ["latest_event" ]
1063
+ self .assertEqual (latest_event_in_thread ["content" ]["body" ], "I've been edited!" )
1070
1064
1071
1065
def test_aggregation_get_event_for_annotation (self ) -> None :
1072
1066
"""Test that annotations do not get bundled aggregations included
@@ -1093,7 +1087,7 @@ def test_aggregation_get_event_for_thread(self) -> None:
1093
1087
channel = self ._send_relation (RelationTypes .THREAD , "m.room.test" )
1094
1088
thread_id = channel .json_body ["event_id" ]
1095
1089
1096
- # Annotate the annotation .
1090
+ # Annotate the thread .
1097
1091
self ._send_relation (
1098
1092
RelationTypes .ANNOTATION , "m.reaction" , "a" , parent_id = thread_id
1099
1093
)
0 commit comments