- Inbox: a top-level page, with a count in the menu, for everything waiting for approval; Content's drafts are reviewed there. /drafts redirects to it. - Scheduling: publish a draft now or at a time (migration 3 adds publish_at). A scheduler in the app publishes due drafts every 30 seconds. Posts more than 12 hours overdue, or refused before posting, go back to the Inbox with the reason. Content gets Scheduled and Published tabs. - UTM tags on links to the company's own websites and product pages, added when publishing; drafts stay untagged. - The container runs in the computer's time zone, so times are shown and read correctly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
2.0 KiB
Go
43 lines
2.0 KiB
Go
package utm
|
|
|
|
import "testing"
|
|
|
|
func TestTagger(t *testing.T) {
|
|
tg := NewTagger([]string{"https://www.acme.example/", "acme.dev", "", "https://acme.example/pricing"})
|
|
p := Params{Source: "x", Medium: "social", Campaign: "partner", Content: "jitsi-12"}
|
|
|
|
for in, want := range map[string]string{
|
|
"https://acme.example/blog/post": "https://acme.example/blog/post?utm_campaign=partner&utm_content=jitsi-12&utm_medium=social&utm_source=x",
|
|
"https://docs.acme.dev/x?a=1": "https://docs.acme.dev/x?a=1&utm_campaign=partner&utm_content=jitsi-12&utm_medium=social&utm_source=x",
|
|
"https://www.acme.example/?utm_source=newsletter#top": "https://www.acme.example/?utm_campaign=partner&utm_content=jitsi-12&utm_medium=social&utm_source=newsletter#top",
|
|
"https://jitsi.org/news": "https://jitsi.org/news",
|
|
"https://notacme.example/": "https://notacme.example/",
|
|
"https://x.com/acme/status/1": "https://x.com/acme/status/1",
|
|
"": "",
|
|
} {
|
|
if got := tg.URL(in, p); got != want {
|
|
t.Errorf("URL(%q) = %q, want %q", in, got, want)
|
|
}
|
|
}
|
|
|
|
text := "Read it (https://acme.example/a). Or https://jitsi.org/b, or https://acme.dev!"
|
|
want := "Read it (https://acme.example/a?utm_campaign=partner&utm_content=jitsi-12&utm_medium=social&utm_source=x). " +
|
|
"Or https://jitsi.org/b, or https://acme.dev?utm_campaign=partner&utm_content=jitsi-12&utm_medium=social&utm_source=x!"
|
|
if got := tg.Text(text, p); got != want {
|
|
t.Errorf("Text =\n%s\nwant\n%s", got, want)
|
|
}
|
|
|
|
var none *Tagger
|
|
if none.URL("https://acme.example", p) != "https://acme.example" || NewTagger(nil).Text(text, p) != text {
|
|
t.Error("a tagger without sites must change nothing")
|
|
}
|
|
}
|
|
|
|
func TestSlug(t *testing.T) {
|
|
for in, want := range map[string]string{"Jitsi Meet": "jitsi-meet", " Acme, Inc. ": "acme-inc", "Ünïcode 2": "n-code-2", "": ""} {
|
|
if got := Slug(in); got != want {
|
|
t.Errorf("Slug(%q) = %q, want %q", in, got, want)
|
|
}
|
|
}
|
|
}
|