(t *testing.T)
| 155 | } |
| 156 | |
| 157 | func TestAPIExceptionDetail(t *testing.T) { |
| 158 | mux := http.NewServeMux() |
| 159 | seedTestData(t, mux) |
| 160 | |
| 161 | // Get the first event's ID. |
| 162 | req := httptest.NewRequest("GET", "/api/sentry/exceptions", nil) |
| 163 | w := httptest.NewRecorder() |
| 164 | mux.ServeHTTP(w, req) |
| 165 | |
| 166 | var listResp map[string]any |
| 167 | json.Unmarshal(w.Body.Bytes(), &listResp) |
| 168 | items := listResp["data"].([]any) |
| 169 | |
| 170 | // Find one with trace_id. |
| 171 | var eventWithTrace map[string]any |
| 172 | for _, item := range items { |
| 173 | m := item.(map[string]any) |
| 174 | if m["trace_id"] != nil && m["trace_id"] != "" { |
| 175 | eventWithTrace = m |
| 176 | break |
| 177 | } |
| 178 | } |
| 179 | if eventWithTrace == nil { |
| 180 | t.Fatal("no event with trace_id found") |
| 181 | } |
| 182 | |
| 183 | id := eventWithTrace["id"].(string) |
| 184 | req = httptest.NewRequest("GET", "/api/sentry/exceptions/"+id, nil) |
| 185 | w = httptest.NewRecorder() |
| 186 | mux.ServeHTTP(w, req) |
| 187 | |
| 188 | if w.Code != 200 { |
| 189 | t.Fatalf("status = %d, want 200", w.Code) |
| 190 | } |
| 191 | |
| 192 | var detail map[string]any |
| 193 | json.Unmarshal(w.Body.Bytes(), &detail) |
| 194 | |
| 195 | if detail["exceptions"] == nil { |
| 196 | t.Error("expected exceptions array") |
| 197 | } |
| 198 | if detail["trace_summary"] == nil { |
| 199 | t.Error("expected trace_summary for event with trace_id") |
| 200 | } |
| 201 | |
| 202 | ts := detail["trace_summary"].(map[string]any) |
| 203 | if ts["transaction_name"] != "GET /api/users" { |
| 204 | t.Errorf("trace_summary.transaction_name = %v", ts["transaction_name"]) |
| 205 | } |
| 206 | if ts["preview_spans"] == nil { |
| 207 | t.Error("expected preview_spans in trace_summary") |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | // TestAPIExceptionDetailByEventID covers Fix B: the detail endpoint must resolve |
| 212 | // by event_id (the key the list and the frontend route use) and still return the |
nothing calls this directly
no test coverage detected