Require at least one element in interactive dialogs (#10003)
Этот коммит содержится в:
коммит произвёл
Carlos Tadeu Panato Junior
родитель
c06e42b24a
Коммит
6c2e216c3f
@@ -59,6 +59,11 @@ func openDialog(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dialog.Dialog.Elements == nil || len(dialog.Dialog.Elements) == 0 {
|
||||||
|
c.SetInvalidParam("dialog.elements")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := c.App.OpenInteractiveDialog(dialog); err != nil {
|
if err := c.App.OpenInteractiveDialog(dialog); err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*func TestOpenDialog(t *testing.T) {
|
func TestOpenDialog(t *testing.T) {
|
||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
@@ -24,11 +24,6 @@ import (
|
|||||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||||
})
|
})
|
||||||
|
|
||||||
WebSocketClient, err := th.CreateWebSocketClient()
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
WebSocketClient.Listen()
|
|
||||||
|
|
||||||
_, triggerId, err := model.GenerateTriggerId(th.BasicUser.Id, th.App.AsymmetricSigningKey())
|
_, triggerId, err := model.GenerateTriggerId(th.BasicUser.Id, th.App.AsymmetricSigningKey())
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
@@ -56,21 +51,6 @@ import (
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
assert.True(t, pass)
|
assert.True(t, pass)
|
||||||
|
|
||||||
timeout := time.After(300 * time.Millisecond)
|
|
||||||
waiting := true
|
|
||||||
for waiting {
|
|
||||||
select {
|
|
||||||
case event := <-WebSocketClient.EventChannel:
|
|
||||||
if event.Event == model.WEBSOCKET_EVENT_OPEN_DIALOG {
|
|
||||||
waiting = false
|
|
||||||
}
|
|
||||||
|
|
||||||
case <-timeout:
|
|
||||||
waiting = false
|
|
||||||
t.Fatal("should have received open_dialog event")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should fail on bad trigger ID
|
// Should fail on bad trigger ID
|
||||||
request.TriggerId = "junk"
|
request.TriggerId = "junk"
|
||||||
pass, resp = Client.OpenInteractiveDialog(request)
|
pass, resp = Client.OpenInteractiveDialog(request)
|
||||||
@@ -83,7 +63,18 @@ import (
|
|||||||
pass, resp = Client.OpenInteractiveDialog(request)
|
pass, resp = Client.OpenInteractiveDialog(request)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
assert.False(t, pass)
|
assert.False(t, pass)
|
||||||
}*/
|
|
||||||
|
// At least one element is required
|
||||||
|
request.URL = "http://localhost:8065"
|
||||||
|
request.Dialog.Elements = nil
|
||||||
|
pass, resp = Client.OpenInteractiveDialog(request)
|
||||||
|
CheckBadRequestStatus(t, resp)
|
||||||
|
assert.False(t, pass)
|
||||||
|
request.Dialog.Elements = []model.DialogElement{}
|
||||||
|
pass, resp = Client.OpenInteractiveDialog(request)
|
||||||
|
CheckBadRequestStatus(t, resp)
|
||||||
|
assert.False(t, pass)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSubmitDialog(t *testing.T) {
|
func TestSubmitDialog(t *testing.T) {
|
||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user