Comments are now threads: replies hang off a thread's first comment, which alone points at text and can be resolved. Authors can edit their own comments, and anyone who can comment can react with an emoji. Resolved threads stop lighting text in the editor and fold away in the panel. Comments can @mention people. People watch the pages they create or comment on, and can watch or mute a page from its menu. Muting is remembered. The inbox collects comments on watched pages, replies in your threads, mentions (in comments and in page text), pages shared with you and resolved threads. It shows an unread badge in the sidebar, polled every minute, and links straight to the thread. Nobody hears about their own actions or about pages they cannot open, and a notification hides its text once access is lost. Unread notifications are emailed as a digest every few minutes unless the person turns that off. Read ones are pruned after 90 days. The jobs registry can now run jobs on a timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package mail
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRender(t *testing.T) {
|
|
m, err := Render("a@b.test", "test", map[string]string{"AppName": "Acme <Wiki>"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m.To != "a@b.test" || m.Subject != "Acme <Wiki> test email" {
|
|
t.Errorf("to/subject = %q / %q", m.To, m.Subject)
|
|
}
|
|
if !strings.Contains(m.HTML, "Acme <Wiki>") {
|
|
t.Errorf("html must escape the app name: %s", m.HTML)
|
|
}
|
|
if strings.Contains(m.Text, "test email\n") || !strings.HasPrefix(m.Text, "This is a test email") {
|
|
t.Errorf("text must not repeat the subject: %q", m.Text)
|
|
}
|
|
}
|
|
|
|
func TestDigest(t *testing.T) {
|
|
m, err := Render("a@x.test", "digest", map[string]any{
|
|
"AppName": "Docwell", "Name": "Ann", "Count": 2, "SettingsLink": "https://w/notifications",
|
|
"Items": []struct{ Text, Link string }{{"Bob commented on “Plan”: <b>hi</b>", "https://w/p/1"}, {"x", "https://w/p/2"}},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m.Subject != "2 new notifications on Docwell" {
|
|
t.Fatalf("subject = %q", m.Subject)
|
|
}
|
|
if !strings.Contains(m.HTML, "<b>hi</b>") || !strings.Contains(m.Text, "https://w/p/2") {
|
|
t.Fatalf("body:\n%s\n%s", m.HTML, m.Text)
|
|
}
|
|
}
|