fix: resolve pending and jumping
This commit is contained in:
54
tui_test.go
54
tui_test.go
@@ -1629,6 +1629,60 @@ func TestResolvingSelectedThreadKeepsSelectionNearItsPreviousPosition(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueuedResolutionOptimisticallyMovesToNeighborWithoutPendingLabel(t *testing.T) {
|
||||
store := loadMutationQueue("")
|
||||
operation := mutationOperation{
|
||||
ID: "resolve", Kind: mutationResolution, Owner: "o", Repository: "r", Number: 1,
|
||||
ThreadID: "b", Resolved: true, EnqueuedAt: time.Now(),
|
||||
}
|
||||
if err := store.add(operation); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
settings := defaultAppSettings()
|
||||
settings.Mutations = store
|
||||
m := NewAppWithSettings(nil, "o", "r", false, 50, time.Minute, settings)
|
||||
m.screen, m.loading, m.focus = threadScreen, false, threadDetailPane
|
||||
m.details = PRDetails{
|
||||
PullRequest: PullRequest{Owner: "o", Repository: "r", Number: 1},
|
||||
Threads: []ReviewThread{
|
||||
{ID: "a", Path: "a.go"},
|
||||
{ID: "b", Path: "b.go"},
|
||||
{ID: "c", Path: "c.go"},
|
||||
},
|
||||
}
|
||||
m.threadIndex = 1
|
||||
|
||||
updated, _ := m.Update(mutationQueuedMsg{operation: operation})
|
||||
m = updated.(App)
|
||||
if got := m.details.Threads[m.threadIndex].ID; got != "c" {
|
||||
t.Fatalf("selected thread = %q, want c", got)
|
||||
}
|
||||
thread := m.threadByID("b")
|
||||
if thread == nil || !thread.IsResolved || thread.Pending {
|
||||
t.Fatalf("optimistic resolved thread = %#v", thread)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMutationQueueAllowsResolvingNextThreadDuringVerificationRefresh(t *testing.T) {
|
||||
store := loadMutationQueue("")
|
||||
settings := defaultAppSettings()
|
||||
settings.Mutations = store
|
||||
m := NewAppWithSettings(&recordingService{}, "o", "r", false, 50, time.Minute, settings)
|
||||
m.screen, m.loading = threadScreen, true
|
||||
m.details = PRDetails{
|
||||
PullRequest: PullRequest{Owner: "o", Repository: "r", Number: 1},
|
||||
Threads: []ReviewThread{{
|
||||
ID: "next", ViewerCanResolve: true,
|
||||
}},
|
||||
}
|
||||
|
||||
m.startResolveToggle()
|
||||
if m.err != nil || m.writeMode != writeResolveConfirm || !m.resolveTarget {
|
||||
t.Fatalf("resolve during verification mode=%d target=%t err=%v",
|
||||
m.writeMode, m.resolveTarget, m.err)
|
||||
}
|
||||
}
|
||||
|
||||
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