@@ -78,6 +78,93 @@ func TestRenderingGrafana(t *testing.T) {
7878 UpdateFixtureIfEnabled (t , fixture , body )
7979 }
8080 })
81+
82+ t .Run ("with very low height and width" , func (t * testing.T ) {
83+ t .Parallel ()
84+
85+ req , err := http .NewRequestWithContext (t .Context (), http .MethodGet , svc .HTTPEndpoint + "/render" , nil )
86+ require .NoError (t , err , "could not construct HTTP request to Grafana" )
87+ req .Header .Set ("Accept" , "image/png" )
88+ req .Header .Set ("X-Auth-Token" , "-" )
89+ query := req .URL .Query ()
90+ query .Set ("url" , "http://grafana:3000/d/provisioned-prom-testing?render=1&from=1699333200000&to=1699344000000&kiosk=true" )
91+ query .Set ("encoding" , "png" )
92+ query .Set ("width" , "1" )
93+ query .Set ("height" , "1" )
94+ query .Set ("renderKey" , renderKey )
95+ query .Set ("domain" , "grafana" )
96+ req .URL .RawQuery = query .Encode ()
97+
98+ resp , err := http .DefaultClient .Do (req )
99+ require .NoError (t , err , "could not send HTTP request to Grafana" )
100+ require .Equal (t , http .StatusOK , resp .StatusCode , "unexpected HTTP status code from Grafana" )
101+
102+ body := ReadBody (t , resp .Body )
103+ bodyImg := ReadRGBA (t , body )
104+ const fixture = "render-prometheus-very-low-width-height.png"
105+ fixtureImg := ReadFixtureRGBA (t , fixture )
106+ if ! AssertPixelDifference (t , fixtureImg , bodyImg , 15_000 ) {
107+ UpdateFixtureIfEnabled (t , fixture , body )
108+ }
109+ })
110+
111+ t .Run ("with d-solo link" , func (t * testing.T ) {
112+ t .Parallel ()
113+
114+ req , err := http .NewRequestWithContext (t .Context (), http .MethodGet , svc .HTTPEndpoint + "/render" , nil )
115+ require .NoError (t , err , "could not construct HTTP request to Grafana" )
116+ req .Header .Set ("Accept" , "image/png" )
117+ req .Header .Set ("X-Auth-Token" , "-" )
118+ query := req .URL .Query ()
119+ query .Set ("url" , "http://grafana:3000/d-solo/provisioned-prom-testing?render=1&from=1699333200000&to=1699344000000&kiosk=true&panelId=1" )
120+ query .Set ("encoding" , "png" )
121+ query .Set ("width" , "2000" )
122+ query .Set ("height" , "800" )
123+ query .Set ("renderKey" , renderKey )
124+ query .Set ("domain" , "grafana" )
125+ req .URL .RawQuery = query .Encode ()
126+
127+ resp , err := http .DefaultClient .Do (req )
128+ require .NoError (t , err , "could not send HTTP request to Grafana" )
129+ require .Equal (t , http .StatusOK , resp .StatusCode , "unexpected HTTP status code from Grafana" )
130+
131+ body := ReadBody (t , resp .Body )
132+ bodyImg := ReadRGBA (t , body )
133+ const fixture = "render-prometheus-dsolo.png"
134+ fixtureImg := ReadFixtureRGBA (t , fixture )
135+ if ! AssertPixelDifference (t , fixtureImg , bodyImg , 85_000 ) {
136+ UpdateFixtureIfEnabled (t , fixture , body )
137+ }
138+ })
139+
140+ t .Run ("with d-solo link and very low width and height" , func (t * testing.T ) {
141+ t .Parallel ()
142+
143+ req , err := http .NewRequestWithContext (t .Context (), http .MethodGet , svc .HTTPEndpoint + "/render" , nil )
144+ require .NoError (t , err , "could not construct HTTP request to Grafana" )
145+ req .Header .Set ("Accept" , "image/png" )
146+ req .Header .Set ("X-Auth-Token" , "-" )
147+ query := req .URL .Query ()
148+ query .Set ("url" , "http://grafana:3000/d-solo/provisioned-prom-testing?render=1&from=1699333200000&to=1699344000000&kiosk=true&panelId=1" )
149+ query .Set ("encoding" , "png" )
150+ query .Set ("width" , "1" )
151+ query .Set ("height" , "1" )
152+ query .Set ("renderKey" , renderKey )
153+ query .Set ("domain" , "grafana" )
154+ req .URL .RawQuery = query .Encode ()
155+
156+ resp , err := http .DefaultClient .Do (req )
157+ require .NoError (t , err , "could not send HTTP request to Grafana" )
158+ require .Equal (t , http .StatusOK , resp .StatusCode , "unexpected HTTP status code from Grafana" )
159+
160+ body := ReadBody (t , resp .Body )
161+ bodyImg := ReadRGBA (t , body )
162+ const fixture = "render-prometheus-dsolo-very-low-width-height.png"
163+ fixtureImg := ReadFixtureRGBA (t , fixture )
164+ if ! AssertPixelDifference (t , fixtureImg , bodyImg , 35_000 ) {
165+ UpdateFixtureIfEnabled (t , fixture , body )
166+ }
167+ })
81168 })
82169
83170 t .Run ("render prometheus dashboard as CSV" , func (t * testing.T ) {
0 commit comments