1package tui
2
3import (
4 "strings"
5 "testing"
6
7 "github.com/patriceckhart/zot/internal/provider"
8)
9
10// TestStatusBarAlwaysTwoLines verifies the status bar always emits
11// two lines when a cwd is present, regardless of terminal width, and
12// that the cwd is indented with the 2-space pad so it lines up under
13// the "(provider)" column on line 1.
14func TestStatusBarAlwaysTwoLines(t *testing.T) {
15 // Wide terminal that would previously combine into one line.
16 lines := StatusBar(StatusBarParams{
17 Theme: Dark,
18 Provider: "anthropic",
19 Model: "claude-opus-4-7",
20 CWD: "/tmp/x",
21 Usage: provider.Usage{
22 InputTokens: 476_000,
23 OutputTokens: 3_400,
24 CostUSD: 1.242,
25 },
26 Subscription: true,
27 ContextUsed: 55_000,
28 ContextMax: 1_000_000,
29 Cols: 500, // very wide
30 })
31 if len(lines) != 2 {
32 t.Fatalf("want 2 lines, got %d: %q", len(lines), lines)
33 }
34 if !strings.Contains(lines[0], "claude-opus-4-7") {
35 t.Errorf("line 1 should contain model, got %q", lines[0])
36 }
37 // Line 2 must start with 2-space indent.
38 if !strings.HasPrefix(lines[1], " ") {
39 t.Errorf("line 2 should start with 2-space indent, got %q", lines[1])
40 }
41 if !strings.Contains(lines[1], "/tmp/x") {
42 t.Errorf("line 2 should contain cwd, got %q", lines[1])
43 }
44}
45
46// TestStatusBarNoCWD verifies an empty cwd stays single-line.
47func TestStatusBarNoCWD(t *testing.T) {
48 lines := StatusBar(StatusBarParams{
49 Theme: Dark,
50 Provider: "openai",
51 Model: "gpt-5.4",
52 CWD: "",
53 Cols: 200,
54 })
55 if len(lines) != 1 {
56 t.Fatalf("empty cwd: want 1 line, got %d: %q", len(lines), lines)
57 }
58}