mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-56948 Fix flaky TestUserHasJoinedChannel (#26359)
* MM-56948 Fix flaky TestUserHasJoinedChannel * Add comment explaining flakiness
This commit is contained in:
parent
6ba3ac4a02
commit
d5446cd25e
@ -2018,12 +2018,23 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
assert.EventuallyWithT(t, func(t *assert.CollectT) {
|
||||
posts, appErr := th.App.GetPosts(channel.Id, 0, 1)
|
||||
expectedMessage := fmt.Sprintf("Test: User %s added to %s by %s", user2.Id, channel.Id, user1.Id)
|
||||
assert.Eventually(t, func() bool {
|
||||
// Typically, the post we're looking for will be the latest, but there's a race between the plugin and
|
||||
// "User has joined the channel" post which means the plugin post may not the the latest one
|
||||
posts, appErr := th.App.GetPosts(channel.Id, 0, 10)
|
||||
|
||||
require.Nil(t, appErr)
|
||||
|
||||
assert.Equal(t, fmt.Sprintf("Test: User %s added to %s by %s", user2.Id, channel.Id, user1.Id), posts.Posts[posts.Order[0]].Message)
|
||||
for _, postId := range posts.Order {
|
||||
post := posts.Posts[postId]
|
||||
|
||||
if post.Message == expectedMessage {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}, 1*time.Second, 10*time.Millisecond)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user