Add manual triggering of game sounds to Field Testing page.

This commit is contained in:
Patrick Fairbank
2020-03-15 18:11:26 -07:00
parent 299a242e9c
commit 4c3850e2e4
6 changed files with 80 additions and 3 deletions

View File

@@ -4,12 +4,23 @@
package web
import (
"github.com/Team254/cheesy-arena/game"
"github.com/Team254/cheesy-arena/websocket"
gorillawebsocket "github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSetupFieldTesting(t *testing.T) {
web := setupTestWeb(t)
recorder := web.getHttpResponse("/setup/field_testing")
assert.Equal(t, 200, recorder.Code)
for _, sound := range game.MatchSounds {
assert.Contains(t, recorder.Body.String(), sound.Name)
}
}
func TestSetupFieldTestingWebsocket(t *testing.T) {
web := setupTestWeb(t)
@@ -22,4 +33,14 @@ func TestSetupFieldTestingWebsocket(t *testing.T) {
// Should get a few status updates right after connection.
readWebsocketType(t, ws, "plcIoChange")
// Also create a websocket to the audience display to check that it plays the requested game sound.
audienceConn, _, err := gorillawebsocket.DefaultDialer.Dial(wsUrl+"/displays/audience/websocket?displayId=1", nil)
assert.Nil(t, err)
defer audienceConn.Close()
audienceWs := websocket.NewTestWebsocket(audienceConn)
readWebsocketMultiple(t, audienceWs, 9)
ws.Write("playSound", "resume")
assert.Equal(t, "resume", readWebsocketType(t, audienceWs, "playSound"))
}