Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Test behavior of /relations for a redacted relation.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 1, 2022
1 parent c53f166 commit 7cd9931
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,12 @@ def _redact(self, event_id: str) -> None:
self.assertEqual(200, channel.code, channel.json_body)

def test_redact_relation_annotation(self) -> None:
"""Test that annotations of an event are properly handled after the
"""
Test that annotations of an event are properly handled after the
annotation is redacted.
The redacted relation should not be included in bundled aggregations or
the response to relations.
"""
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "a")
self.assertEqual(200, channel.code, channel.json_body)
Expand All @@ -1369,11 +1373,34 @@ def test_redact_relation_annotation(self) -> None:
RelationTypes.ANNOTATION, "m.reaction", "a", access_token=self.user2_token
)
self.assertEqual(200, channel.code, channel.json_body)
unredacted_event_id = channel.json_body["event_id"]

# Redact one of the reactions.
self._redact(to_redact_event_id)

# Ensure that the aggregations are correct.
# The unredacted relation should still exist.
channel = self.make_request(
"GET",
f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}",
access_token=self.user_token,
)
self.assertEquals(200, channel.code, channel.json_body)
event_ids = [ev["event_id"] for ev in channel.json_body["chunk"]]
self.assertEquals(event_ids, [unredacted_event_id])

# The unredacted relation should appear in the bundled aggregation.
channel = self.make_request(
"GET",
f"/_matrix/client/unstable/rooms/{self.room}/event/{self.parent_id}",
access_token=self.user_token,
)
self.assertEquals(200, channel.code, channel.json_body)
self.assertEquals(
channel.json_body["unsigned"]["m.relations"]["m.annotation"],
{"chunk": [{"type": "m.reaction", "key": "a", "count": 1}]},
)

# The unredacted aggregation should still exist.
channel = self.make_request(
"GET",
f"/_matrix/client/unstable/rooms/{self.room}/aggregations/{self.parent_id}",
Expand Down

0 comments on commit 7cd9931

Please sign in to comment.