@@ -3,6 +3,7 @@ package sdk_test
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "strings"
6
7
"testing"
7
8
"time"
8
9
@@ -63,6 +64,11 @@ func TestSinglestatPanel(t *testing.T) {
63
64
panel .SinglestatPanel .ValueName = "avg"
64
65
65
66
r .Add (panel )
67
+
68
+ textPanel := sdk .NewText ("text" )
69
+ textPanel .TextPanel .Content = "content"
70
+ textPanel .TextPanel .Mode = "markdown"
71
+ r .Add (textPanel )
66
72
cl := getClient (t )
67
73
68
74
db , err := cl .SetDashboard (context .TODO (), * b , sdk.SetDashboardParams {
@@ -72,6 +78,12 @@ func TestSinglestatPanel(t *testing.T) {
72
78
if err != nil {
73
79
t .Fatalf ("failed setting dashboard: %v" , err )
74
80
}
81
+ t .Cleanup (func () {
82
+ _ , err := cl .DeleteDashboardByUID (context .TODO (), * db .UID )
83
+ if err != nil {
84
+ t .Fatal ("failed cleaning up due to" , err .Error ())
85
+ }
86
+ })
75
87
76
88
durl := getDebugURL (t )
77
89
@@ -106,4 +118,17 @@ func TestSinglestatPanel(t *testing.T) {
106
118
if res == "" {
107
119
t .Fatalf ("expected single-stat panel to have some value" )
108
120
}
121
+
122
+ err = chromedp .Run (ctx ,
123
+ chromedp .Navigate (fullAddr ),
124
+ chromedp .WaitReady (`grafana-app` ),
125
+ chromedp .TextContent (`p.markdown-html` , & res , chromedp .NodeVisible , chromedp .ByQuery ),
126
+ )
127
+ if err != nil {
128
+ t .Fatalf ("running chromedp has failed: %v" , err )
129
+ }
130
+
131
+ if strings .TrimSpace (res ) != `content` {
132
+ t .Fatalf ("expected text panel to have the correct value, got: %s" , res )
133
+ }
109
134
}
0 commit comments