2019-09-14 15:44:15 -07:00
|
|
|
// Copyright 2018 Team 254. All Rights Reserved.
|
2018-09-22 01:10:12 -07:00
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
|
|
|
|
|
package web
|
|
|
|
|
|
|
|
|
|
import (
|
2021-05-16 11:00:29 -07:00
|
|
|
"github.com/Team254/cheesy-arena-lite/websocket"
|
2018-09-22 01:10:12 -07:00
|
|
|
gorillawebsocket "github.com/gorilla/websocket"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestQueueingDisplay(t *testing.T) {
|
|
|
|
|
web := setupTestWeb(t)
|
|
|
|
|
|
|
|
|
|
recorder := web.getHttpResponse("/displays/queueing?displayId=1")
|
|
|
|
|
assert.Equal(t, 200, recorder.Code)
|
|
|
|
|
assert.Contains(t, recorder.Body.String(), "Queueing Display - Untitled Event - Cheesy Arena")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestQueueingDisplayWebsocket(t *testing.T) {
|
|
|
|
|
web := setupTestWeb(t)
|
|
|
|
|
|
|
|
|
|
server, wsUrl := web.startTestServer()
|
|
|
|
|
defer server.Close()
|
|
|
|
|
conn, _, err := gorillawebsocket.DefaultDialer.Dial(wsUrl+"/displays/queueing/websocket?displayId=1", nil)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
defer conn.Close()
|
|
|
|
|
ws := websocket.NewTestWebsocket(conn)
|
|
|
|
|
|
|
|
|
|
// Should get a few status updates right after connection.
|
2020-03-29 16:55:53 -07:00
|
|
|
readWebsocketType(t, ws, "displayConfiguration")
|
2018-09-22 01:10:12 -07:00
|
|
|
readWebsocketType(t, ws, "matchTiming")
|
|
|
|
|
readWebsocketType(t, ws, "matchLoad")
|
|
|
|
|
readWebsocketType(t, ws, "matchTime")
|
2020-03-28 18:32:46 -07:00
|
|
|
readWebsocketType(t, ws, "eventStatus")
|
2018-09-22 01:10:12 -07:00
|
|
|
}
|