feat: Enhance dashboard layout and widget configuration
- Updated dashboard layout schema to introduce separate default layouts for product and lab dashboards. - Added new functions for managing product and lab default layouts, improving user customization options. - Updated app_dashboard version to 1.9.0 to reflect the introduction of product vs lab layout defaults and new API fields for dashboard configuration. - Enhanced tests to validate new layout functionalities and ensure proper widget visibility based on user settings.
This commit is contained in:
1 parent
9bc0cf70da
commit
e4e2f23d7f
12 files changed
+592
-417
No files matched your search
@@ -6,12 +6,14 @@ from dashboard_layout_schema import (
|
||||
coalesce_effective_layout,
|
||||
default_layout_dict,
|
||||
)
|
||||
from widget_catalog import DEFAULT_PRODUCT_DASHBOARD_WIDGET_IDS
|
||||
|
||||
|
||||
def test_default_has_all_allowed_ids():
|
||||
d = default_layout_dict()
|
||||
got = {w["id"] for w in d["widgets"]}
|
||||
assert got == ALLOWED_WIDGET_IDS
|
||||
assert {w["id"] for w in d["widgets"] if w["enabled"]} == DEFAULT_PRODUCT_DASHBOARD_WIDGET_IDS
|
||||
|
||||
|
||||
def test_payload_rejects_duplicate_ids():
|
||||
@@ -32,7 +34,7 @@ def test_payload_requires_one_enabled():
|
||||
DashboardLayoutPayload.model_validate(
|
||||
{
|
||||
"version": 1,
|
||||
"widgets": [{"id": "welcome", "enabled": False}],
|
||||
"widgets": [{"id": "dashboard_greeting", "enabled": False}],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
from dashboard_layout_schema import default_layout_dict
|
||||
from dashboard_widget_entitlements import widgets_catalog_payload
|
||||
from widget_catalog import ALLOWED_WIDGET_IDS, DEFAULT_LAB_WIDGET_IDS, WIDGET_CATALOG
|
||||
from widget_catalog import (
|
||||
ALLOWED_WIDGET_IDS,
|
||||
DEFAULT_LAB_WIDGET_IDS,
|
||||
DEFAULT_PRODUCT_DASHBOARD_WIDGET_IDS,
|
||||
WIDGET_CATALOG,
|
||||
)
|
||||
|
||||
|
||||
def test_catalog_ids_unique_and_match_allowed():
|
||||
@@ -17,10 +22,17 @@ def test_default_layout_follows_catalog_order():
|
||||
got = [w["id"] for w in d["widgets"]]
|
||||
assert got == [e["id"] for e in WIDGET_CATALOG]
|
||||
enabled_ids = {w["id"] for w in d["widgets"] if w["enabled"]}
|
||||
assert enabled_ids == DEFAULT_LAB_WIDGET_IDS
|
||||
assert enabled_ids == DEFAULT_PRODUCT_DASHBOARD_WIDGET_IDS
|
||||
assert any(w["enabled"] for w in d["widgets"])
|
||||
|
||||
|
||||
def test_lab_default_matches_lab_widget_ids():
|
||||
from dashboard_layout_schema import lab_default_layout_dict
|
||||
|
||||
d = lab_default_layout_dict()
|
||||
assert {w["id"] for w in d["widgets"] if w["enabled"]} == DEFAULT_LAB_WIDGET_IDS
|
||||
|
||||
|
||||
def test_catalog_payload_shape(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"dashboard_widget_entitlements._check_feature_access",
|
||||
|
||||
Reference in new issue
Block a user