Phase 1, part 4: promote the company's own products
- Content lists the company first, at /content/own: its products from the profile (always there to pick from), its own feeds (a new profile field for the blog, news and releases), and new or updated pages from its websites' sitemaps, with each page's title and description. - Drafts from it are kind "product" (utm_campaign=product), filed under the company's name, and prompted to promote the company's own work without unsupported claims; on Reddit, in the makers' voice, with a warning that self-promotion is often restricted. This completes Phase 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,9 @@ package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -273,3 +275,44 @@ func TestWriteRedditNeedsSubreddit(t *testing.T) {
|
||||
t.Errorf("write without subreddit: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestOwnContentPage(t *testing.T) {
|
||||
var site *httptest.Server
|
||||
site = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/sitemap.xml":
|
||||
fmt.Fprintf(w, `<urlset><url><loc>%s/blog/launch</loc><lastmod>%s</lastmod></url></urlset>`, site.URL, time.Now().UTC().Format("2006-01-02"))
|
||||
case "/blog/launch":
|
||||
w.Write([]byte(`<title>We launched Acme Mail</title><meta name="description" content="Hosted email.">`))
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer site.Close()
|
||||
|
||||
s, h := newTestServer(t, nil)
|
||||
_ = profile.Save(s.DB, &profile.Profile{Name: "Acme", Description: "Widgets.",
|
||||
Products: []profile.Product{{Name: "Acme Mail", Description: "Hosted email.", URL: "https://acme.example/mail"}},
|
||||
Websites: []profile.Website{{URL: site.URL}}})
|
||||
|
||||
body := do(h, http.MethodGet, "/content", nil, nil).Body.String()
|
||||
if !strings.Contains(body, `href="/content/own">Acme</a>`) || !strings.Contains(body, "1 product, new pages on your websites") {
|
||||
t.Errorf("content index:\n%s", body)
|
||||
}
|
||||
body = do(h, http.MethodGet, "/content/own", nil, nil).Body.String()
|
||||
for _, want := range []string{"<h1>Acme <span class=\"badge product\">", `value="product:acme-mail"`, `action="/content/own/fetch"`,
|
||||
`href="/profile">Edit profile`, `action="/content/own/items"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("own page lacks %q", want)
|
||||
}
|
||||
}
|
||||
rec := postForm(h, "/content/own/fetch", nil)
|
||||
if body := rec.Body.String(); !strings.Contains(body, "1 new item") || !strings.Contains(body, "We launched Acme Mail") {
|
||||
t.Errorf("fetch:\n%s", body)
|
||||
}
|
||||
// Writing goes through the same form; without an AI key, its error shows.
|
||||
rec = postForm(h, "/content/own/items", url.Values{"action": {"write"}, "item": {"product:acme-mail"}, "channel": {"linkedin"}})
|
||||
if !strings.Contains(rec.Body.String(), "Anthropic API key") {
|
||||
t.Errorf("write: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user