feat: task unread tracking (#1857)

---------

Co-authored-by: Mithilesh Gupta <guptamithilesh@protonmail.com>
Co-authored-by: kolaente <k@knt.li>
This commit is contained in:
Mithilesh Gupta
2025-11-27 19:44:42 +05:30
committed by GitHub
parent 2976d6f676
commit 7dddc5dfa2
18 changed files with 328 additions and 9 deletions

View File

@@ -93,6 +93,39 @@ func TestTaskComment_Create(t *testing.T) {
"name": (&TaskCommentNotification{}).Name(),
}, false)
})
t.Run("should mark task unread for project members on comment", func(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
task, err := GetTaskByIDSimple(s, 32)
require.NoError(t, err)
tc := &TaskComment{
Comment: "test comment",
TaskID: 32,
}
err = tc.Create(s, u)
require.NoError(t, err)
ev := &TaskCommentCreatedEvent{
Task: &task,
Doer: u,
Comment: tc,
}
events.TestListener(t, ev, &MarkTaskUnreadOnComment{})
db.AssertExists(t, "task_unread_statuses", map[string]interface{}{
"task_id": task.ID,
"user_id": 2,
}, false)
db.AssertMissing(t, "task_unread_statuses", map[string]interface{}{
"task_id": task.ID,
"user_id": u.ID,
})
})
}
func TestTaskComment_Delete(t *testing.T) {