Rename colliding test helpers

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 15:46:25 -04:00
1 parent 408aa3ba7d
commit 8e6c1bd9a9
2 files changed
+10 -10

No files matched your search

+7 -7
View File
@@ -14,8 +14,8 @@ var mentionSample = []ContextItem{
{ID: "f2", Label: "seating.xlsx", Detail: "~/ball", Kind: ContextFile}, {ID: "f2", Label: "seating.xlsx", Detail: "~/ball", Kind: ContextFile},
} }
// mentionTester filters items as an async source would, one frame late. // mentionMenuTester filters items as an async source would, one frame late.
type mentionTester struct { type mentionMenuTester struct {
text string text string
items []ContextItem items []ContextItem
loading bool loading bool
@@ -23,7 +23,7 @@ type mentionTester struct {
queries []string queries []string
} }
func (m *mentionTester) view(c *ui.Context) { func (m *mentionMenuTester) view(c *ui.Context) {
Use(c, Settings{}) Use(c, Settings{})
ui.Column(c).Fill().Justify(ui.End).Padding(16).Children(func() { ui.Column(c).Fill().Justify(ui.End).Padding(16).Children(func() {
p := PromptComposer(c, &m.text, PromptComposerOptions{Label: "Prompt"}) p := PromptComposer(c, &m.text, PromptComposerOptions{Label: "Prompt"})
@@ -44,7 +44,7 @@ func (m *mentionTester) view(c *ui.Context) {
} }
func TestContextMentionMenuGroupsAndChooses(t *testing.T) { func TestContextMentionMenuGroupsAndChooses(t *testing.T) {
m := &mentionTester{} m := &mentionMenuTester{}
tt := ui.NewTester(m.view, 600, 500) tt := ui.NewTester(m.view, 600, 500)
_ = tt.Click("Prompt") _ = tt.Click("Prompt")
tt.Type("Read @") tt.Type("Read @")
@@ -68,7 +68,7 @@ func TestContextMentionMenuGroupsAndChooses(t *testing.T) {
} }
func TestContextMentionMenuOnlyAfterSpaceAndLoading(t *testing.T) { func TestContextMentionMenuOnlyAfterSpaceAndLoading(t *testing.T) {
m := &mentionTester{loading: true} m := &mentionMenuTester{loading: true}
tt := ui.NewTester(m.view, 600, 500) tt := ui.NewTester(m.view, 600, 500)
_ = tt.Click("Prompt") _ = tt.Click("Prompt")
tt.Type("mail@host") tt.Type("mail@host")
@@ -93,13 +93,13 @@ func TestContextMentionMenuBadItem(t *testing.T) {
t.Fatal("no panic for an item without ID") t.Fatal("no panic for an item without ID")
} }
}() }()
m := &mentionTester{items: []ContextItem{{Label: "x"}}} m := &mentionMenuTester{items: []ContextItem{{Label: "x"}}}
ui.NewTester(m.view, 300, 300) ui.NewTester(m.view, 300, 300)
} }
func TestContextMentionMenuSnapshot(t *testing.T) { func TestContextMentionMenuSnapshot(t *testing.T) {
snapshotAfter(t, "context_mention_menu", 560, 420, func(c *ui.Context) { snapshotAfter(t, "context_mention_menu", 560, 420, func(c *ui.Context) {
(*ui.Local(c.Root(), "m", func() *mentionTester { return &mentionTester{items: mentionSample} })).view(c) (*ui.Local(c.Root(), "m", func() *mentionMenuTester { return &mentionMenuTester{items: mentionSample} })).view(c)
}, func(tt *ui.Tester) { }, func(tt *ui.Tester) {
_ = tt.Click("Prompt") _ = tt.Click("Prompt")
tt.Type("Compare @") tt.Type("Compare @")
+3 -3
View File
@@ -8,7 +8,7 @@ import (
"github.com/egoist/mygo/ui" "github.com/egoist/mygo/ui"
) )
var traceSample = []WaterfallSpan{ var waterfallSample = []WaterfallSpan{
{ID: "db", Parent: "api", Name: "SELECT guests", Service: "postgres", Start: 40 * time.Millisecond, Duration: 90 * time.Millisecond}, {ID: "db", Parent: "api", Name: "SELECT guests", Service: "postgres", Start: 40 * time.Millisecond, Duration: 90 * time.Millisecond},
{ID: "root", Name: "GET /ball", Service: "gateway", Duration: 320 * time.Millisecond}, {ID: "root", Name: "GET /ball", Service: "gateway", Duration: 320 * time.Millisecond},
{ID: "api", Parent: "root", Name: "ListGuests", Service: "api", Start: 20 * time.Millisecond, Duration: 200 * time.Millisecond}, {ID: "api", Parent: "root", Name: "ListGuests", Service: "api", Start: 20 * time.Millisecond, Duration: 200 * time.Millisecond},
@@ -26,7 +26,7 @@ func traceTester(spans []WaterfallSpan, changes *int) *ui.Tester {
func TestTraceWaterfallOrderAndDetail(t *testing.T) { func TestTraceWaterfallOrderAndDetail(t *testing.T) {
n := 0 n := 0
tt := traceTester(traceSample, &n) tt := traceTester(waterfallSample, &n)
if !tt.HasText("4 spans · 320 ms") { if !tt.HasText("4 spans · 320 ms") {
t.Fatalf("summary: %q", tt.Texts()) t.Fatalf("summary: %q", tt.Texts())
} }
@@ -73,6 +73,6 @@ func TestTraceWaterfallRulesAndMany(t *testing.T) {
func TestTraceWaterfallSnapshot(t *testing.T) { func TestTraceWaterfallSnapshot(t *testing.T) {
snapshot(t, "trace_waterfall", 680, 280, func(c *ui.Context) { snapshot(t, "trace_waterfall", 680, 280, func(c *ui.Context) {
ui.Column(c).Padding(16).Children(func() { TraceWaterfall(c, traceSample, TraceWaterfallOptions{Height: 180}) }) ui.Column(c).Padding(16).Children(func() { TraceWaterfall(c, waterfallSample, TraceWaterfallOptions{Height: 180}) })
}) })
} }