Skip to content
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

Pass lazy loading filter to sync reqs in room summary tests #597

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions tests/csapi/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,33 @@ func TestPresenceSyncDifferentRooms(t *testing.T) {
})
}

func getLazyLoadingSyncFilter() string {
j, _ := json.Marshal(map[string]interface{}{
"room": map[string]interface{}{
"timeline": map[string]interface{}{
"lazy_load_members": true,
},
"state": map[string]interface{}{
"lazy_load_members": true,
},
},
})
return string(j)
}

func TestRoomSummary(t *testing.T) {
runtime.SkipIf(t, runtime.Synapse) // Currently more of a Dendrite test, so skip on Synapse
deployment := Deploy(t, b.BlueprintOneToOneRoom)
defer deployment.Destroy(t)
alice := deployment.Client(t, "hs1", "@alice:hs1")
bob := deployment.Client(t, "hs1", "@bob:hs1")
lazyLoadingFilter := getLazyLoadingSyncFilter()

_, aliceSince := alice.MustSync(t, client.SyncReq{TimeoutMillis: "0"})
_, aliceSince := alice.MustSync(t, client.SyncReq{TimeoutMillis: "0", Filter: lazyLoadingFilter})
roomID := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"invite": []string{bob.UserID},
})
aliceSince = alice.MustSyncUntil(t, client.SyncReq{Since: aliceSince},
aliceSince = alice.MustSyncUntil(t, client.SyncReq{Since: aliceSince, Filter: lazyLoadingFilter},
client.SyncJoinedTo(alice.UserID, roomID),
func(clientUserID string, syncResp gjson.Result) error {
summary := syncResp.Get("rooms.join." + client.GjsonEscape(roomID) + ".summary")
Expand All @@ -471,12 +485,12 @@ func TestRoomSummary(t *testing.T) {
return nil
}

sinceToken := bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID))
sinceToken := bob.MustSyncUntil(t, client.SyncReq{Filter: lazyLoadingFilter}, client.SyncInvitedTo(bob.UserID, roomID))
bob.JoinRoom(t, roomID, []string{})
// Verify Bob sees the correct room summary
bob.MustSyncUntil(t, client.SyncReq{Since: sinceToken}, client.SyncJoinedTo(bob.UserID, roomID), joinedCheck)
bob.MustSyncUntil(t, client.SyncReq{Since: sinceToken, Filter: lazyLoadingFilter}, client.SyncJoinedTo(bob.UserID, roomID), joinedCheck)
// .. and Alice as well.
alice.MustSyncUntil(t, client.SyncReq{Since: aliceSince}, client.SyncJoinedTo(bob.UserID, roomID), joinedCheck)
alice.MustSyncUntil(t, client.SyncReq{Since: aliceSince, Filter: lazyLoadingFilter}, client.SyncJoinedTo(bob.UserID, roomID), joinedCheck)
}

func sendMessages(t *testing.T, client *client.CSAPI, roomID string, prefix string, count int) {
Expand Down