TestViewHandlesZeroWidth reproduces the "shrunk UI" startup flash: before WindowSizeMsg arrives, View must not panic or emit garbled layout.
(t *testing.T)
| 1378 | |
| 1379 | // TestStatusBarShowsBudgetFromHeaders: the pass segment renders whenever |
| 1380 | // X-Budget-Remaining arrives: the header is the only signal, no profile gating. |
| 1381 | // The percent is rounded to a whole number so it doesn't jitter on every token. |
| 1382 | func TestStatusBarShowsBudgetFromHeaders(t *testing.T) { |
| 1383 | view := runTurn(t, budgetResponseHandler, "sk-test", "hi").View() |
| 1384 | if !strings.Contains(view, "73% pass") { |
| 1385 | t.Fatalf("status bar missing pass segment: %s", view) |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | // TestStatusBarOmitsBudgetWithoutHeaders: endpoint sends no budget header, |
| 1390 | // no pass segment appears. |
| 1391 | func TestStatusBarOmitsBudgetWithoutHeaders(t *testing.T) { |
| 1392 | view := runTurn(t, func(w http.ResponseWriter, _ *http.Request) { |
| 1393 | w.Header().Set("Content-Type", "text/event-stream") |
| 1394 | fmt.Fprint(w, "data: "+`{"choices":[{"delta":{"content":"ok"}}]}`+"\n\n") |
| 1395 | fmt.Fprint(w, "data: [DONE]\n\n") |