(t *testing.T)
| 403 | } |
| 404 | |
| 405 | func TestHandler_SendAfterConnect(t *testing.T) { |
| 406 | hub := NewHub() |
| 407 | defer hub.Close() |
| 408 | store := &mockStore{ |
| 409 | user: newTestUser(), |
| 410 | agent: newTestAgent("user_1"), |
| 411 | } |
| 412 | handler := NewHandler(hub, store) |
| 413 | srv := startServer(t, handler) |
| 414 | |
| 415 | conn, _ := dialWS(t, srv, "bot@agents.e2a.dev", "valid_key") |
| 416 | if conn == nil { |
| 417 | t.Fatal("expected successful WS connection") |
| 418 | } |
| 419 | defer conn.Close(websocket.StatusNormalClosure, "") |
| 420 | |
| 421 | waitConnected(t, hub, "agent_test") |
| 422 | |
| 423 | // Send a message through the hub after connection |
| 424 | msg := `{"message_id":"msg_live","from":"charlie@example.com","subject":"Live"}` |
| 425 | if !hub.Send("agent_test", []byte(msg)) { |
| 426 | t.Fatal("expected send to succeed") |
| 427 | } |
| 428 | |
| 429 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 430 | defer cancel() |
| 431 | _, data, err := conn.Read(ctx) |
| 432 | if err != nil { |
| 433 | t.Fatalf("read: %v", err) |
| 434 | } |
| 435 | if string(data) != msg { |
| 436 | t.Fatalf("got %q, want %q", data, msg) |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | func TestBuildNotification(t *testing.T) { |
| 441 | now := time.Date(2026, 3, 27, 10, 0, 0, 0, time.UTC) |
nothing calls this directly
no test coverage detected