--------------------------------------------------------------------------- Server-side verification helpers --------------------------------------------------------------------------- fetchHTML fetches a page via HTTP using the session cookie and returns the raw HTML body. This is a lightweight alt
(t *testing.T, url string)
| 406 | func browserPageText(t *testing.T, pageURL string) string { |
| 407 | t.Helper() |
| 408 | |
| 409 | ctx, ctxCancel, allocCancel := newBrowserContext() |
| 410 | defer ctxCancel() |
| 411 | defer allocCancel() |
| 412 | |
| 413 | tCtx, cancel := context.WithTimeout(ctx, 30*time.Second) |
| 414 | defer cancel() |
| 415 | |
| 416 | // Set session cookie directly instead of doing a full login flow. |
| 417 | // This avoids loading the heavy post-login homepage which can crash Chrome. |
| 418 | parsed, err := url.Parse(baseURL) |
| 419 | if err != nil { |
| 420 | t.Fatalf("failed to parse baseURL %q: %v", baseURL, err) |
| 421 | } |
| 422 | cookieDomain := parsed.Hostname() |
| 423 | if err := chromedp.Run(tCtx, |
| 424 | network.SetCookie("session_token", sessionCookie). |
| 425 | WithDomain(cookieDomain). |
| 426 | WithPath("/"). |
| 427 | WithHTTPOnly(true), |
| 428 | ); err != nil { |
| 429 | t.Fatalf("failed to set session cookie: %v", err) |
| 430 | } |
| 431 | |
| 432 | var text string |
| 433 | if err := chromedp.Run(tCtx, |
| 434 | chromedp.Navigate(pageURL), |
no outgoing calls
no test coverage detected