Phase 7 part 3: suggestions from the funnel
A new package, next, finds the pages the funnel asks for: a landing page for a signal with replies or interested people in 90 days and none yet; a product or alternative page for an app two or more people name in their replies (outreach email, origami.chat, explee.com) that the site has no page for; and picked keywords with no brief, briefs left unanswered. Sites → New pages can be filled in from a link (kind, signal, notes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package next
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"supermarket/internal/db"
|
||||
"supermarket/internal/profile"
|
||||
"supermarket/internal/prospects"
|
||||
"supermarket/internal/signals"
|
||||
)
|
||||
|
||||
var now = time.Date(2026, 11, 24, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
func openDB(t *testing.T) *db.DB {
|
||||
t.Helper()
|
||||
d, err := db.Open(filepath.Join(t.TempDir(), "app.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
return d
|
||||
}
|
||||
|
||||
func TestSignalsWithoutPages(t *testing.T) {
|
||||
d := openDB(t)
|
||||
edu := &signals.Signal{Name: "Education", Status: "testing"}
|
||||
quiet := &signals.Signal{Name: "Quiet", Status: "testing"}
|
||||
signals.Save(d, edu)
|
||||
signals.Save(d, quiet)
|
||||
for i, stage := range []string{signals.StageReplied, signals.StageReplied, signals.StageInterested} {
|
||||
if _, err := signals.Record(d, signals.Event{SignalID: edu.ID, Stage: stage, Channel: "explee", Source: "explee",
|
||||
Subject: "explee:" + string(rune('a'+i)), ExternalID: stage + string(rune('a'+i)), At: now.AddDate(0, 0, -3)}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
got, err := SignalsWithoutPages(d, now)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(got) != 1 || got[0].Title != "Education" || !strings.Contains(got[0].Why, "2 replies and 1 interested person") ||
|
||||
!strings.Contains(got[0].Action.URL, "kind=landing&signal=") {
|
||||
t.Errorf("got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppsInReplies(t *testing.T) {
|
||||
d := openDB(t)
|
||||
for i, text := range []string{
|
||||
"origami.chat campaign “CRM buyers on Salesforce”: We moved our help desk to FreeScout last year and love it.",
|
||||
"origami.chat campaign “Ministries”: Do you host Planning Center? We also use freescout.",
|
||||
"explee.com campaign “Startups”: Runs Slack and Planning Center for 40 staff.",
|
||||
"explee.com campaign “Startups”: nothing useful here",
|
||||
} {
|
||||
if _, _, err := prospects.AddContact(d, prospects.Contact{FirstName: "P", LastName: string(rune('a' + i)), Email: string(rune('a'+i)) + "@x.example",
|
||||
Source: prospects.SourceManual, SourceDetail: text}, now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
p := &profile.Profile{}
|
||||
p.Targets.Technologies = []string{"Planning Center", "Slack"}
|
||||
// The site has a FreeScout page; Salesforce is only in a campaign's name.
|
||||
ms, err := AppsInReplies(d, p, []string{"/freescout/", "/pricing/"}, []string{"Pricing"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(ms) != 1 || ms[0].Name != "Planning Center" || ms[0].People != 2 {
|
||||
t.Fatalf("mentions: %+v", ms)
|
||||
}
|
||||
s := MentionSuggestions(ms, p)
|
||||
if s[0].Kind != "Alternative page" || !strings.Contains(s[0].Why, "2 people named it") {
|
||||
t.Errorf("suggestion: %+v", s[0])
|
||||
}
|
||||
if !hasPage("FreeScout", nil, []string{"FreeScout — help desk you own"}) || hasPage("Plane", []string{"/planning-center/"}, nil) {
|
||||
t.Error("hasPage")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user