mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-31 07:12:23 -07:00
New Features: - API endpoints now support comprehensive input validation with detailed error responses via Pydantic models. - OpenAPI specification endpoint (/openapi.json) and interactive Swagger UI documentation (/docs) now available for API discovery. - Enhanced MCP session lifecycle management with create, retrieve, and delete operations. - Network diagnostic tools: traceroute, nslookup, NMAP scanning, and network topology viewing exposed via API. - Device search, filtering by status (including 'offline'), and bulk operations (copy, delete, update). - Wake-on-LAN functionality for remote device management. - Added dynamic tool disablement and status reporting. Bug Fixes: - Fixed get_tools_status in registry to correctly return boolean values instead of None for enabled tools. - Improved error handling for invalid API inputs with standardized validation responses. - Fixed OPTIONS request handling for cross-origin requests. Refactoring: - Significant refactoring of api_server_start.py to use decorator-based validation (@validate_request).
UI Testing Setup
Selenium Tests
The UI test suite uses Selenium with Chrome/Chromium for browser automation and comprehensive testing.
First Time Setup (Devcontainer)
The devcontainer includes Chromium and chromedriver. If you need to reinstall:
# Install Chromium and chromedriver
apk add --no-cache chromium chromium-chromedriver nss freetype harfbuzz ca-certificates ttf-freefont font-noto
# Install Selenium
pip install selenium
Running Tests
# Run all UI tests
pytest test/ui/
# Run specific test file
pytest test/ui/test_ui_dashboard.py
# Run specific test
pytest test/ui/test_ui_dashboard.py::test_dashboard_loads
# Run with verbose output
pytest test/ui/ -v
# Run and stop on first failure
pytest test/ui/ -x
What Gets Tested
- ✅ API Backend endpoints - All Flask API endpoints work correctly
- ✅ Page loads - All pages load without fatal errors (Dashboard, Devices, Network, Settings, etc.)
- ✅ Dashboard metrics - Charts and device counts display
- ✅ Device operations - Add, edit, delete devices via UI
- ✅ Network topology - Device relationship visualization
- ✅ Multi-edit bulk operations - Bulk device editing
- ✅ Maintenance tools - CSV export/import, database cleanup
- ✅ Settings configuration - Settings page loads and saves
- ✅ Notification system - User notifications display
- ✅ JavaScript error detection - No console errors on page loads
Test Organization
Tests are organized by page/feature:
test_ui_dashboard.py- Dashboard metrics and chartstest_ui_devices.py- Device listing and CRUD operationstest_ui_network.py- Network topology visualizationtest_ui_maintenance.py- Database tools and CSV operationstest_ui_multi_edit.py- Bulk device editingtest_ui_settings.py- Settings configurationtest_ui_notifications.py- Notification systemtest_ui_plugins.py- Plugin management
Troubleshooting
"Could not start Chromium"
- Ensure Chromium is installed:
which chromium - Check chromedriver:
which chromedriver - Verify versions match:
chromium --versionandchromedriver --version
"API token not available"
- Check
/data/config/app.confexists and containsAPI_TOKEN= - Restart backend services if needed
Tests skip with "Chromium browser not available"
- Chromium not installed or not in PATH
- Run:
apk add chromium chromium-chromedriver
Writing New Tests
See TESTING_GUIDE.md for comprehensive examples of:
- Button click testing
- Form submission
- AJAX request verification
- File download testing
- Multi-step workflows
Browser launch fails
- Alpine Linux uses system Chromium
- Make sure chromium package is installed:
apk info chromium
Tests timeout
- Increase timeout in test functions
- Check if backend is running:
ps aux | grep python3 - Verify frontend is accessible:
curl http://localhost:20211