Add ordering for threads

This commit is contained in:
2026-07-28 09:52:57 +02:00
parent 80f24bcfa8
commit 60d64dedb2
6 changed files with 196 additions and 1 deletions

View File

@@ -89,6 +89,52 @@ func TestSelectionSurvivesRefresh(t *testing.T) {
}
}
func TestDefaultThreadOrderingUsesStatusThenFile(t *testing.T) {
threads := []ReviewThread{
{ID: "resolved-outdated", Path: "a.go", IsResolved: true, IsOutdated: true},
{ID: "outdated", Path: "a.go", IsOutdated: true},
{ID: "current-z", Path: "z.go"},
{ID: "resolved", Path: "z.go", IsResolved: true},
{ID: "current-a", Path: "a.go"},
}
settings := defaultAppSettings()
sortReviewThreads(threads, settings.ThreadStatusOrder, settings.ThreadWithinStatus)
got := make([]string, len(threads))
for i, thread := range threads {
got[i] = thread.ID
}
want := []string{"current-a", "current-z", "outdated", "resolved-outdated", "resolved"}
if strings.Join(got, ",") != strings.Join(want, ",") {
t.Fatalf("thread order = %v, want %v", got, want)
}
}
func TestCustomThreadOrderingUsesOpeningTimestamp(t *testing.T) {
base := time.Date(2026, 7, 1, 12, 0, 0, 0, time.UTC)
threads := []ReviewThread{
{ID: "current", Path: "a.go", Comments: []ReviewComment{{CreatedAt: base}}},
{ID: "resolved-new", IsResolved: true, Path: "a.go", Comments: []ReviewComment{{CreatedAt: base.Add(2 * time.Hour)}}},
{ID: "outdated", IsOutdated: true, Path: "a.go", Comments: []ReviewComment{{CreatedAt: base.Add(time.Hour)}}},
{ID: "resolved-old", IsResolved: true, Path: "z.go", Comments: []ReviewComment{
{CreatedAt: base.Add(3 * time.Hour)},
{CreatedAt: base.Add(-time.Hour)},
}},
}
sortReviewThreads(
threads,
[]string{"resolved", "outdated", "unresolved"},
"timestamp",
)
got := make([]string, len(threads))
for i, thread := range threads {
got[i] = thread.ID
}
want := []string{"resolved-old", "resolved-new", "outdated", "current"}
if strings.Join(got, ",") != strings.Join(want, ",") {
t.Fatalf("thread order = %v, want %v", got, want)
}
}
func TestPaneFocusAndNavigation(t *testing.T) {
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
m.screen = threadScreen