feat(v4.3.0): Database Views — 10 types complets
- New view types: chart (Chart.js CDN), form (HTML form POST), map (Leaflet OSM), feed (chronological), gantt (timeline + groups) - View tabs updated to show all 11 view types (table, board, calendar, gallery, list, timeline, gantt, chart, form, map, feed) - Chart supports bar/line/pie/doughnut/scatter via config.chart_type - Form auto-generates fields from collection properties (text/email/select/checkbox/date/number) - Map renders location markers from property values (lat,lng pairs) - Gantt supports group_by for categorized timeline bars - 7 new tests (166 total)
This commit is contained in:
@@ -2375,3 +2375,80 @@ def test_dashboard_create_default_layout(client):
|
||||
layout = json.loads(dash["layout_json"])
|
||||
assert layout["columns"] == 1
|
||||
assert layout["widgets"] == []
|
||||
|
||||
|
||||
# ── v4.3.0: Database Views (10 types) ──
|
||||
|
||||
|
||||
def test_view_chart_renders(client):
|
||||
"""Chart view renders with Chart.js CDN."""
|
||||
resp = client.post("/db/api", json={"name": "Chart DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
client.post(f"/db/{coll_id}/pages/api", json={"title": "Item A", "properties": {"Count": "5"}})
|
||||
client.post(f"/db/{coll_id}/pages/api", json={"title": "Item B", "properties": {"Count": "8"}})
|
||||
resp = client.get(f"/db/{coll_id}/view/chart")
|
||||
assert resp.status_code == 200
|
||||
assert "chart.js" in resp.text
|
||||
|
||||
|
||||
def test_view_form_renders(client):
|
||||
"""Form view renders with input fields."""
|
||||
resp = client.post("/db/api", json={"name": "Form DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
client.post(f"/db/{coll_id}/properties/api", json={"name": "Email", "prop_type": "email"})
|
||||
resp = client.get(f"/db/{coll_id}/view/form")
|
||||
assert resp.status_code == 200
|
||||
assert "<form" in resp.text
|
||||
assert "Email" in resp.text
|
||||
|
||||
|
||||
def test_view_map_renders(client):
|
||||
"""Map view renders with Leaflet CDN."""
|
||||
resp = client.post("/db/api", json={"name": "Map DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
resp = client.get(f"/db/{coll_id}/view/map")
|
||||
assert resp.status_code == 200
|
||||
assert "leaflet" in resp.text.lower()
|
||||
|
||||
|
||||
def test_view_feed_renders(client):
|
||||
"""Feed view renders chronological entries."""
|
||||
resp = client.post("/db/api", json={"name": "Feed DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
client.post(f"/db/{coll_id}/pages/api", json={"title": "Latest post"})
|
||||
resp = client.get(f"/db/{coll_id}/view/feed")
|
||||
assert resp.status_code == 200
|
||||
assert "Latest post" in resp.text
|
||||
|
||||
|
||||
def test_view_gantt_renders(client):
|
||||
"""Gantt view renders with date bars."""
|
||||
resp = client.post("/db/api", json={"name": "Gantt DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
client.post(f"/db/{coll_id}/pages/api", json={
|
||||
"title": "Task 1",
|
||||
"properties": {"Timeline": "2026-07-01...2026-07-15"},
|
||||
})
|
||||
resp = client.get(f"/db/{coll_id}/view/gantt")
|
||||
assert resp.status_code == 200
|
||||
assert "Task 1" in resp.text
|
||||
assert "gantt-bar" in resp.text
|
||||
|
||||
|
||||
def test_all_view_tabs_present(client):
|
||||
"""All 11 view tabs are present in the base HTML."""
|
||||
resp = client.post("/db/api", json={"name": "Tabs DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
resp = client.get(f"/db/{coll_id}/view/table")
|
||||
assert resp.status_code == 200
|
||||
for vt in ["table", "board", "calendar", "gallery", "list", "timeline", "gantt", "chart", "form", "map", "feed"]:
|
||||
assert f"?view={vt}" in resp.text, f"Missing view tab: {vt}"
|
||||
|
||||
|
||||
def test_view_unknown_falls_back_to_table(client):
|
||||
"""Unknown view type falls back to table view."""
|
||||
resp = client.post("/db/api", json={"name": "Fallback DB"})
|
||||
coll_id = resp.json()["id"]
|
||||
resp = client.get(f"/db/{coll_id}/view/unknown_view_type")
|
||||
assert resp.status_code == 200
|
||||
assert "<table>" in resp.text
|
||||
Reference in New Issue
Block a user