feat: Add branding change prompts and corresponding translations for restart notifications
This commit is contained in:
parent
ca7105a6bc
commit
2ecd299f31
5 changed files with 79 additions and 15 deletions
|
|
@ -9,11 +9,14 @@ from webdrop_bridge.config import Config, ConfigurationError
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clear_env():
|
||||
def clear_env(tmp_path):
|
||||
"""Clear environment variables before each test to avoid persistence."""
|
||||
# Save current env
|
||||
saved_env = os.environ.copy()
|
||||
|
||||
# Isolate runtime branding state from the developer machine
|
||||
os.environ["WEBDROP_BRANDING_DIR"] = str(tmp_path / "branding")
|
||||
|
||||
# Clear relevant variables
|
||||
for key in list(os.environ.keys()):
|
||||
if key.startswith(
|
||||
|
|
|
|||
|
|
@ -82,6 +82,25 @@ class TestMainWindowInitialization:
|
|||
assert window.drag_interceptor is not None
|
||||
|
||||
|
||||
class TestSettingsRestartBehavior:
|
||||
"""Test restart prompts for settings changes that require a restart."""
|
||||
|
||||
def test_branding_change_prompts_restart(self, qtbot, sample_config):
|
||||
"""Changing the active branding should trigger the restart flow."""
|
||||
window = MainWindow(sample_config)
|
||||
qtbot.addWidget(window)
|
||||
|
||||
with patch.object(window, "_handle_branding_change_restart") as mock_restart:
|
||||
with patch("webdrop_bridge.ui.settings_dialog.SettingsDialog") as mock_dialog_cls:
|
||||
mock_dialog = mock_dialog_cls.return_value
|
||||
mock_dialog.exec.side_effect = lambda: setattr(
|
||||
window.config, "active_branding_id", "agravity"
|
||||
)
|
||||
window._show_settings_dialog()
|
||||
|
||||
mock_restart.assert_called_once()
|
||||
|
||||
|
||||
class TestMainWindowDragIntegration:
|
||||
"""Test drag-and-drop integration."""
|
||||
|
||||
|
|
@ -207,15 +226,15 @@ class TestMainWindowOpenWith:
|
|||
test_file.write_text("test")
|
||||
|
||||
call_count = [0] # Use list to make it mutable in nested function
|
||||
|
||||
|
||||
class _AppChooseResult:
|
||||
returncode = 0
|
||||
stdout = "TextEdit" # Simulated chosen app name
|
||||
|
||||
|
||||
class _OpenResult:
|
||||
returncode = 0
|
||||
stdout = ""
|
||||
|
||||
|
||||
def mock_run(*args, **kwargs):
|
||||
"""Mock subprocess.run with two different behaviors per call."""
|
||||
call_count[0] += 1
|
||||
|
|
@ -227,8 +246,7 @@ class TestMainWindowOpenWith:
|
|||
return _OpenResult()
|
||||
else:
|
||||
raise AssertionError(f"Unexpected call #{call_count[0]} to subprocess.run")
|
||||
|
||||
|
||||
|
||||
with patch("webdrop_bridge.ui.main_window.sys.platform", "darwin"):
|
||||
with patch("webdrop_bridge.ui.main_window.subprocess.run", side_effect=mock_run):
|
||||
assert window._open_with_app_chooser(str(test_file)) is True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue