Files
pipelines/internal/server/chat_reply_paragraphs_test.go
T
alan 895b23d2da Chat reply notifications: up to 1000 characters, paragraphs kept
The finished-reply notification now carries up to 1000 characters of the reply
(was 200), keeping its paragraph breaks for the app's expanded notification;
ntfy still gets it on one line within its 2048-byte limit.
2026-11-02 17:08:19 +00:00

27 lines
884 B
Go

package server
import (
"strings"
"testing"
"unicode/utf8"
)
func TestReplyNotificationKeepsParagraphs(t *testing.T) {
got := paragraphs(" First line \r\n\r\n\n\n Second paragraph \nthird\x00 line\n\n")
if want := "First line\n\nSecond paragraph\nthird line"; got != want {
t.Fatalf("paragraphs = %q, want %q", got, want)
}
_, body := chatReplyText("Chat", "One\n\nTwo")
if body != "One\n\nTwo" {
t.Fatalf("app body should keep paragraph breaks, got %q", body)
}
// ntfy gets the same text on one line.
if flat := singleLine(body); strings.Contains(flat, "\n") || flat != "One Two" {
t.Fatalf("ntfy body = %q", flat)
}
long := truncateRunes(strings.Repeat("a", 1500), chatReplyBodyRunes)
if n := utf8.RuneCountInString(long); n != chatReplyBodyRunes+1 || chatReplyBodyRunes != 1000 {
t.Fatalf("excerpt is %d runes (limit %d)", n, chatReplyBodyRunes)
}
}