mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
fix: report ErrSearchTimeout when results never hydrate; raise integration selector timeout to 15s
This commit is contained in:
@@ -160,7 +160,12 @@ func (baid *Baidu) waitForParsedSearchResults(ctx context.Context, page *rod.Pag
|
||||
}
|
||||
return nil, core.ErrParser
|
||||
}
|
||||
return nil, nil
|
||||
// The page never reached a recognizable state: no result containers, no
|
||||
// captcha or timeout markers. Baidu hydrates result cards client-side and
|
||||
// can exceed the selector deadline, so report a timeout rather than a
|
||||
// successful empty SERP — callers must retry/skip, not trust 0 results.
|
||||
baid.logger.Debug("No result containers or block markers within selector timeout")
|
||||
return nil, core.ErrSearchTimeout
|
||||
}
|
||||
|
||||
// SearchImage executes a Baidu image search and returns normalized image
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchBaidu(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchBing(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchDuckDuckGo(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchEcosia(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchGoogle(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ func HandleError(t *testing.T, operation string, err error) {
|
||||
t.Skipf("skipping flaky live %s: %v", operation, err)
|
||||
}
|
||||
|
||||
// EngineOptions returns engine options tuned for live-site integration runs.
|
||||
// Real SERPs (Baidu especially) hydrate result cards client-side and can take
|
||||
// well past the 5s default selector timeout on a first visit.
|
||||
func EngineOptions() core.SearchEngineOptions {
|
||||
return core.SearchEngineOptions{SelectorTimeout: 15}
|
||||
}
|
||||
|
||||
// CreateBrowser creates a browser configured for integration tests and closes
|
||||
// it when the test finishes. Respects OPENSERP_INTEGRATION_HEADFUL for
|
||||
// debugging (browser and page are left open for inspection).
|
||||
|
||||
@@ -12,6 +12,6 @@ import (
|
||||
|
||||
func TestSearchYandex(t *testing.T) {
|
||||
ithelper.RunEngineTests(t, func(b *core.Browser) core.SearchEngine {
|
||||
return New(*b, core.SearchEngineOptions{})
|
||||
return New(*b, ithelper.EngineOptions())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user