6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
"""Behavior guard for the comment-reply notification handler."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.db import User, Workspace
|
|
from app.notifications.service import NotificationService
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
handler = NotificationService.comment_reply
|
|
|
|
|
|
async def _notify(db_session, db_user, db_workspace, *, reply_id=1, preview="hi"):
|
|
"""Raise a comment-reply notification for the assertions in the tests below."""
|
|
return await handler.notify_comment_reply(
|
|
session=db_session,
|
|
user_id=db_user.id,
|
|
reply_id=reply_id,
|
|
parent_comment_id=10,
|
|
message_id=20,
|
|
thread_id=30,
|
|
thread_title="Thread",
|
|
author_id="author-1",
|
|
author_name="Bob",
|
|
author_avatar_url=None,
|
|
author_email="bob@surfsense.net",
|
|
content_preview=preview,
|
|
workspace_id=db_workspace.id,
|
|
)
|
|
|
|
|
|
async def test_comment_reply_title_and_message(
|
|
db_session: AsyncSession, db_user: User, db_workspace: Workspace
|
|
):
|
|
"""A reply notification names the author and carries the comment preview."""
|
|
notification = await _notify(db_session, db_user, db_workspace, preview="thanks")
|
|
|
|
assert notification.type == "comment_reply"
|
|
assert notification.title == "Bob replied in a thread"
|
|
assert notification.message == "thanks"
|
|
|
|
|
|
async def test_comment_reply_truncates_long_preview(
|
|
db_session: AsyncSession, db_user: User, db_workspace: Workspace
|
|
):
|
|
"""A long comment preview is truncated in the reply message."""
|
|
notification = await _notify(db_session, db_user, db_workspace, preview="y" * 150)
|
|
|
|
assert notification.message == "y" * 100 + "..."
|
|
|
|
|
|
async def test_comment_reply_is_idempotent(
|
|
db_session: AsyncSession, db_user: User, db_workspace: Workspace
|
|
):
|
|
"""Re-notifying the same reply id reuses the existing notification row."""
|
|
first = await _notify(db_session, db_user, db_workspace, reply_id=5)
|
|
second = await _notify(db_session, db_user, db_workspace, reply_id=5)
|
|
|
|
assert second.id == first.id
|