MM-56948 Fix flaky TestUserHasJoinedChannel (#26359)

* MM-56948 Fix flaky TestUserHasJoinedChannel

* Add comment explaining flakiness
Этот коммит содержится в:
Harrison Healey
2024-03-04 15:16:56 -05:00
коммит произвёл GitHub
родитель 6ba3ac4a02
Коммит 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)
})