@@ -169,24 +169,28 @@ def test_basic_paginate_relations(self):
169
169
"""Tests that calling pagination API correctly the latest relations."""
170
170
channel = self ._send_relation (RelationTypes .ANNOTATION , "m.reaction" , "a" )
171
171
self .assertEquals (200 , channel .code , channel .json_body )
172
+ first_annotation_id = channel .json_body ["event_id" ]
172
173
173
174
channel = self ._send_relation (RelationTypes .ANNOTATION , "m.reaction" , "b" )
174
175
self .assertEquals (200 , channel .code , channel .json_body )
175
- annotation_id = channel .json_body ["event_id" ]
176
+ second_annotation_id = channel .json_body ["event_id" ]
176
177
177
178
channel = self .make_request (
178
179
"GET" ,
179
- "/_matrix/client/unstable/rooms/%s/relations/%s?limit=1"
180
- % (self .room , self .parent_id ),
180
+ f"/_matrix/client/unstable/rooms/{ self .room } /relations/{ self .parent_id } ?limit=1" ,
181
181
access_token = self .user_token ,
182
182
)
183
183
self .assertEquals (200 , channel .code , channel .json_body )
184
184
185
- # We expect to get back a single pagination result, which is the full
186
- # relation event we sent above.
185
+ # We expect to get back a single pagination result, which is the latest
186
+ # full relation event we sent above.
187
187
self .assertEquals (len (channel .json_body ["chunk" ]), 1 , channel .json_body )
188
188
self .assert_dict (
189
- {"event_id" : annotation_id , "sender" : self .user_id , "type" : "m.reaction" },
189
+ {
190
+ "event_id" : second_annotation_id ,
191
+ "sender" : self .user_id ,
192
+ "type" : "m.reaction" ,
193
+ },
190
194
channel .json_body ["chunk" ][0 ],
191
195
)
192
196
@@ -201,6 +205,27 @@ def test_basic_paginate_relations(self):
201
205
channel .json_body .get ("next_batch" ), str , channel .json_body
202
206
)
203
207
208
+ # Request the relations again, but with a different direction.
209
+ channel = self .make_request (
210
+ "GET" ,
211
+ f"/_matrix/client/unstable/rooms/{ self .room } /relations"
212
+ f"/{ self .parent_id } ?limit=1&org.matrix.msc3715.dir=f" ,
213
+ access_token = self .user_token ,
214
+ )
215
+ self .assertEquals (200 , channel .code , channel .json_body )
216
+
217
+ # We expect to get back a single pagination result, which is the earliest
218
+ # full relation event we sent above.
219
+ self .assertEquals (len (channel .json_body ["chunk" ]), 1 , channel .json_body )
220
+ self .assert_dict (
221
+ {
222
+ "event_id" : first_annotation_id ,
223
+ "sender" : self .user_id ,
224
+ "type" : "m.reaction" ,
225
+ },
226
+ channel .json_body ["chunk" ][0 ],
227
+ )
228
+
204
229
def _stream_token_to_relation_token (self , token : str ) -> str :
205
230
"""Convert a StreamToken into a legacy token (RelationPaginationToken)."""
206
231
room_key = self .get_success (StreamToken .from_string (self .store , token )).room_key
0 commit comments