@@ -9969,7 +9969,7 @@ def test_locator_click_dispatches_trusted_mouse_sequence_by_default(page, monkey
99699969 """
99709970 )
99719971
9972- page.locator("#go").click(timeout=1_000 )
9972+ page.locator("#go").click(timeout=3_000 )
99739973
99749974 events = page.evaluate("window.events")
99759975 assert [event["type"] for event in events] == [
@@ -25309,6 +25309,147 @@ def read(self):
2530925309 assert os.access(executable, os.X_OK)
2531025310
2531125311
25312+ def test_cli_exact_chromium_version_uses_direct_download_url():
25313+ from rustwright import cli
25314+
25315+ download = cli._chrome_for_testing_download("linux64", version="123.0.6312.86")
25316+
25317+ assert download == {
25318+ "version": "123.0.6312.86",
25319+ "url": (
25320+ "https://storage.googleapis.com/chrome-for-testing-public/"
25321+ "123.0.6312.86/linux64/chrome-linux64.zip"
25322+ ),
25323+ "platform": "linux64",
25324+ }
25325+
25326+
25327+ def test_cli_install_pinned_chromium_bypasses_system_browser(monkeypatch, capsys):
25328+ from rustwright import cli
25329+
25330+ calls = []
25331+ monkeypatch.setenv("RUSTWRIGHT_CHROMIUM_VERSION", "124.0.6367.91")
25332+ monkeypatch.setattr(
25333+ cli,
25334+ "_chromium_executable_path",
25335+ lambda: pytest.fail("pinned install must not resolve a system browser"),
25336+ )
25337+ monkeypatch.setattr(
25338+ cli,
25339+ "_download_chromium",
25340+ lambda **kwargs: calls.append(kwargs)
25341+ or {
25342+ "executable": "/cache/chromium-124.0.6367.91/chrome-linux64/chrome",
25343+ "downloaded": True,
25344+ "url": "https://example.test/124.0.6367.91/chrome-linux64.zip",
25345+ },
25346+ )
25347+
25348+ assert cli.install(["chromium"]) == 0
25349+
25350+ assert calls == [{"force": False, "dry_run": False, "version": "124.0.6367.91"}]
25351+ output = capsys.readouterr().out
25352+ assert "installed pinned Chromium 124.0.6367.91 executable" in output
25353+
25354+
25355+ def test_cli_install_version_flag_overrides_environment(monkeypatch, capsys):
25356+ from rustwright import cli
25357+
25358+ calls = []
25359+ monkeypatch.setenv("RUSTWRIGHT_CHROMIUM_VERSION", "124.0.6367.91")
25360+ monkeypatch.setattr(
25361+ cli,
25362+ "_chromium_executable_path",
25363+ lambda: pytest.fail("pinned install must not resolve a system browser"),
25364+ )
25365+ monkeypatch.setattr(
25366+ cli,
25367+ "_download_chromium",
25368+ lambda **kwargs: calls.append(kwargs)
25369+ or {
25370+ "executable": "/cache/chromium-125.0.6422.60/chrome-linux64/chrome",
25371+ "downloaded": False,
25372+ "url": "https://example.test/125.0.6422.60/chrome-linux64.zip",
25373+ },
25374+ )
25375+
25376+ assert cli.install(["chromium", "--version", "125.0.6422.60", "--dry-run"]) == 0
25377+
25378+ assert calls == [{"force": False, "dry_run": True, "version": "125.0.6422.60"}]
25379+ output = capsys.readouterr().out
25380+ assert "would download pinned Chromium 125.0.6422.60" in output
25381+ assert output.rstrip().endswith("/cache/chromium-125.0.6422.60/chrome-linux64/chrome")
25382+
25383+
25384+ def test_cli_install_pinned_chromium_fails_without_fallback(monkeypatch, capsys):
25385+ from rustwright import cli
25386+
25387+ monkeypatch.setenv("RUSTWRIGHT_CHROMIUM_VERSION", "126.0.6478.55")
25388+ monkeypatch.setattr(
25389+ cli,
25390+ "_chromium_executable_path",
25391+ lambda: pytest.fail("pinned install must not resolve a system browser"),
25392+ )
25393+ monkeypatch.setattr(
25394+ cli,
25395+ "_download_chromium",
25396+ lambda **kwargs: (_ for _ in ()).throw(RuntimeError("HTTP 404")),
25397+ )
25398+
25399+ assert cli.install(["chromium"]) == 1
25400+
25401+ error = capsys.readouterr().err
25402+ assert "Could not install pinned Chromium 126.0.6478.55" in error
25403+ assert "will not fall back to a system browser or a different Chrome for Testing build" in error
25404+ assert "HTTP 404" in error
25405+
25406+
25407+ def test_cli_install_rejects_invalid_pinned_chromium_version(monkeypatch, capsys):
25408+ from rustwright import cli
25409+
25410+ monkeypatch.setenv("RUSTWRIGHT_CHROMIUM_VERSION", "stable")
25411+ monkeypatch.setattr(
25412+ cli,
25413+ "_download_chromium",
25414+ lambda **kwargs: pytest.fail("invalid pinned version must fail before download resolution"),
25415+ )
25416+
25417+ assert cli.install(["chromium"]) == 1
25418+
25419+ assert "expected a full Chrome for Testing version" in capsys.readouterr().err
25420+
25421+
25422+ def test_cli_install_rejects_explicit_empty_chromium_version(monkeypatch, capsys):
25423+ from rustwright import cli
25424+
25425+ monkeypatch.delenv("RUSTWRIGHT_CHROMIUM_VERSION", raising=False)
25426+ monkeypatch.setattr(
25427+ cli,
25428+ "_download_chromium",
25429+ lambda **kwargs: pytest.fail("invalid pinned version must fail before download resolution"),
25430+ )
25431+
25432+ assert cli.install(["chromium", "--version", ""]) == 1
25433+
25434+ assert "expected a full Chrome for Testing version" in capsys.readouterr().err
25435+
25436+
25437+ def test_cli_install_empty_version_environment_keeps_unpinned_behavior(monkeypatch, capsys):
25438+ from rustwright import cli
25439+
25440+ monkeypatch.setenv("RUSTWRIGHT_CHROMIUM_VERSION", "")
25441+ monkeypatch.setattr(cli, "_chromium_executable_path", lambda: "/usr/bin/chromium")
25442+ monkeypatch.setattr(
25443+ cli,
25444+ "_download_chromium",
25445+ lambda **kwargs: pytest.fail("empty pin must preserve system-browser resolution"),
25446+ )
25447+
25448+ assert cli.install(["chromium"]) == 0
25449+
25450+ assert "Rustwright found Chromium executable: /usr/bin/chromium" in capsys.readouterr().out
25451+
25452+
2531225453def test_cli_chrome_for_testing_platform_rejects_linux_arm64(monkeypatch):
2531325454 from rustwright import cli
2531425455
0 commit comments