[MM-62437] Fix flakyness in channel bookmark tests (#29893)
* Fix flakyness in channel bookmark tests * Use existing util to initialize client * Update server/channels/api4/apitestlib.go Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com> * Remove redundant close --------- Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
106cd66d69
Коммит
835b276ff0
@@ -555,6 +555,25 @@ func (th *TestHelper) CreateLocalClient(socketPath string) *model.Client4 {
|
||||
}
|
||||
}
|
||||
|
||||
func (th *TestHelper) CreateConnectedWebSocketClient(t *testing.T) *model.WebSocketClient {
|
||||
t.Helper()
|
||||
wsClient, err := th.CreateWebSocketClient()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, wsClient, "webSocketClient should not be nil")
|
||||
wsClient.Listen()
|
||||
t.Cleanup(wsClient.Close)
|
||||
|
||||
// Ensure WS is connected. First event should be hello message.
|
||||
select {
|
||||
case ev := <-wsClient.EventChannel:
|
||||
require.Equal(t, model.WebsocketEventHello, ev.EventType())
|
||||
case <-time.After(5 * time.Second):
|
||||
require.FailNow(t, "hello event was not received within the timeout period")
|
||||
}
|
||||
|
||||
return wsClient
|
||||
}
|
||||
|
||||
func (th *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, error) {
|
||||
return model.NewWebSocketClient4(fmt.Sprintf("ws://localhost:%v", th.App.Srv().ListenAddr.Port), th.Client.AuthToken)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user