Skip to content

Commit 08e9a88

Browse files
Add test to make sure we can paginate after getting remote event from timestamp to event endpoint (#406)
Synapse changes: matrix-org/synapse#13205
1 parent ed5f21d commit 08e9a88

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/msc3030_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616

1717
"github.com/matrix-org/complement/internal/b"
1818
"github.com/matrix-org/complement/internal/client"
19+
"github.com/matrix-org/complement/internal/match"
20+
"github.com/matrix-org/complement/internal/must"
1921
"github.com/tidwall/gjson"
2022
)
2123

@@ -163,6 +165,36 @@ func TestJumpToDateEndpoint(t *testing.T) {
163165
remoteCharlie.JoinRoom(t, roomID, []string{"hs1"})
164166
mustCheckEventisReturnedForTime(t, remoteCharlie, roomID, timeBeforeRoomCreation, "b", importedEventID)
165167
})
168+
169+
t.Run("can paginate after getting remote event from timestamp to event endpoint", func(t *testing.T) {
170+
t.Parallel()
171+
roomID, eventA, eventB := createTestRoom(t, alice)
172+
remoteCharlie.JoinRoom(t, roomID, []string{"hs1"})
173+
mustCheckEventisReturnedForTime(t, remoteCharlie, roomID, eventB.AfterTimestamp, "b", eventB.EventID)
174+
175+
// Get a pagination token from eventB
176+
contextRes := remoteCharlie.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "context", eventB.EventID}, client.WithContentType("application/json"), client.WithQueries(url.Values{
177+
"limit": []string{"0"},
178+
}))
179+
contextResResBody := client.ParseJSON(t, contextRes)
180+
paginationToken := client.GetJSONFieldStr(t, contextResResBody, "end")
181+
182+
// Paginate backwards from eventB
183+
messagesRes := remoteCharlie.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithContentType("application/json"), client.WithQueries(url.Values{
184+
"dir": []string{"b"},
185+
"limit": []string{"100"},
186+
"from": []string{paginationToken},
187+
}))
188+
189+
// Make sure both messages are visible
190+
must.MatchResponse(t, messagesRes, match.HTTPResponse{
191+
JSON: []match.JSON{
192+
match.JSONCheckOffAllowUnwanted("chunk", []interface{}{eventA.EventID, eventB.EventID}, func(r gjson.Result) interface{} {
193+
return r.Get("event_id").Str
194+
}, nil),
195+
},
196+
})
197+
})
166198
})
167199
})
168200
}

0 commit comments

Comments
 (0)