mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Use SlidingSyncUntilMembership for subscription test
This commit is contained in:
parent
e8c4dc4b8c
commit
d5f96eba7a
@ -5,10 +5,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/matrix-org/sliding-sync/sync3"
|
||||
"github.com/matrix-org/sliding-sync/testutils/m"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func TestRoomStateTransitions(t *testing.T) {
|
||||
@ -627,32 +626,7 @@ func TestHeroesOnMembershipChanges(t *testing.T) {
|
||||
subRoomID := alice.CreateRoom(t, map[string]interface{}{"preset": "public_chat"})
|
||||
bob.JoinRoom(t, subRoomID, []string{})
|
||||
|
||||
res := alice.SlidingSyncUntil(t, "", sync3.Request{
|
||||
RoomSubscriptions: map[string]sync3.RoomSubscription{
|
||||
subRoomID: {
|
||||
TimelineLimit: 10,
|
||||
Heroes: &boolTrue,
|
||||
},
|
||||
},
|
||||
}, func(response *sync3.Response) error {
|
||||
r, ok := response.Rooms[subRoomID]
|
||||
if !ok {
|
||||
return fmt.Errorf("room %q not in response", subRoomID)
|
||||
}
|
||||
// wait for bob to be joined
|
||||
for _, ev := range r.Timeline {
|
||||
if gjson.GetBytes(ev, "type").Str != "m.room.member" {
|
||||
continue
|
||||
}
|
||||
if gjson.GetBytes(ev, "state_key").Str != bob.UserID {
|
||||
continue
|
||||
}
|
||||
if gjson.GetBytes(ev, "content.membership").Str == "join" {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%s is not joined to room %q", bob.UserID, subRoomID)
|
||||
})
|
||||
res := alice.SlidingSyncUntilMembership(t, "", subRoomID, bob, "join")
|
||||
if c := len(res.Rooms[subRoomID].Heroes); c > 1 {
|
||||
t.Errorf("expected 1 room hero, got %d", c)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user