Files
tajniak81andClaude Opus 5.5 c98b127f1e
CI / go (Media) (push) Successful in 13m40s
CI / go (Server) (push) Failing after 23m20s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 10m35s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Failing after 3h4m42s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / mobile (push) Failing after 9m19s
CI / docker (push) Successful in 2h2m57s
Add columns, suggesting mode, verified pages, scanned PDF search and server translations
- Columns: /columns puts 2 to 4 columns side by side, with widths dragged
  between them; they stack on phones. HTML export and import keep them
  (also Notion column lists and Confluence page layouts).
- Suggesting mode: edits become suggested insertions and deletions that
  editors accept or reject one by one or all at once. Text only.
- Verified pages: editors verify a page for a while or without end; the
  verifier is notified when it runs out (migration 1764700000).
- Scanned PDFs attached to pages are read by AI for search where a
  workspace turns it on.
- The server writes error messages, emails, digests and phone
  notifications in English, Polish, German, French and Spanish; the apps
  send their language with each request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:38:08 +01:00

81 lines
2.6 KiB
Go

// SPDX-License-Identifier: AGPL-3.0-or-later
package directory
import (
"strings"
"testing"
)
func TestMentionIDs(t *testing.T) {
doc := `{"type":"doc","content":[
{"type":"paragraph","content":[
{"type":"text","text":"hi "},
{"type":"mention","attrs":{"id":"bbbbbbbbbbbbbbb","label":"Bob"}},
{"type":"mention","attrs":{"id":"aaaaaaaaaaaaaaa","label":"Ann"}}]},
{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[
{"type":"mention","attrs":{"id":"bbbbbbbbbbbbbbb"}},
{"type":"mention","attrs":{"id":"bad id!"}}]}]}]}]}`
got := strings.Join(mentionIDs([]byte(doc)), ",")
if got != "aaaaaaaaaaaaaaa,bbbbbbbbbbbbbbb" {
t.Fatalf("mentionIDs = %q", got)
}
if mentionIDs([]byte("null")) != nil || mentionIDs([]byte("{")) != nil {
t.Fatal("empty documents should have no mentions")
}
}
func TestValidEmoji(t *testing.T) {
for _, e := range []string{"👍", "❤️", "🎉", "👩‍💻"} {
if !validEmoji(e) {
t.Errorf("%q should be accepted", e)
}
}
for _, e := range []string{"", "ok", "a b", "1", "👍👍👍👍👍👍👍👍👍", "\n"} {
if validEmoji(e) {
t.Errorf("%q should be refused", e)
}
}
}
func TestExcerpt(t *testing.T) {
if got := excerpt(" a\n\n b "); got != "a b" {
t.Fatalf("excerpt = %q", got)
}
if got := []rune(excerpt(strings.Repeat("x", 300))); len(got) != 200 || got[199] != '…' {
t.Fatalf("long excerpt has %d runes", len(got))
}
}
func TestLinkIDs(t *testing.T) {
link := func(href string) string {
return `{"type":"text","text":"x","marks":[{"type":"bold"},{"type":"link","attrs":{"href":"` + href + `"}}]}`
}
doc := `{"type":"doc","content":[{"type":"paragraph","content":[` + strings.Join([]string{
link("/p/bbbbbbbbbbbbbbb"),
link("https://docs.example.com/p/aaaaaaaaaaaaaaa?comment=x"),
link("/p/selfselfselfse"),
link("/p/bbbbbbbbbbbbbbb"),
link("https://example.com/other"),
link("/p/bad id"),
}, ",") + `]}]}`
got := strings.Join(linkIDs([]byte(doc), "selfselfselfse"), ",")
if got != "aaaaaaaaaaaaaaa,bbbbbbbbbbbbbbb" {
t.Fatalf("linkIDs = %q", got)
}
if ids := linkIDs([]byte("null"), "x"); ids == nil || len(ids) != 0 {
t.Fatalf("empty document should give an empty list, got %v", ids)
}
}
func TestEmailTypesLeaveOutTheOnesTurnedOff(t *testing.T) {
got := emailTypes([]string{"comment", "share"})
want := []string{"mention", "reply", "resolved", "reminder", "verify_expired", "join_request"}
if strings.Join(got, ",") != strings.Join(want, ",") {
t.Errorf("emailTypes = %v, want %v", got, want)
}
if len(emailTypes(nil)) != len(notificationTypes) {
t.Error("nothing turned off should email every type")
}
}