fix: open account browser maximized without Chrome first-run
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
Human open now uses start-maximized and no-first-run flags, and profile shortcuts share the same args plus the platform URL. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -77,13 +77,42 @@ class TestCmdOpenDirectBrowser:
|
||||
assert payload["data"]["browser_exe"] == fake_exe
|
||||
assert spawned["cmd"][0] == fake_exe
|
||||
assert spawned["cmd"][1].startswith("--user-data-dir=")
|
||||
assert spawned["cmd"][2] == "https://example.com"
|
||||
assert "--start-maximized" in spawned["cmd"]
|
||||
assert "--no-first-run" in spawned["cmd"]
|
||||
assert "--no-default-browser-check" in spawned["cmd"]
|
||||
assert "--disable-search-engine-choice-screen" in spawned["cmd"]
|
||||
assert spawned["cmd"][-1] == "https://example.com"
|
||||
assert "--enable-automation" not in spawned["cmd"]
|
||||
# must NOT spawn python / open_child_runner
|
||||
joined = " ".join(spawned["cmd"])
|
||||
assert "open_child_runner" not in joined
|
||||
assert "python" not in joined.lower()
|
||||
|
||||
|
||||
class TestHumanChromeLaunchArgs:
|
||||
def test_flags_then_url(self, tmp_path):
|
||||
from service.browser_service import HUMAN_CHROME_FLAGS, human_chrome_launch_args
|
||||
|
||||
profile = str(tmp_path / "prof")
|
||||
args = human_chrome_launch_args(profile, "https://chat.deepseek.com")
|
||||
assert args[0].startswith("--user-data-dir=")
|
||||
for flag in HUMAN_CHROME_FLAGS:
|
||||
assert flag in args
|
||||
assert args[-1] == "https://chat.deepseek.com"
|
||||
assert "--enable-automation" not in args
|
||||
|
||||
def test_shortcut_arguments_quote_profile_and_include_url(self, tmp_path):
|
||||
from service.browser_service import human_chrome_shortcut_arguments
|
||||
|
||||
profile = tmp_path / "my prof"
|
||||
profile.mkdir()
|
||||
text = human_chrome_shortcut_arguments(str(profile), "https://example.com")
|
||||
assert '--user-data-dir="' in text
|
||||
assert "--start-maximized" in text
|
||||
assert "--no-first-run" in text
|
||||
assert text.endswith("https://example.com")
|
||||
|
||||
|
||||
class TestResolveChromiumChannel:
|
||||
"""resolve_chromium_channel returns a channel string when browsers exist."""
|
||||
|
||||
|
||||
@@ -31,6 +31,33 @@ class TestCreateProfileBrowserShortcut:
|
||||
out = create_profile_browser_shortcut(str(tmp_path), "demo")
|
||||
assert out is None
|
||||
|
||||
def test_windows_lnk_uses_human_chrome_args(self, tmp_path, monkeypatch) -> None:
|
||||
captured = {}
|
||||
|
||||
def fake_run(argv, **kwargs):
|
||||
captured["argv"] = list(argv)
|
||||
class Result:
|
||||
returncode = 0
|
||||
return Result()
|
||||
|
||||
monkeypatch.setattr("util.profile_shortcut.sys.platform", "win32")
|
||||
monkeypatch.setattr(
|
||||
"util.profile_shortcut.resolve_chromium_executable",
|
||||
lambda: r"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
||||
)
|
||||
monkeypatch.setattr("util.profile_shortcut.subprocess.run", fake_run)
|
||||
monkeypatch.setattr("util.profile_shortcut.os.path.isfile", lambda path: True)
|
||||
|
||||
out = create_profile_browser_shortcut(
|
||||
str(tmp_path), "demo", url="https://chat.deepseek.com",
|
||||
)
|
||||
assert out is not None
|
||||
ps = captured["argv"][-1]
|
||||
assert "--start-maximized" in ps
|
||||
assert "--no-first-run" in ps
|
||||
assert "https://chat.deepseek.com" in ps
|
||||
assert "--enable-automation" not in ps
|
||||
|
||||
@pytest.mark.skipif(sys.platform != "win32", reason="Windows .lnk only")
|
||||
def test_creates_lnk_on_windows(self, tmp_path, monkeypatch) -> None:
|
||||
from service.browser_service import resolve_chromium_executable
|
||||
|
||||
Reference in New Issue
Block a user