CI / go (Media) (push) Successful in 14m33s
CI / go (Server) (push) Failing after 23m30s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 9m30s
CI / desktop (ubuntu-latest) (push) Successful in 1h21m24s
CI / mobile (push) Failing after 4m16s
CI / docker (push) Successful in 1h1m25s
Docs / build (push) Successful in 14m59s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Phase G of docs/AFFINE.md (ADR-17): - Invite links: one per workspace (member or guest, optional end date, optional admin approval) on a new /join page. Requests are approved (optionally as another role) or declined from workspace settings; join_request, join_approved and join_declined notifications reach the inbox, phones and the email digest. Workspace admins decide, else the organization's admins, else superadmins. Signup honours ?redirect=. - Workspace switches: allowSharing (off makes every share link answer 404 until it is back on) and urlPreview (chat apps may show private pages' titles). docwell-web writes title and Open Graph tags for known link-preview bots, asking docwell-server via DOCWELL_PREVIEW_API_URL; search engines are left out. - Page analytics: page_views counts opens per page, person and day from the existing visit call and share-link reads; editors see totals, a daily chart and recent viewers in the Info panel. analytics.prune drops rows after 400 days. - Unused files: attachments whose id appears in no page's Yjs state, page icon or comment (older than a day) are listed and deleted from workspace settings. - Migration, schema snapshot, OpenAPI, generated clients, translations in five languages, phone inbox, compose files and user docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
2.6 KiB
Go
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", "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")
|
|
}
|
|
}
|