-
Notifications
You must be signed in to change notification settings - Fork 61
MSC4308: Thread Subscriptions extension to Sliding Sync tests #802
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
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
16fd3bf
MSC4306: Thread Subscriptions Tests
reivilibre d78bd2a
Enable MSC4306 tests in CI for Synapse
reivilibre 62d906c
GetPushRule -> MustGetPushRule
reivilibre 4d86f15
Add non-failing GetPushRule
reivilibre 109ba45
Disable MSC4306 push rules in non-MSC4306 test
reivilibre 6a10106
MSC4308: Thread Subscriptions extension to Sliding Sync tests
reivilibre 9830388
Update tests/msc4306/thread_subscriptions_sliding_sync_test.go
reivilibre c3b27cb
Make it obvious it's MSC4308
reivilibre a203030
fixup! Update tests/msc4306/thread_subscriptions_sliding_sync_test.go
reivilibre 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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/matrix-org/complement" | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| complement.TestMain(m, "msc4306") | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/matrix-org/complement" | ||
| "github.com/matrix-org/complement/b" | ||
| "github.com/matrix-org/complement/client" | ||
| "github.com/matrix-org/complement/helpers" | ||
| "github.com/matrix-org/complement/match" | ||
| "github.com/matrix-org/complement/must" | ||
| "github.com/tidwall/gjson" | ||
| ) | ||
|
|
||
| func MustDoSlidingSync(t *testing.T, user *client.CSAPI, pos string, thread_subs_ext map[string]interface{}) (string, gjson.Result) { | ||
| body := map[string]interface{}{ | ||
| "extensions": map[string]interface{}{ | ||
| "io.element.msc4308.thread_subscriptions": thread_subs_ext, | ||
| }, | ||
| } | ||
| if pos != "" { | ||
| body["pos"] = pos | ||
| } | ||
| resp := user.MustDo(t, "POST", []string{"_matrix", "client", "unstable", "org.matrix.simplified_msc3575", "sync"}, client.WithJSONBody(t, body)) | ||
| respBody := client.ParseJSON(t, resp) | ||
|
|
||
| newPos := client.GetJSONFieldStr(t, respBody, "pos") | ||
| extension := client.GetOptionalJSONFieldObject(t, respBody, "extensions.io\\.element\\.msc4308\\.thread_subscriptions") | ||
| if !extension.Exists() { | ||
| // Missing extension is semantically the same as an empty one | ||
| // So eliminate the nil for simplicity | ||
| extension = gjson.Parse("{}") | ||
| } | ||
| return newPos, extension | ||
| } | ||
|
|
||
| func TestThreadSubscriptionsSlidingSync(t *testing.T) { | ||
| deployment := complement.Deploy(t, 1) | ||
| defer deployment.Destroy(t) | ||
|
|
||
| t.Run("Receives thread subscriptions over initial sliding sync", func(t *testing.T) { | ||
| alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) | ||
| roomID := alice.MustCreateRoom(t, map[string]interface{}{}) | ||
| threadRootID := alice.SendEventSynced(t, roomID, b.Event{ | ||
| Type: "m.room.message", | ||
| Content: map[string]interface{}{ | ||
| "msgtype": "m.text", | ||
| "body": "what do you think? reply in a thread!", | ||
| }, | ||
| }) | ||
|
|
||
| // Subscribe to the thread manually | ||
| alice.MustDo(t, "PUT", []string{"_matrix", "client", "unstable", "io.element.msc4306", "rooms", roomID, "thread", threadRootID, "subscription"}, client.WithJSONBody(t, map[string]interface{}{})) | ||
|
|
||
| _, ext := MustDoSlidingSync(t, alice, "", map[string]interface{}{ | ||
| "enabled": true, | ||
| "limit": 2, | ||
| }) | ||
reivilibre marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| must.MatchGJSON(t, ext, | ||
| match.JSONKeyTypeEqual("subscribed."+gjson.Escape(roomID)+"."+gjson.Escape(threadRootID)+".bump_stamp", gjson.Number), | ||
| match.JSONKeyEqual("subscribed."+gjson.Escape(roomID)+"."+gjson.Escape(threadRootID)+".automatic", false), | ||
| ) | ||
| }) | ||
|
|
||
| t.Run("Receives thread subscriptions over incremental sliding sync", func(t *testing.T) { | ||
| alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) | ||
| roomID := alice.MustCreateRoom(t, map[string]interface{}{}) | ||
| threadRootID := alice.SendEventSynced(t, roomID, b.Event{ | ||
| Type: "m.room.message", | ||
| Content: map[string]interface{}{ | ||
| "msgtype": "m.text", | ||
| "body": "what do you think? reply in a thread!", | ||
| }, | ||
| }) | ||
|
|
||
| newPos, ext := MustDoSlidingSync(t, alice, "", map[string]interface{}{ | ||
| "enabled": true, | ||
| "limit": 2, | ||
| }) | ||
| must.MatchGJSON(t, ext, | ||
| match.JSONKeyMissing("subscribed")) | ||
|
|
||
| // Subscribe to the thread manually | ||
| alice.MustDo(t, "PUT", []string{"_matrix", "client", "unstable", "io.element.msc4306", "rooms", roomID, "thread", threadRootID, "subscription"}, client.WithJSONBody(t, map[string]interface{}{})) | ||
|
|
||
| _, ext = MustDoSlidingSync(t, alice, newPos, map[string]interface{}{ | ||
| "enabled": true, | ||
| "limit": 2, | ||
| }) | ||
|
|
||
| must.MatchGJSON(t, ext, | ||
| match.JSONKeyTypeEqual("subscribed."+gjson.Escape(roomID)+"."+gjson.Escape(threadRootID)+".bump_stamp", gjson.Number), | ||
| match.JSONKeyEqual("subscribed."+gjson.Escape(roomID)+"."+gjson.Escape(threadRootID)+".automatic", false), | ||
| ) | ||
| }) | ||
| } | ||
Oops, something went wrong.
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.
Even though we're organizing this in MSC4306 for convenience and grouping, we should probably call this out as MSC4308 in the comments at-least