mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-02-05 12:31:34 -05: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).
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Dashboard Page UI Tests
|
|
Tests main dashboard metrics, charts, and device table
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
# Add test directory to path
|
|
sys.path.insert(0, os.path.dirname(__file__))
|
|
|
|
from .test_helpers import BASE_URL, wait_for_page_load, wait_for_element_by_css # noqa: E402
|
|
|
|
|
|
def test_dashboard_loads(driver):
|
|
"""Test: Dashboard/index page loads successfully"""
|
|
driver.get(f"{BASE_URL}/index.php")
|
|
wait_for_page_load(driver, timeout=10)
|
|
assert driver.title, "Page should have a title"
|
|
|
|
|
|
def test_metric_tiles_present(driver):
|
|
"""Test: Dashboard metric tiles are rendered"""
|
|
driver.get(f"{BASE_URL}/index.php")
|
|
wait_for_page_load(driver, timeout=10)
|
|
# Wait for at least one metric/tile/info-box to be present
|
|
wait_for_element_by_css(driver, ".metric, .tile, .info-box, .small-box", timeout=10)
|
|
tiles = driver.find_elements(By.CSS_SELECTOR, ".metric, .tile, .info-box, .small-box")
|
|
assert len(tiles) > 0, "Dashboard should have metric tiles"
|
|
|
|
|
|
def test_device_table_present(driver):
|
|
"""Test: Dashboard device table is rendered"""
|
|
driver.get(f"{BASE_URL}/index.php")
|
|
wait_for_page_load(driver, timeout=10)
|
|
wait_for_element_by_css(driver, "table", timeout=10)
|
|
table = driver.find_elements(By.CSS_SELECTOR, "table")
|
|
assert len(table) > 0, "Dashboard should have a device table"
|
|
|
|
|
|
def test_charts_present(driver):
|
|
"""Test: Dashboard charts are rendered"""
|
|
driver.get(f"{BASE_URL}/index.php")
|
|
wait_for_page_load(driver, timeout=15) # Charts may take longer to load
|
|
wait_for_element_by_css(driver, "canvas, .chart, svg", timeout=15)
|
|
charts = driver.find_elements(By.CSS_SELECTOR, "canvas, .chart, svg")
|
|
assert len(charts) > 0, "Dashboard should have charts"
|