2026-06-24 10:02:42 +00:00
|
|
|
package placement
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestWithoutCrawlerStripsBrowserModes(t *testing.T) {
|
|
|
|
|
if got := WithoutCrawler(SearchSourceMixed); got != SearchSourceThreadsBrave {
|
|
|
|
|
t.Fatalf("mixed -> threads_brave, got %s", got)
|
|
|
|
|
}
|
|
|
|
|
if got := WithoutCrawler(SearchSourceCrawler); got != SearchSourceThreads {
|
|
|
|
|
t.Fatalf("crawler -> threads, got %s", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 16:48:56 +00:00
|
|
|
func TestMemberNeedsBraveKey(t *testing.T) {
|
|
|
|
|
threadsOnly := MemberContext{AllowsBrave: false, AllowsThreadsAPI: true, SearchSourceMode: SearchSourceThreads}
|
|
|
|
|
if MemberNeedsBraveKey(threadsOnly) {
|
|
|
|
|
t.Fatal("threads-only should not require brave key")
|
|
|
|
|
}
|
|
|
|
|
braveOnly := MemberContext{AllowsBrave: true, SearchSourceMode: SearchSourceBrave}
|
|
|
|
|
if !MemberNeedsBraveKey(braveOnly) {
|
|
|
|
|
t.Fatal("brave-only should require brave key")
|
|
|
|
|
}
|
|
|
|
|
devCrawler := MemberContext{AllowsBrave: true, DevMode: true, SearchSourceMode: SearchSourceCrawler}
|
|
|
|
|
if MemberNeedsBraveKey(devCrawler) {
|
|
|
|
|
t.Fatal("dev crawler should not require brave key")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 10:02:42 +00:00
|
|
|
func TestBuildMemberContextFormalModeNeverAllowsCrawler(t *testing.T) {
|
|
|
|
|
prefs := ConnectionPrefsInput{
|
|
|
|
|
DevMode: false,
|
|
|
|
|
SearchSourceMode: string(SearchSourceMixed),
|
|
|
|
|
}
|
|
|
|
|
ctx := BuildMemberContext("t", "u", "acc", prefs, true, false, ResearchSettings{}, false, 10)
|
|
|
|
|
if ctx.AllowsCrawler {
|
|
|
|
|
t.Fatal("formal mode must not allow crawler")
|
|
|
|
|
}
|
|
|
|
|
if ctx.SearchSourceMode != SearchSourceThreadsBrave {
|
|
|
|
|
t.Fatalf("expected threads_brave, got %s", ctx.SearchSourceMode)
|
|
|
|
|
}
|
|
|
|
|
}
|