mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Add failing test
This commit is contained in:
parent
6ad321d86c
commit
93b150de7c
@ -397,6 +397,63 @@ func TestInviteRejectionTwice(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestLeavingRoomReturnsOneEvent(t *testing.T) {
|
||||
alice := registerNewUser(t)
|
||||
bob := registerNewUser(t)
|
||||
roomName := "It's-a-me-invitio"
|
||||
inviteRoomID := alice.CreateRoom(t, map[string]interface{}{"preset": "private_chat", "name": roomName})
|
||||
t.Logf("TestLeavingRoomReturnsOneEvent room %s", inviteRoomID)
|
||||
|
||||
// sync as bob, we see no invites yet.
|
||||
res := bob.SlidingSync(t, sync3.Request{
|
||||
Lists: map[string]sync3.RequestList{
|
||||
"a": {
|
||||
Ranges: sync3.SliceRanges{{0, 20}},
|
||||
Filters: &sync3.RequestFilters{
|
||||
IsInvite: &boolTrue,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
m.MatchResponse(t, res, m.MatchList("a", m.MatchV3Count(0)), m.MatchRoomSubscriptionsStrict(nil))
|
||||
|
||||
// now invite bob
|
||||
alice.InviteRoom(t, inviteRoomID, bob.UserID)
|
||||
// sync as bob until we see the room
|
||||
res = bob.SlidingSyncUntilMembership(t, res.Pos, inviteRoomID, bob, "invite")
|
||||
t.Logf("bob is invited")
|
||||
|
||||
// join the room
|
||||
bob.JoinRoom(t, inviteRoomID, []string{})
|
||||
res = bob.SlidingSyncUntilMembership(t, res.Pos, inviteRoomID, bob, "join")
|
||||
t.Logf("bob joined")
|
||||
|
||||
// leave the room again, we should receive exactly one leave response
|
||||
bob.LeaveRoom(t, inviteRoomID)
|
||||
res = bob.SlidingSyncUntilMembership(t, res.Pos, inviteRoomID, bob, "leave")
|
||||
|
||||
if room, ok := res.Rooms[inviteRoomID]; ok {
|
||||
if c := len(room.Timeline); c > 1 {
|
||||
for _, ev := range res.Rooms[inviteRoomID].Timeline {
|
||||
t.Logf("Event: %s", ev)
|
||||
}
|
||||
t.Fatalf("expected 1 timeline event, got %d", c)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("expected room %s in response, but didn't find it", inviteRoomID)
|
||||
}
|
||||
|
||||
res = bob.SlidingSync(t, sync3.Request{}, WithPos(res.Pos))
|
||||
|
||||
// this should not happen, as we already send down the leave event
|
||||
if room, ok := res.Rooms[inviteRoomID]; ok {
|
||||
for _, ev := range room.Timeline {
|
||||
t.Logf("Event: %s", ev)
|
||||
}
|
||||
t.Fatalf("expected room not to be in response")
|
||||
}
|
||||
}
|
||||
|
||||
// test invite/join counts update and are accurate
|
||||
func TestMemberCounts(t *testing.T) {
|
||||
alice := registerNewUser(t)
|
||||
|
Loading…
x
Reference in New Issue
Block a user