@@ -209,7 +209,8 @@ def test_not_found_raises(self, org, author_orguser):
209209class TestDeleteComment :
210210 """Tests for CommentService.delete_comment"""
211211
212- def test_success (self , snapshot , author_orguser , org ):
212+ def test_hard_deletes_sole_comment (self , snapshot , author_orguser , org ):
213+ """Only comment in thread, only author — hard-delete."""
213214 comment = Comment .objects .create (
214215 target_type = CommentTargetType .SUMMARY ,
215216 snapshot = snapshot ,
@@ -218,16 +219,67 @@ def test_success(self, snapshot, author_orguser, org):
218219 author = author_orguser ,
219220 org = org ,
220221 )
222+ comment_id = comment .id
221223 CommentService .delete_comment (
222- comment_id = comment . id ,
224+ comment_id = comment_id ,
223225 org = org ,
224226 orguser = author_orguser ,
225227 )
226- comment .refresh_from_db ()
227- assert comment .is_deleted is True
228- assert comment .content == ""
229- assert comment .mentioned_emails == []
230- comment .delete ()
228+ assert not Comment .objects .filter (id = comment_id ).exists ()
229+
230+ def test_hard_deletes_multiple_own_comments (self , snapshot , author_orguser , org ):
231+ """Multiple comments in thread but ALL by the same author — hard-delete."""
232+ c1 = Comment .objects .create (
233+ target_type = CommentTargetType .SUMMARY ,
234+ snapshot = snapshot ,
235+ content = "My first" ,
236+ author = author_orguser ,
237+ org = org ,
238+ )
239+ c2 = Comment .objects .create (
240+ target_type = CommentTargetType .SUMMARY ,
241+ snapshot = snapshot ,
242+ content = "My second" ,
243+ author = author_orguser ,
244+ org = org ,
245+ )
246+ c2_id = c2 .id
247+ CommentService .delete_comment (
248+ comment_id = c2_id ,
249+ org = org ,
250+ orguser = author_orguser ,
251+ )
252+ assert not Comment .objects .filter (id = c2_id ).exists ()
253+ c1 .delete ()
254+
255+ def test_soft_deletes_when_other_author_exists (
256+ self , snapshot , author_orguser , other_orguser , org
257+ ):
258+ """Another user has commented in the thread — soft-delete."""
259+ Comment .objects .create (
260+ target_type = CommentTargetType .SUMMARY ,
261+ snapshot = snapshot ,
262+ content = "Other person's comment" ,
263+ author = other_orguser ,
264+ org = org ,
265+ )
266+ my_comment = Comment .objects .create (
267+ target_type = CommentTargetType .SUMMARY ,
268+ snapshot = snapshot ,
269+ content = "Delete me" ,
270+ mentioned_emails = ["someone@test.com" ],
271+ author = author_orguser ,
272+ org = org ,
273+ )
274+ CommentService .delete_comment (
275+ comment_id = my_comment .id ,
276+ org = org ,
277+ orguser = author_orguser ,
278+ )
279+ my_comment .refresh_from_db ()
280+ assert my_comment .is_deleted is True
281+ assert my_comment .content == ""
282+ assert my_comment .mentioned_emails == []
231283
232284 def test_non_author_raises (self , snapshot , author_orguser , other_orguser , org ):
233285 comment = Comment .objects .create (
0 commit comments