High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: improving stability of integration tests
Luigi Agosti4b0770ea36e3
diff --git a/tests/integration/actions_test.go b/tests/integration/actions_test.goindex 86089012..b124f5bd 100644--- a/tests/integration/actions_test.go+++ b/tests/integration/actions_test.go@@ -14,7 +14,7 @@ func TestAction_Click(t *testing.T) {defer closeCurrentTab(t)// Get snapshot to find a clickable ref- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)s := string(snapBody)// Find a ref like [e0] or [e1] for the link@@ -127,7 +127,7 @@ func TestAction_Type(t *testing.T) {navigate(t, "https://httpbin.org/forms/post")defer closeCurrentTab(t)- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)ref := findRef(string(snapBody), "textbox")if ref == "" {ref = findRef(string(snapBody), "input")@@ -152,7 +152,7 @@ func TestAction_Fill(t *testing.T) {navigate(t, "https://httpbin.org/forms/post")defer closeCurrentTab(t)- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)ref := findRef(string(snapBody), "textbox")if ref == "" {ref = findRef(string(snapBody), "input")@@ -177,7 +177,7 @@ func TestAction_Focus(t *testing.T) {navigate(t, "https://httpbin.org/forms/post")defer closeCurrentTab(t)- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)ref := findRef(string(snapBody), "textbox")if ref == "" {t.Skip("no focusable ref found")@@ -212,6 +212,7 @@ func TestAction_Scroll(t *testing.T) {func TestAction_Batch(t *testing.T) {navigate(t, "https://example.com")payload := map[string]any{+ "tabId": currentTabID,"actions": []map[string]any{{"kind": "press", "key": "Escape"},{"kind": "scroll", "direction": "down"},@@ -238,7 +239,7 @@ func TestAction_Hover(t *testing.T) {navigate(t, "https://example.com")// Get snapshot to find a link ref- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)s := string(snapBody)// Find a link ref@@ -265,7 +266,7 @@ func TestAction_Select(t *testing.T) {defer closeCurrentTab(t)// Get snapshot to find a select element- _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text")+ _, snapBody := httpGet(t, "/snapshot?filter=interactive&format=text&tabId="+currentTabID)ref := findRef(string(snapBody), "combobox")if ref == "" {ref = findRef(string(snapBody), "select")diff --git a/tests/integration/config_test.go b/tests/integration/config_test.goindex bcfac83c..74e06a10 100644--- a/tests/integration/config_test.go+++ b/tests/integration/config_test.go@@ -27,6 +27,7 @@ func TestConfig_ChromeVersionDefault(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "navigator.userAgent",})if code != 200 {@@ -58,6 +59,7 @@ func TestConfig_ChromeVersionInFingerprint(t *testing.T) {// Get initial user agentcode1, body1 := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "navigator.userAgent",})if code1 != 200 {@@ -75,7 +77,8 @@ func TestConfig_ChromeVersionInFingerprint(t *testing.T) {// Rotate fingerprint with "mac" OS to ensure consistent test results// (don't use random because we want to verify the Chrome version is preserved)code2, body2 := httpPost(t, "/fingerprint/rotate", map[string]string{- "os": "mac",+ "os": "mac",+ "tabId": currentTabID,})if code2 != 200 {t.Fatalf("expected 200 for fingerprint rotate, got %d (body: %s)", code2, body2)@@ -83,6 +86,7 @@ func TestConfig_ChromeVersionInFingerprint(t *testing.T) {// Get user agent after rotationcode3, body3 := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "navigator.userAgent",})if code3 != 200 {@@ -119,6 +123,7 @@ func TestConfig_ChromeVersionOverride(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "navigator.userAgent",})if code != 200 {@@ -158,6 +163,7 @@ func TestConfig_CustomProfileDir(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "window.location.href",})if code != 200 {@@ -188,6 +194,7 @@ func TestConfig_NoRestore(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "window.location.href",})if code != 200 {@@ -211,6 +218,7 @@ func TestConfig_ConfigFilePreference(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "document.title",})if code != 200 {@@ -234,6 +242,7 @@ func TestConfig_EnvOverridesConfig(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "window.location.href",})if code != 200 {@@ -264,6 +273,7 @@ func TestConfig_CDPURLExternalChrome(t *testing.T) {navigate(t, "https://example.com")code, body := httpPost(t, "/evaluate", map[string]string{+ "tabId": currentTabID,"expression": "navigator.userAgent",})if code != 200 {diff --git a/tests/integration/cookies_test.go b/tests/integration/cookies_test.goindex f95bfe32..84fdd5f3 100644--- a/tests/integration/cookies_test.go+++ b/tests/integration/cookies_test.go@@ -10,7 +10,7 @@ import (// C1: Get cookiesfunc TestCookies_Get(t *testing.T) {navigate(t, "https://example.com")- code, body := httpGet(t, "/cookies")+ code, body := httpGet(t, "/cookies?tabId="+currentTabID)if code != 200 {t.Fatalf("expected 200, got %d (body: %s)", code, body)}@@ -57,7 +57,8 @@ func TestCookies_Set(t *testing.T) {// Set a cookiecode, body := httpPost(t, "/cookies", map[string]any{- "url": "https://example.com",+ "tabId": currentTabID,+ "url": "https://example.com","cookies": []map[string]any{{"name": "test_cookie",@@ -83,7 +84,7 @@ func TestCookies_Set(t *testing.T) {}// Verify the cookie was set by getting cookies again- code2, body2 := httpGet(t, "/cookies?url=https://example.com")+ code2, body2 := httpGet(t, "/cookies?url=https://example.com&tabId="+currentTabID)if code2 != 200 {t.Fatalf("GET /cookies failed: %d", code2)}@@ -142,6 +143,7 @@ func TestCookies_SetEmpty(t *testing.T) {// Post with empty cookies arraycode, body := httpPost(t, "/cookies", map[string]any{+ "tabId": currentTabID,"url": "https://example.com","cookies": []map[string]any{},})diff --git a/tests/integration/error_handling_test.go b/tests/integration/error_handling_test.goindex 42c3d94e..d204b423 100644--- a/tests/integration/error_handling_test.go+++ b/tests/integration/error_handling_test.go@@ -16,7 +16,7 @@ func TestError_UnicodeContent(t *testing.T) {navigate(t, "https://www.wikipedia.org")// Test snapshot- code, snapBody := httpGet(t, "/snapshot")+ code, snapBody := httpGet(t, "/snapshot?tabId="+currentTabID)if code != 200 {t.Errorf("snapshot failed with %d", code)}@@ -28,7 +28,7 @@ func TestError_UnicodeContent(t *testing.T) {}// Test text- code, textBody := httpGet(t, "/text")+ code, textBody := httpGet(t, "/text?tabId="+currentTabID)if code != 200 {t.Errorf("text failed with %d", code)}@@ -46,7 +46,7 @@ func TestError_EmptyPage(t *testing.T) {navigate(t, "about:blank")// Test snapshot- code, snapBody := httpGet(t, "/snapshot")+ code, snapBody := httpGet(t, "/snapshot?tabId="+currentTabID)if code != 200 {t.Errorf("snapshot on empty page failed with %d", code)}@@ -58,7 +58,7 @@ func TestError_EmptyPage(t *testing.T) {}// Test text- code, textBody := httpGet(t, "/text")+ code, textBody := httpGet(t, "/text?tabId="+currentTabID)if code != 200 {t.Errorf("text on empty page failed with %d", code)}@@ -82,7 +82,7 @@ func TestError_BinaryPage(t *testing.T) {// Test snapshot on PDF content// PDF may not render as a traditional page, so snapshot might fail or return empty// We just verify it doesn't crash and returns gracefully- code, snapBody := httpGet(t, "/snapshot")+ code, snapBody := httpGet(t, "/snapshot?tabId="+currentTabID)if code == 200 {// Verify response is valid JSON (even if empty/error)var snapData map[string]any@@ -97,7 +97,7 @@ func TestError_BinaryPage(t *testing.T) {}// Test text extraction on PDF- code, textBody := httpGet(t, "/text")+ code, textBody := httpGet(t, "/text?tabId="+currentTabID)if code == 200 {var textData map[string]anyif err := json.Unmarshal(textBody, &textData); err != nil {