===== E2E TESTS =====
(t *testing.T)
| 188 | // ===== E2E TESTS ===== |
| 189 | |
| 190 | func TestWebSocketSessionOpen(t *testing.T) { |
| 191 | ensureServer() |
| 192 | token := signUpAndGetToken(t) |
| 193 | |
| 194 | ws := dialWSRaw(t, token) |
| 195 | defer ws.Close() |
| 196 | |
| 197 | // first message should be session-open |
| 198 | msg := recvJSON(t, ws, 5*time.Second) |
| 199 | if msg.Type != "session" { |
| 200 | t.Errorf("expected type=session, got %q", msg.Type) |
| 201 | } |
| 202 | if msg.Status != "open" { |
| 203 | t.Errorf("expected status=open, got %q", msg.Status) |
| 204 | } |
| 205 | |
| 206 | var data map[string]interface{} |
| 207 | json.Unmarshal(msg.Data, &data) |
| 208 | if data["user"] == nil { |
| 209 | t.Errorf("session-open missing user field") |
| 210 | } |
| 211 | if data["sessionId"] == nil { |
| 212 | t.Errorf("session-open missing sessionId field") |
| 213 | } |
| 214 | t.Logf("session-open: user=%v sessionId=%v", data["user"], data["sessionId"]) |
| 215 | } |
| 216 | |
| 217 | func TestWebSocketConnect(t *testing.T) { |
| 218 | ensureServer() |
nothing calls this directly
no test coverage detected