Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: Add CF4 and CF5 integration tests

Mario5aa69dc254b1
diff --git a/tests/integration/config_test.go b/tests/integration/config_test.go
index e002e836..12275fc5 100644
--- a/tests/integration/config_test.go
+++ b/tests/integration/config_test.go
@@ -141,3 +141,63 @@ func TestConfig_ChromeVersionOverride(t *testing.T) {
t.Logf("Chrome version override working: %s", version)
}
+
+// CF4: Custom profile directory
+// Verify that BRIDGE_PROFILE environment variable is accepted and server starts.
+// Usage: TEST_PROFILE_DIR=/tmp/custom-profile go test -tags integration -v -run TestConfig_CustomProfileDir
+func TestConfig_CustomProfileDir(t *testing.T) {
+ // Check if TEST_PROFILE_DIR was set
+ testProfileDir := os.Getenv("TEST_PROFILE_DIR")
+ if testProfileDir == "" {
+ t.Skip("TEST_PROFILE_DIR not set; set it to run this test (e.g., TEST_PROFILE_DIR=/tmp/custom-profile go test -tags integration -v)")
+ }
+
+ // If we reach here, the server has already been started with the custom profile dir.
+ // Simply verify the server is responding to requests - this confirms BRIDGE_PROFILE
+ // was accepted and the server started without error.
+ navigate(t, "https://example.com")
+
+ code, body := httpPost(t, "/evaluate", map[string]string{
+ "expression": "window.location.href",
+ })
+ if code != 200 {
+ t.Fatalf("expected 200, got %d (body: %s)", code, body)
+ }
+
+ result := jsonField(t, body, "result")
+ if result == "" {
+ t.Errorf("expected non-empty result from evaluate")
+ }
+
+ t.Logf("Custom profile directory test passed: server responding normally")
+}
+
+// CF5: NO_RESTORE configuration
+// Verify that BRIDGE_NO_RESTORE environment variable is accepted and server starts.
+// Usage: TEST_NO_RESTORE=true go test -tags integration -v -run TestConfig_NoRestore
+func TestConfig_NoRestore(t *testing.T) {
+ // Check if TEST_NO_RESTORE was set
+ testNoRestore := os.Getenv("TEST_NO_RESTORE")
+ if testNoRestore == "" {
+ t.Skip("TEST_NO_RESTORE not set; set it to run this test (e.g., TEST_NO_RESTORE=true go test -tags integration -v)")
+ }
+
+ // If we reach here, the server has already been started with the NO_RESTORE config.
+ // Simply verify the server is responding to requests - this confirms BRIDGE_NO_RESTORE
+ // was accepted and the server started without error.
+ navigate(t, "https://example.com")
+
+ code, body := httpPost(t, "/evaluate", map[string]string{
+ "expression": "window.location.href",
+ })
+ if code != 200 {
+ t.Fatalf("expected 200, got %d (body: %s)", code, body)
+ }
+
+ result := jsonField(t, body, "result")
+ if result == "" {
+ t.Errorf("expected non-empty result from evaluate")
+ }
+
+ t.Logf("NO_RESTORE configuration test passed: server responding normally")
+}
diff --git a/tests/integration/main_test.go b/tests/integration/main_test.go
index 983afccc..56f3723a 100644
--- a/tests/integration/main_test.go
+++ b/tests/integration/main_test.go
@@ -16,6 +16,17 @@ import (
var serverURL string
+// removeEnvPrefix removes all environment variables starting with the given prefix
+func removeEnvPrefix(env []string, prefix string) []string {
+ result := []string{}
+ for _, e := range env {
+ if !strings.HasPrefix(e, prefix) {
+ result = append(result, e)
+ }
+ }
+ return result
+}
+
func TestMain(m *testing.M) {
port := os.Getenv("PINCHTAB_TEST_PORT")
if port == "" {
@@ -68,6 +79,21 @@ func TestMain(m *testing.M) {
env = append(env, "BRIDGE_CHROME_VERSION="+testChromeVersion)
}
+ // Pass BRIDGE_PROFILE if TEST_PROFILE_DIR is set
+ if testProfileDir := os.Getenv("TEST_PROFILE_DIR"); testProfileDir != "" {
+ fmt.Fprintf(os.Stderr, "TestMain: setting BRIDGE_PROFILE=%s from TEST_PROFILE_DIR\n", testProfileDir)
+ // Remove the default BRIDGE_PROFILE and use the test-specified one
+ env = removeEnvPrefix(env, "BRIDGE_PROFILE=")
+ env = append(env, "BRIDGE_PROFILE="+testProfileDir)
+ }
+
+ // Handle BRIDGE_NO_RESTORE - only disable if TEST_NO_RESTORE is explicitly set
+ if testNoRestore := os.Getenv("TEST_NO_RESTORE"); testNoRestore != "" {
+ fmt.Fprintf(os.Stderr, "TestMain: setting BRIDGE_NO_RESTORE=%s from TEST_NO_RESTORE\n", testNoRestore)
+ env = removeEnvPrefix(env, "BRIDGE_NO_RESTORE=")
+ env = append(env, "BRIDGE_NO_RESTORE="+testNoRestore)
+ }
+
cmd.Env = env
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
diff --git a/tests/integration/tabs_test.go b/tests/integration/tabs_test.go
index 74a28829..bd027416 100644
--- a/tests/integration/tabs_test.go
+++ b/tests/integration/tabs_test.go
@@ -111,7 +111,7 @@ func TestTabs_MaxTabs(t *testing.T) {
}
// Verify we created at least one tab or hit an error
- if createdCount == 0 && len(initialTabs) > 0 {
+ if createdCount == 0 && initialTabs > 0 {
// Acceptable: either we created tabs or hit limit immediately
}