Skip to content

Commit 916b542

Browse files
committed
test: fix 5 TUI rendering tests to use i18n.T() instead of hardcoded strings
- choices_test.go: use i18n.T("choices.input.other") for input field check - input_test.go: use i18n.T("client.ui.input.placeholder") for placeholder - statusbar_test.go: use i18n.T("client.status.idle") for state checks - modelselect_test.go: use i18n.T("setup.model.select.title") for title check These tests failed after gofmt because source code uses i18n translations while tests had hardcoded Chinese strings that no longer match.
1 parent 55dcb44 commit 916b542

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

internal/client/component/choices/choices_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
tea "charm.land/bubbletea/v2"
8+
"github.com/DotNetAge/mindx/internal/i18n"
89
clientmsg "github.com/DotNetAge/mindx/internal/client/msg"
910
)
1011

@@ -293,7 +294,7 @@ func TestMultiSelectWithTextInput(t *testing.T) {
293294
}
294295

295296
view := p.View()
296-
if !strings.Contains(view, "其他:") {
297+
if !strings.Contains(view, i18n.T("choices.input.other")) {
297298
t.Errorf("view should show custom input field, got %q", view)
298299
}
299300
}

internal/client/component/input/input_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
tea "charm.land/bubbletea/v2"
8+
"github.com/DotNetAge/mindx/internal/i18n"
89
"github.com/DotNetAge/mindx/internal/client/data"
910
clientmsg "github.com/DotNetAge/mindx/internal/client/msg"
1011
)
@@ -45,7 +46,7 @@ func TestInputAreaViewEmpty(t *testing.T) {
4546
if !strings.Contains(v, "❯") {
4647
t.Error("View() should contain prompt '❯'")
4748
}
48-
if !strings.Contains(v, "发送消息或") {
49+
if !strings.Contains(v, i18n.T("client.ui.input.placeholder")) {
4950
t.Error("View() should contain placeholder '发送消息或...'")
5051
}
5152
}

internal/client/component/statusbar/statusbar_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"strings"
55
"testing"
66

7+
"github.com/DotNetAge/mindx/internal/i18n"
78
"github.com/DotNetAge/mindx/internal/client/data"
89
clientmsg "github.com/DotNetAge/mindx/internal/client/msg"
910
)
@@ -13,8 +14,8 @@ func TestNewStatusBar(t *testing.T) {
1314
if s == nil {
1415
t.Fatal("New() returned nil")
1516
}
16-
if s.CurrentState != "空闲" {
17-
t.Errorf("expected CurrentState %q, got %q", "空闲", s.CurrentState)
17+
if s.CurrentState != i18n.T("client.status.idle") {
18+
t.Errorf("expected CurrentState %q, got %q", i18n.T("client.status.idle"), s.CurrentState)
1819
}
1920
if s.SessionName != "" {
2021
t.Errorf("expected empty SessionName, got %q", s.SessionName)
@@ -32,16 +33,16 @@ func TestNewStatusBar(t *testing.T) {
3233

3334
func TestStatusBarViewIdle(t *testing.T) {
3435
s := New()
35-
s.CurrentState = "空闲"
36+
s.CurrentState = i18n.T("client.status.idle")
3637
view := s.View()
3738
if view == "" {
3839
t.Fatal("View() returned empty string")
3940
}
4041
if !strings.Contains(view, "●") {
4142
t.Errorf("View() should contain ●, got %q", view)
4243
}
43-
if !strings.Contains(view, "空闲") {
44-
t.Errorf("View() should contain 空闲, got %q", view)
44+
if !strings.Contains(view, i18n.T("client.status.idle")) {
45+
t.Errorf("View() should contain %s, got %q", i18n.T("client.status.idle"), view)
4546
}
4647
}
4748

internal/setup/component/modelselect/modelselect_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66
"testing"
77

8+
"github.com/DotNetAge/mindx/internal/i18n"
89
setupdata "github.com/DotNetAge/mindx/internal/setup/data"
910
)
1011

@@ -25,7 +26,7 @@ func TestViewContainsGradientTitle(t *testing.T) {
2526
t.Logf("\n=== View Output ===\n%s\n=== End ===", view)
2627

2728
plain := stripANSI(view)
28-
if !strings.Contains(plain, "选择一个 AI 模型") {
29+
if !strings.Contains(plain, i18n.T("setup.model.select.title")) {
2930
t.Error("View output does NOT contain '选择一个 AI 模型'")
3031
} else {
3132
t.Log("✅ View output contains '选择一个 AI 模型'")

0 commit comments

Comments
 (0)