package extractor import ( "testing" ) func TestMergeOptions_StealthDefault(t *testing.T) { base := BrowserOptions{Stealth: Bool(true)} got := mergeOptions(base, nil) if got.Stealth == nil || !*got.Stealth { t.Fatal("expected stealth to default to true") } } func TestMergeOptions_StealthOverrideFalse(t *testing.T) { base := BrowserOptions{Stealth: Bool(true)} got := mergeOptions(base, []BrowserOptions{{Stealth: Bool(false)}}) if got.Stealth == nil || *got.Stealth { t.Fatal("expected stealth to be overridden to false") } } func TestMergeOptions_LaunchArgsAppend(t *testing.T) { base := BrowserOptions{LaunchArgs: []string{"--arg1"}} got := mergeOptions(base, []BrowserOptions{{LaunchArgs: []string{"--arg2", "--arg3"}}}) if len(got.LaunchArgs) != 3 { t.Fatalf("expected 3 launch args, got %d", len(got.LaunchArgs)) } if got.LaunchArgs[0] != "--arg1" || got.LaunchArgs[1] != "--arg2" || got.LaunchArgs[2] != "--arg3" { t.Fatalf("unexpected launch args: %v", got.LaunchArgs) } } func TestMergeOptions_InitScriptsAppend(t *testing.T) { base := BrowserOptions{InitScripts: []string{"script1"}} got := mergeOptions(base, []BrowserOptions{{InitScripts: []string{"script2"}}}) if len(got.InitScripts) != 2 { t.Fatalf("expected 2 init scripts, got %d", len(got.InitScripts)) } if got.InitScripts[0] != "script1" || got.InitScripts[1] != "script2" { t.Fatalf("unexpected init scripts: %v", got.InitScripts) } } func TestMergeOptions_StealthNilDoesNotOverride(t *testing.T) { base := BrowserOptions{Stealth: Bool(true)} got := mergeOptions(base, []BrowserOptions{{Stealth: nil}}) if got.Stealth == nil || !*got.Stealth { t.Fatal("expected stealth to remain true when override is nil") } } func TestStealthChromiumArgs(t *testing.T) { if len(stealthChromiumArgs) == 0 { t.Fatal("expected at least one chromium stealth arg") } found := false for _, arg := range stealthChromiumArgs { if arg == "--disable-blink-features=AutomationControlled" { found = true } } if !found { t.Fatal("expected --disable-blink-features=AutomationControlled in stealth chromium args") } } func TestStealthInitScripts(t *testing.T) { if len(stealthInitScripts) == 0 { t.Fatal("expected at least one stealth init script") } }