mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Add manual triggering of game sounds to Field Testing page.
This commit is contained in:
@@ -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"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user