From 76289a8fd348c013f52acd4cb0c425f702d3dde6 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 1 Mar 2022 10:02:00 -0500 Subject: [PATCH] Add tests for thread relations. --- tests/rest/client/test_relations.py | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py index 2c4412bed7b3..b23386649d7f 100644 --- a/tests/rest/client/test_relations.py +++ b/tests/rest/client/test_relations.py @@ -1579,3 +1579,34 @@ def test_redact_parent_annotation(self) -> None: # There's nothing to aggregate. chunk = self._get_aggregations() self.assertEqual(chunk, [{"count": 1, "key": "👍", "type": "m.reaction"}]) + + @unittest.override_config({"experimental_features": {"msc3440_enabled": True}}) + def test_redact_parent_thread(self) -> None: + """ + Test that thread replies are still available when the root event is redacted. + """ + channel = self._send_relation( + RelationTypes.THREAD, + EventTypes.Message, + content={"body": "reply 1", "msgtype": "m.text"}, + ) + self.assertEqual(200, channel.code, channel.json_body) + related_event_id = channel.json_body["event_id"] + + # Redact one of the reactions. + self._redact(self.parent_id) + + # The unredacted relation should still exist. + event_ids, relations = self._make_relation_requests() + self.assertEquals(len(event_ids), 1) + self.assertDictContainsSubset( + { + "count": 1, + "current_user_participated": True, + }, + relations[RelationTypes.THREAD], + ) + self.assertEqual( + relations[RelationTypes.THREAD]["latest_event"]["event_id"], + related_event_id, + )