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) } } 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") } } 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) } }