Refactor drag handling and update tests

- Renamed `initiate_drag` to `handle_drag` in MainWindow and updated related tests.
- Improved drag handling logic to utilize a bridge for starting file drags.
- Updated `_on_drag_started` and `_on_drag_failed` methods to match new signatures.
- Modified test cases to reflect changes in drag handling and assertions.

Enhance path validation and logging

- Updated `PathValidator` to log warnings for nonexistent roots instead of raising errors.
- Adjusted tests to verify the new behavior of skipping nonexistent roots.

Update web application UI and functionality

- Changed displayed text for drag items to reflect local paths and Azure Blob Storage URLs.
- Added debug logging for drag operations in the web application.
- Improved instructions for testing drag and drop functionality.

Add configuration documentation and example files

- Created `CONFIG_README.md` to provide detailed configuration instructions for WebDrop Bridge.
- Added `config.example.json` and `config_test.json` for reference and testing purposes.

Implement URL conversion logic

- Introduced `URLConverter` class to handle conversion of Azure Blob Storage URLs to local paths.
- Added unit tests for URL conversion to ensure correct functionality.

Develop download interceptor script

- Created `download_interceptor.js` to intercept download-related actions in the web application.
- Implemented logging for fetch calls, XMLHttpRequests, and Blob URL creations.

Add download test page and related tests

- Created `test_download.html` for testing various download scenarios.
- Implemented `test_download.py` to verify download path resolution and file construction.
- Added `test_url_mappings.py` to ensure URL mappings are loaded correctly.

Add unit tests for URL converter

- Created `test_url_converter.py` to validate URL conversion logic and mapping behavior.
This commit is contained in:
claudi 2026-02-17 15:56:53 +01:00
parent c9704efc8d
commit 88dc358894
21 changed files with 1870 additions and 432 deletions

View file

@ -231,10 +231,12 @@ class TestMainWindowDragIntegration:
assert window.drag_interceptor.drag_started is not None
assert window.drag_interceptor.drag_failed is not None
def test_initiate_drag_delegates_to_interceptor(
def test_handle_drag_delegates_to_interceptor(
self, qtbot, sample_config, tmp_path
):
"""Test initiate_drag method delegates to interceptor."""
"""Test drag handling delegates to interceptor."""
from PySide6.QtCore import QCoreApplication
window = MainWindow(sample_config)
qtbot.addWidget(window)
@ -243,29 +245,32 @@ class TestMainWindowDragIntegration:
test_file.write_text("test")
with patch.object(
window.drag_interceptor, "initiate_drag"
window.drag_interceptor, "handle_drag"
) as mock_drag:
mock_drag.return_value = True
result = window.initiate_drag([str(test_file)])
# Call through bridge
window._drag_bridge.start_file_drag(str(test_file))
# Process deferred QTimer.singleShot(0, ...) call
QCoreApplication.processEvents()
mock_drag.assert_called_once_with([str(test_file)])
assert result is True
mock_drag.assert_called_once_with(str(test_file))
def test_on_drag_started_called(self, qtbot, sample_config):
"""Test _on_drag_started handler can be called."""
window = MainWindow(sample_config)
qtbot.addWidget(window)
# Should not raise
window._on_drag_started(["/some/path"])
# Should not raise - new signature has source and local_path
window._on_drag_started("https://example.com/file.png", "/local/path/file.png")
def test_on_drag_failed_called(self, qtbot, sample_config):
"""Test _on_drag_failed handler can be called."""
window = MainWindow(sample_config)
qtbot.addWidget(window)
# Should not raise
window._on_drag_failed("Test error message")
# Should not raise - new signature has source and error
window._on_drag_failed("https://example.com/file.png", "Test error message")
class TestMainWindowURLWhitelist: