fix: own comments trigger NEW

This commit is contained in:
2026-08-03 15:27:57 +02:00
parent 6f963c7660
commit 63ce0319f7
4 changed files with 130 additions and 4 deletions

View File

@@ -1752,6 +1752,39 @@ func TestPollingMarksNewThreadCommentsUnread(t *testing.T) {
}
}
func TestPollingDoesNotMarkViewerReplyUnread(t *testing.T) {
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
m.screen = threadScreen
initial := PRDetails{
PullRequest: PullRequest{ID: "pr", Owner: "o", Repository: "r", Number: 1},
ViewerLogin: "me",
Threads: []ReviewThread{{
ID: "thread", Comments: []ReviewComment{{ID: "original", Author: "reviewer"}},
}},
}
updated, _ := m.Update(detailsLoadedMsg{owner: "o", repo: "r", number: 1, details: initial})
m = updated.(App)
refreshed := initial
refreshed.Threads = []ReviewThread{{
ID: "thread", Comments: []ReviewComment{
{ID: "original", Author: "reviewer"},
{ID: "own-reply", Author: "ME", Body: "sent by me"},
},
}}
updated, _ = m.Update(detailsLoadedMsg{owner: "o", repo: "r", number: 1, details: refreshed})
m = updated.(App)
if m.unreadThreads["thread"] || m.unreadComments["own-reply"] || len(m.updatedThreads) != 0 {
t.Fatalf("viewer reply was marked new: threads=%v comments=%v updated=%v",
m.unreadThreads, m.unreadComments, m.updatedThreads)
}
state := m.readState.Data["pr"]
if !state.Comments["own-reply"] {
t.Fatal("viewer reply was not persisted as read")
}
}
func TestResolvingThreadMarksItRead(t *testing.T) {
service := &recordingService{}
m := NewApp(service, "o", "r", false, 50, time.Second)