- Added new routes and API endpoints for the Dashboard-Lab layout in the app. - Updated main.py to include the app_dashboard router for backend integration. - Enhanced App.jsx to include a route for the DashboardLabPage. - Modified SettingsPage to add a link to the new Dashboard-Lab layout, improving user access to dashboard features. - Updated version.py to reflect the new app_dashboard module version.
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
import pytest
|
|
|
|
from dashboard_layout_schema import (
|
|
ALLOWED_WIDGET_IDS,
|
|
DashboardLayoutPayload,
|
|
coalesce_effective_layout,
|
|
default_layout_dict,
|
|
)
|
|
|
|
|
|
def test_default_has_all_allowed_ids():
|
|
d = default_layout_dict()
|
|
got = {w["id"] for w in d["widgets"]}
|
|
assert got == ALLOWED_WIDGET_IDS
|
|
|
|
|
|
def test_payload_rejects_duplicate_ids():
|
|
with pytest.raises(Exception):
|
|
DashboardLayoutPayload.model_validate(
|
|
{
|
|
"version": 1,
|
|
"widgets": [
|
|
{"id": "welcome", "enabled": True},
|
|
{"id": "welcome", "enabled": False},
|
|
],
|
|
}
|
|
)
|
|
|
|
|
|
def test_payload_requires_one_enabled():
|
|
with pytest.raises(Exception):
|
|
DashboardLayoutPayload.model_validate(
|
|
{
|
|
"version": 1,
|
|
"widgets": [{"id": "welcome", "enabled": False}],
|
|
}
|
|
)
|
|
|
|
|
|
def test_coalesce_none():
|
|
custom, eff = coalesce_effective_layout(None)
|
|
assert custom is False
|
|
assert eff == default_layout_dict()
|
|
|
|
|
|
def test_coalesce_valid_raw():
|
|
raw = {
|
|
"version": 1,
|
|
"widgets": [
|
|
{"id": "welcome", "enabled": True},
|
|
{"id": "kpi_board", "enabled": True},
|
|
],
|
|
}
|
|
custom, eff = coalesce_effective_layout(raw)
|
|
assert custom is True
|
|
assert eff == raw
|