31 lines
819 B
Python
31 lines
819 B
Python
import os
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from cloakbrowser import launch
|
|
|
|
|
|
@patch("cloakbrowser.browser.ensure_binary")
|
|
@patch("playwright.sync_api.sync_playwright")
|
|
def test_extension_loading(mock_sync_playwright, mock_ensure_binary):
|
|
mock_ensure_binary.return_value = "/fake/chrome"
|
|
|
|
mock_browser = MagicMock()
|
|
|
|
mock_pw = MagicMock()
|
|
mock_pw.chromium.launch.return_value = mock_browser
|
|
|
|
mock_sync_playwright.return_value.start.return_value = mock_pw
|
|
|
|
launch(extension_paths=["./ext"])
|
|
|
|
mock_pw.chromium.launch.assert_called_once()
|
|
|
|
launch_call = mock_pw.chromium.launch.call_args
|
|
|
|
args = launch_call.kwargs["args"]
|
|
|
|
abs_path = os.path.abspath("./ext")
|
|
|
|
assert f"--load-extension={abs_path}" in args
|
|
assert f"--disable-extensions-except={abs_path}" in args
|