-
Notifications
You must be signed in to change notification settings - Fork 66
TestJumpToDateEndpoint: Clarify why we use /context end for paginating backwards despite the spec saying "A token that can be used to paginate forwards with."
#852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MadLittleMods
merged 5 commits into
main
from
madlittlemods/clarify-why-end-timestamp-to-event-test
Apr 10, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a03b187
Clarify why we use `end` despite the spec saying "A token that can be…
MadLittleMods 91c73f9
Clarify desire
MadLittleMods 9c6c144
Fix 'to' missing typo
MadLittleMods 8abd31a
Be more specific
MadLittleMods 4513157
Merge branch 'main' into madlittlemods/clarify-why-end-timestamp-to-e…
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,10 +213,20 @@ func TestJumpToDateEndpoint(t *testing.T) { | |
| mustCheckEventisReturnedForTime(t, remoteCharlie, roomID, eventB.AfterTimestamp, "b", eventB.EventID) | ||
|
|
||
| // Get a pagination token from eventB | ||
| contextRes := remoteCharlie.MustDo(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "context", eventB.EventID}, client.WithContentType("application/json"), client.WithQueries(url.Values{ | ||
| "limit": []string{"0"}, | ||
| })) | ||
| contextRes := remoteCharlie.MustDo(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "context", eventB.EventID}, | ||
| client.WithContentType("application/json"), client.WithQueries(url.Values{ | ||
| "limit": []string{"0"}, | ||
| }), | ||
| ) | ||
| contextResResBody := client.ParseJSON(t, contextRes) | ||
| // Remember: Tokens are positions between events. Normally, you would use the | ||
| // `start` token to paginate backwards with but for the sake of the test we want | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // to paginate `/messages` and want see both A and B in the response; so we use | ||
| // the `end` token. The `end` token comes after B. | ||
| // | ||
| // start end | ||
| // | | | ||
| // [A] <-- ▼ [B] ▼ <--- [remoteCharlie join] | ||
|
Comment on lines
+222
to
+229
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inspired by these comments in Synapse |
||
| paginationToken := client.GetJSONFieldStr(t, contextResResBody, "end") | ||
|
|
||
| // Hit `/messages` until `eventA` has been backfilled and replicated across | ||
|
|
@@ -226,12 +236,15 @@ func TestJumpToDateEndpoint(t *testing.T) { | |
| return ev.Get("event_id").Str == eventA.EventID | ||
| }) | ||
|
|
||
| // Paginate backwards from eventB | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| messagesRes := remoteCharlie.MustDo(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithContentType("application/json"), client.WithQueries(url.Values{ | ||
| "dir": []string{"b"}, | ||
| "limit": []string{"100"}, | ||
| "from": []string{paginationToken}, | ||
| })) | ||
| // Paginate backwards from the point after eventB | ||
| messagesRes := remoteCharlie.MustDo(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, | ||
| client.WithContentType("application/json"), | ||
| client.WithQueries(url.Values{ | ||
| "dir": []string{"b"}, | ||
| "limit": []string{"100"}, | ||
| "from": []string{paginationToken}, | ||
| }), | ||
| ) | ||
|
|
||
| // Make sure both messages are visible | ||
| must.MatchResponse(t, messagesRes, match.HTTPResponse{ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just line wrapping this better. There is no functional change in this PR.