fix: make resolving less jumpy
This commit is contained in:
39
tui_test.go
39
tui_test.go
@@ -1470,6 +1470,45 @@ func TestResolveToggleConfirmsAndUsesCurrentThreadState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvingSelectedThreadKeepsSelectionNearItsPreviousPosition(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
selected int
|
||||
wantID string
|
||||
}{
|
||||
{name: "next thread", selected: 1, wantID: "c"},
|
||||
{name: "previous thread at end", selected: 2, wantID: "b"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
m := NewApp(nil, "o", "r", false, 50, time.Second)
|
||||
m.screen, m.loading, m.focus = threadScreen, false, threadDetailPane
|
||||
m.details.Threads = []ReviewThread{
|
||||
{ID: "a", Path: "a.go"},
|
||||
{ID: "b", Path: "b.go"},
|
||||
{ID: "c", Path: "c.go"},
|
||||
}
|
||||
m.threadIndex = test.selected
|
||||
resolvedID := m.details.Threads[test.selected].ID
|
||||
|
||||
updated, _ := m.Update(threadResolvedMsg{
|
||||
threadID: resolvedID,
|
||||
thread: ReviewThread{
|
||||
ID: resolvedID, IsResolved: true, ViewerCanUnresolve: true,
|
||||
},
|
||||
})
|
||||
m = updated.(App)
|
||||
|
||||
if got := m.details.Threads[m.threadIndex].ID; got != test.wantID {
|
||||
t.Fatalf("selected thread = %q, want nearest thread %q", got, test.wantID)
|
||||
}
|
||||
if m.focus != threadDetailPane {
|
||||
t.Fatalf("focus = %d, want detail pane", m.focus)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPollingMarksNewThreadCommentsUnread(t *testing.T) {
|
||||
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
|
||||
m.screen, m.width, m.height = threadScreen, 80, 8
|
||||
|
||||
Reference in New Issue
Block a user