(t *testing.T, s *step)
| 419 | } |
| 420 | |
| 421 | func (r *runner) execWSConnect(t *testing.T, s *step) { |
| 422 | t.Helper() |
| 423 | |
| 424 | path := r.resolve(s.Path) |
| 425 | |
| 426 | // Extract agent email from WS path (e.g., /v1/agents/bot@ws.test.dev/ws) |
| 427 | agentEmail := extractEmailFromWSPath(path) |
| 428 | ag, err := r.env.store.GetAgentByEmail(context.Background(), agentEmail) |
| 429 | if err != nil { |
| 430 | t.Fatalf("step %s: get agent %s: %v", s.ID, agentEmail, err) |
| 431 | } |
| 432 | r.wsAgent = ag.ID |
| 433 | |
| 434 | wsURL := "ws" + strings.TrimPrefix(r.env.baseURL, "http") + path |
| 435 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 436 | defer cancel() |
| 437 | |
| 438 | conn, _, err := websocket.Dial(ctx, wsURL, wsDialOpts(r.env.apiKey)) |
| 439 | if err != nil { |
| 440 | t.Fatalf("step %s: ws dial: %v", s.ID, err) |
| 441 | } |
| 442 | r.wsConn = conn |
| 443 | r.env.waitWSConnected(t, r.wsAgent) |
| 444 | } |
| 445 | |
| 446 | // wsDialOpts authenticates the WS handshake with Authorization: Bearer (the |
| 447 | // credential is never in the URL — header-only auth). |
no test coverage detected