2026-06-25 08:20:03 +00:00
|
|
|
package placement
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestShouldTryCrawlerFirst_mixedWithBrowser(t *testing.T) {
|
|
|
|
|
m := MemberContext{
|
2026-06-25 09:34:28 +00:00
|
|
|
AllowsCrawler: true,
|
|
|
|
|
BrowserConnected: true,
|
|
|
|
|
SearchSourceMode: SearchSourceMixed,
|
|
|
|
|
AllowsThreadsAPI: true,
|
|
|
|
|
ApiConnected: true,
|
2026-06-25 08:20:03 +00:00
|
|
|
}
|
|
|
|
|
if !ShouldTryCrawlerFirst(m) {
|
|
|
|
|
t.Fatal("mixed + browser should try crawler first to save API")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestShouldTryCrawlerFirst_threadsOnly(t *testing.T) {
|
|
|
|
|
m := MemberContext{
|
|
|
|
|
AllowsCrawler: true,
|
|
|
|
|
BrowserConnected: true,
|
|
|
|
|
SearchSourceMode: SearchSourceThreads,
|
|
|
|
|
}
|
|
|
|
|
if ShouldTryCrawlerFirst(m) {
|
|
|
|
|
t.Fatal("threads-only must not use crawler first")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildMemberContextFormalModeKeepsCrawlerMode(t *testing.T) {
|
|
|
|
|
prefs := ConnectionPrefsInput{
|
|
|
|
|
DevMode: false,
|
|
|
|
|
SearchSourceMode: string(SearchSourceThreadsCrawler),
|
|
|
|
|
}
|
|
|
|
|
ctx := BuildMemberContext("t", "u", "acc", prefs, true, true, ResearchSettings{}, false, 10)
|
|
|
|
|
if !ctx.AllowsCrawler {
|
|
|
|
|
t.Fatal("threads_crawler in formal mode should allow crawler")
|
|
|
|
|
}
|
|
|
|
|
if !ctx.AllowsThreadsAPI {
|
|
|
|
|
t.Fatal("threads_crawler should still allow API fallback")
|
|
|
|
|
}
|
2026-06-25 09:34:28 +00:00
|
|
|
}
|