mirror of
https://github.com/element-hq/synapse
synced 2024-09-29 14:42:42 +00:00
Add rest test
This commit is contained in:
parent
a917edad8c
commit
84eaeeafa8
2 changed files with 60 additions and 1 deletions
|
@ -1341,6 +1341,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
||||||
# Create the rooms as user2 so we can have user1 with a clean slate to work from
|
# Create the rooms as user2 so we can have user1 with a clean slate to work from
|
||||||
# and join in whatever order we need for the tests.
|
# and join in whatever order we need for the tests.
|
||||||
room_id1 = self.helper.create_room_as(user2_id, tok=user2_tok, is_public=True)
|
room_id1 = self.helper.create_room_as(user2_id, tok=user2_tok, is_public=True)
|
||||||
|
# If we're testing knocks, set the room to knock
|
||||||
if room1_membership == Membership.KNOCK:
|
if room1_membership == Membership.KNOCK:
|
||||||
self.helper.send_state(
|
self.helper.send_state(
|
||||||
room_id1,
|
room_id1,
|
||||||
|
@ -1352,6 +1353,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
||||||
room_id3 = self.helper.create_room_as(user2_id, tok=user2_tok, is_public=True)
|
room_id3 = self.helper.create_room_as(user2_id, tok=user2_tok, is_public=True)
|
||||||
|
|
||||||
# Here is the activity with user1 that will determine the sort of the rooms
|
# Here is the activity with user1 that will determine the sort of the rooms
|
||||||
|
# (room2, room1, room3)
|
||||||
self.helper.join(room_id3, user1_id, tok=user1_tok)
|
self.helper.join(room_id3, user1_id, tok=user1_tok)
|
||||||
if room1_membership == Membership.LEAVE:
|
if room1_membership == Membership.LEAVE:
|
||||||
self.helper.join(room_id1, user1_id, tok=user1_tok)
|
self.helper.join(room_id1, user1_id, tok=user1_tok)
|
||||||
|
@ -1364,7 +1366,7 @@ class SortRoomsTestCase(HomeserverTestCase):
|
||||||
self.helper.ban(room_id1, src=user2_id, targ=user1_id, tok=user2_tok)
|
self.helper.ban(room_id1, src=user2_id, targ=user1_id, tok=user2_tok)
|
||||||
self.helper.join(room_id2, user1_id, tok=user1_tok)
|
self.helper.join(room_id2, user1_id, tok=user1_tok)
|
||||||
|
|
||||||
# Activity before the token but the user is only invited to this room so it
|
# Activity before the token but the user is only been xxx to this room so it
|
||||||
# shouldn't be taken into account
|
# shouldn't be taken into account
|
||||||
self.helper.send(room_id1, "activity in room1", tok=user2_tok)
|
self.helper.send(room_id1, "activity in room1", tok=user2_tok)
|
||||||
|
|
||||||
|
|
|
@ -1459,3 +1459,60 @@ class SlidingSyncTestCase(unittest.HomeserverTestCase):
|
||||||
],
|
],
|
||||||
list(channel.json_body["lists"]["foo-list"]),
|
list(channel.json_body["lists"]["foo-list"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_sort_list(self) -> None:
|
||||||
|
"""
|
||||||
|
Test that the lists are sorted by `stream_ordering`
|
||||||
|
"""
|
||||||
|
user1_id = self.register_user("user1", "pass")
|
||||||
|
user1_tok = self.login(user1_id, "pass")
|
||||||
|
|
||||||
|
room_id1 = self.helper.create_room_as(user1_id, tok=user1_tok, is_public=True)
|
||||||
|
room_id2 = self.helper.create_room_as(user1_id, tok=user1_tok, is_public=True)
|
||||||
|
room_id3 = self.helper.create_room_as(user1_id, tok=user1_tok, is_public=True)
|
||||||
|
|
||||||
|
# Activity that will order the rooms
|
||||||
|
self.helper.send(room_id3, "activity in room3", tok=user1_tok)
|
||||||
|
self.helper.send(room_id1, "activity in room1", tok=user1_tok)
|
||||||
|
self.helper.send(room_id2, "activity in room2", tok=user1_tok)
|
||||||
|
|
||||||
|
# Make the Sliding Sync request
|
||||||
|
channel = self.make_request(
|
||||||
|
"POST",
|
||||||
|
self.sync_endpoint,
|
||||||
|
{
|
||||||
|
"lists": {
|
||||||
|
"foo-list": {
|
||||||
|
"ranges": [[0, 99]],
|
||||||
|
"required_state": [
|
||||||
|
["m.room.join_rules", ""],
|
||||||
|
["m.room.history_visibility", ""],
|
||||||
|
["m.space.child", "*"],
|
||||||
|
],
|
||||||
|
"timeline_limit": 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
access_token=user1_tok,
|
||||||
|
)
|
||||||
|
self.assertEqual(channel.code, 200, channel.json_body)
|
||||||
|
|
||||||
|
# Make sure it has the foo-list we requested
|
||||||
|
self.assertListEqual(
|
||||||
|
list(channel.json_body["lists"].keys()),
|
||||||
|
["foo-list"],
|
||||||
|
channel.json_body["lists"].keys(),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make sure the list is sorted in the way we expect
|
||||||
|
self.assertListEqual(
|
||||||
|
list(channel.json_body["lists"]["foo-list"]["ops"]),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"op": "SYNC",
|
||||||
|
"range": [0, 99],
|
||||||
|
"room_ids": [room_id2, room_id1, room_id3],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
channel.json_body["lists"]["foo-list"],
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue