Skip to content

Commit 302d300

Browse files
committed
fix: remove the unreliable Releases panel from the Grafana home dashboard
Fixes #5542
1 parent 2e6c448 commit 302d300

2 files changed

Lines changed: 47 additions & 17 deletions

File tree

grafana/dashboards/internal/home.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{
4848
"gridPos": {
4949
"h": 20,
50-
"w": 16,
50+
"w": 18,
5151
"x": 6,
5252
"y": 0
5353
},
@@ -63,22 +63,6 @@
6363
},
6464
"pluginVersion": "13.0.1+security-01",
6565
"type": "text"
66-
},
67-
{
68-
"gridPos": {
69-
"h": 20,
70-
"w": 2,
71-
"x": 22,
72-
"y": 0
73-
},
74-
"id": 3,
75-
"options": {
76-
"feedUrl": "https://api.cors.lol/?url=https://github.com/teslamate-org/teslamate/tags.atom",
77-
"showImage": false
78-
},
79-
"pluginVersion": "13.0.1+security-01",
80-
"title": "Releases",
81-
"type": "news"
8266
}
8367
],
8468
"preload": false,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
defmodule TeslaMate.Grafana.HomeDashboardTest do
2+
use ExUnit.Case, async: true
3+
4+
@dashboard_path "grafana/dashboards/internal/home.json"
5+
6+
setup_all do
7+
json = File.read!(@dashboard_path)
8+
9+
{:ok, dashboard: Jason.decode!(json), json: json}
10+
end
11+
12+
test "contains only the dashboard list and image panels", %{dashboard: dashboard, json: json} do
13+
assert dashboard["title"] == "Home"
14+
assert Enum.map(dashboard["panels"], & &1["type"]) == ["dashlist", "text"]
15+
assert get_in(dashboard, ["panels", Access.at(1), "options", "content"]) =~ "background-image"
16+
17+
refute Enum.any?(dashboard["panels"], &(&1["type"] == "news"))
18+
refute json =~ "api.cors.lol"
19+
end
20+
21+
test "panels fill the 24-column grid without gaps, overlaps, or overflow", %{
22+
dashboard: dashboard
23+
} do
24+
final_x =
25+
dashboard["panels"]
26+
|> Enum.sort_by(& &1["gridPos"]["x"])
27+
|> Enum.reduce(0, fn %{"gridPos" => %{"w" => width, "x" => x}}, expected_x ->
28+
assert width > 0
29+
assert x == expected_x
30+
assert x + width <= 24
31+
32+
x + width
33+
end)
34+
35+
assert final_x == 24
36+
end
37+
38+
test "Dockerfile provisions the shipped dashboard as Grafana's home dashboard" do
39+
dockerfile = File.read!("grafana/Dockerfile")
40+
41+
assert dockerfile =~
42+
"GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/dashboards_internal/home.json"
43+
44+
assert dockerfile =~ "COPY dashboards/internal/*.json /dashboards_internal/"
45+
end
46+
end

0 commit comments

Comments
 (0)