MCPcopy Create free account
hub / github.com/diillson/chatcli / TestRenderPageHTML_Integration

Function TestRenderPageHTML_Integration

cli/plugins/webfetch_render_test.go:161–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159</body></html>`
160
161func TestRenderPageHTML_Integration(t *testing.T) {
162 if testing.Short() {
163 t.Skip("short mode")
164 }
165 bin, ok, _ := resolveRenderBrowser()
166 if !ok || bin == "" {
167 t.Skip("no Chromium-based browser available")
168 }
169
170 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
171 w.Header().Set("Content-Type", "text/html")
172 _, _ = w.Write([]byte(jsTablePage))
173 }))
174 defer srv.Close()
175
176 // Sanity: the static path must NOT see the table (that is the gap).
177 staticText := extractText(jsTablePage)
178 if strings.Contains(staticText, "sirius-7") {
179 t.Fatal("test page leaks content statically; it no longer exercises the gap")
180 }
181 if !looksJSRendered(jsTablePage, staticText) {
182 t.Fatal("test page must be detected as a JS shell")
183 }
184
185 html, err := renderPageHTML(t.Context(), srv.URL)
186 if err != nil {
187 t.Fatalf("render: %v", err)
188 }
189 rendered := extractText(html)
190 for _, want := range []string{"sirius-7", "healthy", "vega-3", "degraded"} {
191 if !strings.Contains(rendered, want) {
192 t.Errorf("rendered text missing JS-built cell %q", want)
193 }
194 }
195
196 // Second render reuses the shared browser (no relaunch) — just assert
197 // it still works and the session kept a live instance.
198 if _, err := renderPageHTML(t.Context(), srv.URL); err != nil {
199 t.Fatalf("second render (browser reuse): %v", err)
200 }
201 renderShared.mu.Lock()
202 alive := renderShared.browser != nil
203 renderShared.mu.Unlock()
204 if !alive {
205 t.Error("shared browser must stay alive between renders (idle window)")
206 }
207}
208
209func TestResolvedHostAllowed_FailsClosedOnResolutionError(t *testing.T) {
210 hostVerdicts.mu.Lock()

Callers

nothing calls this directly

Calls 12

resolveRenderBrowserFunction · 0.85
extractTextFunction · 0.85
looksJSRenderedFunction · 0.85
renderPageHTMLFunction · 0.85
ErrorfMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
WriteMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
SetMethod · 0.45
ContextMethod · 0.45

Tested by

no test coverage detected