Skip to content

Commit

Permalink
WIP on next test case
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Jul 14, 2023
1 parent b943a60 commit 5051c20
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 46 deletions.
6 changes: 3 additions & 3 deletions tests-e2e/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ func (c *CSAPI) UploadContent(t *testing.T, fileBody []byte, fileName string, co
return GetJSONFieldStr(t, body, "content_uri")
}

// Use an empty string to remove your avatar.
func (c *CSAPI) SetAvatar(t *testing.T, avatarURL string) {
t.Helper()
reqBody := map[string]interface{}{}
if avatarURL != "" {
reqBody["avatar_url"] = avatarURL
reqBody := map[string]interface{}{
"avatar_url": avatarURL,
}
c.MustDoFunc(t, "PUT", []string{"_matrix", "client", "v3", "profile", c.UserID, "avatar_url"}, WithJSONBody(t, reqBody))
}
Expand Down
105 changes: 62 additions & 43 deletions tests-e2e/lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1401,56 +1401,75 @@ func TestAvatarFieldInRoomResponse(t *testing.T) {
m.MatchResponse(t, res, m.MatchRoomSubscription(dmBobChris, m.MatchRoomAvatar(bobAvatar)))
})

/*
t.Run("Bob's avatar change propagates", func(t *testing.T) {
t.Log("Bob changes his avatar.")
bobAvatar2 := uploadAvatar(bob, "bob2.png")
bob.SetAvatar(t, bobAvatar2)
avatarChangeInDM := false
avatarChangeInGroupDM := false
t.Log("Alice syncs until she sees Bob's new avatar.")
res = alice.SlidingSyncUntil(
t,
res.Pos,
sync3.Request{},
func(response *sync3.Response) error {
if !avatarChangeInDM {
err := m.MatchRoomSubscription(dmBob, m.MatchRoomAvatar(bobAvatar2))(response)
if err == nil {
avatarChangeInDM = true
}
t.Run("Bob's avatar change propagates", func(t *testing.T) {
t.Log("Bob changes his avatar.")
bobAvatar2 := uploadAvatar(bob, "bob2.png")
bob.SetAvatar(t, bobAvatar2)

avatarChangeInDM := false
avatarChangeInGroupDM := false
t.Log("Alice syncs until she sees Bob's new avatar.")
res = alice.SlidingSyncUntil(
t,
res.Pos,
sync3.Request{},
func(response *sync3.Response) error {
if !avatarChangeInDM {
err := m.MatchRoomSubscription(dmBob, m.MatchRoomAvatar(bobAvatar2))(response)
if err == nil {
avatarChangeInDM = true
}
}

if !avatarChangeInGroupDM {
err := m.MatchRoomSubscription(dmBobChris, m.MatchRoomAvatar(bobAvatar2))(response)
if err == nil {
avatarChangeInGroupDM = true
}
if !avatarChangeInGroupDM {
err := m.MatchRoomSubscription(dmBobChris, m.MatchRoomAvatar(bobAvatar2))(response)
if err == nil {
avatarChangeInGroupDM = true
}
}

if avatarChangeInDM && avatarChangeInGroupDM {
return nil
if avatarChangeInDM && avatarChangeInGroupDM {
return nil
}
return fmt.Errorf("Still waiting: avatarChangeInDM=%t avatarChangeInGroupDM=%t", avatarChangeInDM, avatarChangeInGroupDM)
},
)

t.Log("Bob removes his avatar.")
bob.SetAvatar(t, "")

avatarChangeInDM = false
avatarChangeInGroupDM = false
t.Log("Alice syncs until she sees Bob's avatars vanish.")
res = alice.SlidingSyncUntil(
t,
res.Pos,
sync3.Request{},
func(response *sync3.Response) error {
if !avatarChangeInDM {
err := m.MatchRoomSubscription(dmBob, m.MatchRoomUnsetAvatar())(response)
if err == nil {
avatarChangeInDM = true
}
m.LogRooms(t)(response)
return fmt.Errorf("Still waiting: avatarChangeInDM=%t avatarChangeInGroupDM=%t", avatarChangeInDM, avatarChangeInGroupDM)
},
)
}

t.Log("Bob removes his avatar.")
bob.SetAvatar(t, "")
if !avatarChangeInGroupDM {
err := m.MatchRoomSubscription(dmBobChris, m.MatchRoomUnsetAvatar())(response)
if err == nil {
avatarChangeInGroupDM = true
}
}

t.Log("Alice syncs until she sees Bob's avatar vanish.")
res = alice.SlidingSyncUntil(
t,
res.Pos,
sync3.Request{},
m.MatchRoomSubscriptions(map[string][]m.RoomMatcher{
dmBob: {m.MatchRoomUnsetAvatar()},
dmBobChris: {m.MatchRoomUnsetAvatar()},
}),
)
})
if avatarChangeInDM && avatarChangeInGroupDM {
return nil
}
m.LogRooms(t)(response)
return fmt.Errorf("Still waiting: avatarChangeInDM=%t avatarChangeInGroupDM=%t", avatarChangeInDM, avatarChangeInGroupDM)
},
)

})
/*
t.Run("Explicit avatar propagates in non-DM room", func(t *testing.T) {
t.Log("Alice sets an avatar for the public room.")
Expand Down

0 comments on commit 5051c20

Please sign in to comment.