feat: add comments feature with nested replies and recursive rendering
All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
Implement full comments system: domain entities (Comment, CommentLike), value objects (CommentContent), use cases (CRUD, like toggle), SQLAlchemy repository, API v1 endpoints, web UI with comment form and nested replies, i18n translations (EN/RU/FR/DE), and E2E tests. Fix nested reply (reply-to-reply) not displaying — the flat reply_comments dict was only queried for top-level comment IDs, so deeply nested replies were saved to DB (incrementing comment count) but never rendered. Switch to a recursive Jinja2 macro that renders any nesting depth.
This commit is contained in:
50
tests/unit/domain/test_comment_like_entity.py
Normal file
50
tests/unit/domain/test_comment_like_entity.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""Tests for CommentLike domain entity.
|
||||
|
||||
This module tests the CommentLike entity creation, attributes,
|
||||
and BaseEntity integration.
|
||||
"""
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from app.domain.entities.comment_like import CommentLike
|
||||
|
||||
|
||||
class TestCommentLikeEntity:
|
||||
"""Tests for the CommentLike domain entity.
|
||||
|
||||
Covers TC-UNIT-831.
|
||||
"""
|
||||
|
||||
def test_comment_like_creation(self) -> None:
|
||||
"""Test creating a CommentLike with valid attributes.
|
||||
|
||||
TC-UNIT-831: Positive — create CommentLike instance.
|
||||
|
||||
Expected:
|
||||
- comment_id matches input
|
||||
- liked_by matches input
|
||||
- id is a valid UUID
|
||||
- created_at is set
|
||||
"""
|
||||
comment_id = UUID("00000000-0000-0000-0000-000000000001")
|
||||
liked_by = "user-123"
|
||||
|
||||
like = CommentLike(comment_id=comment_id, liked_by=liked_by)
|
||||
|
||||
assert like.comment_id == comment_id
|
||||
assert like.liked_by == liked_by
|
||||
assert isinstance(like.id, UUID)
|
||||
assert like.created_at is not None
|
||||
|
||||
def test_comment_like_to_dict(self) -> None:
|
||||
"""Test CommentLike to_dict serialization."""
|
||||
comment_id = UUID("00000000-0000-0000-0000-000000000001")
|
||||
liked_by = "device-abc-123"
|
||||
|
||||
like = CommentLike(comment_id=comment_id, liked_by=liked_by)
|
||||
data = like.to_dict()
|
||||
|
||||
assert data["comment_id"] == str(comment_id)
|
||||
assert data["liked_by"] == liked_by
|
||||
assert "id" in data
|
||||
assert "created_at" in data
|
||||
Reference in New Issue
Block a user