MCPcopy
hub / github.com/TecharoHQ/anubis / TestPlaywrightWithBasePrefix

Function TestPlaywrightWithBasePrefix

internal/test/playwright_test.go:291–419  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

289}
290
291func TestPlaywrightWithBasePrefix(t *testing.T) {
292 if os.Getenv("DONT_USE_NETWORK") != "" {
293 t.Skip("test requires network egress")
294 return
295 }
296
297 if os.Getenv("SKIP_INTEGRATION") != "" {
298 t.Skip("SKIP_INTEGRATION was set")
299 return
300 }
301
302 t.Skip("NOTE(Xe)\\ these tests require HTTPS support in #364")
303
304 startPlaywright(t)
305
306 pw := setupPlaywright(t)
307 basePrefix := "/myapp"
308 anubisURL := spawnAnubisWithOptions(t, basePrefix)
309
310 // Reset BasePrefix after test
311 t.Cleanup(func() {
312 anubis.BasePrefix = ""
313 })
314
315 browsers := []playwright.BrowserType{pw.Chromium}
316
317 for _, typ := range browsers {
318 t.Run(typ.Name()+"/basePrefix", func(t *testing.T) {
319 browser, err := typ.Connect(buildBrowserConnect(typ.Name()), playwright.BrowserTypeConnectOptions{
320 ExposeNetwork: playwright.String("<loopback>"),
321 })
322 if err != nil {
323 t.Fatalf("could not connect to remote browser: %v", err)
324 }
325 defer browser.Close()
326
327 ctx, err := browser.NewContext(playwright.BrowserNewContextOptions{
328 AcceptDownloads: playwright.Bool(false),
329 ExtraHttpHeaders: map[string]string{
330 "X-Real-Ip": "127.0.0.1",
331 },
332 UserAgent: playwright.String("Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0"),
333 })
334 if err != nil {
335 t.Fatalf("could not create context: %v", err)
336 }
337 defer ctx.Close()
338
339 page, err := ctx.NewPage()
340 if err != nil {
341 t.Fatalf("could not create page: %v", err)
342 }
343 defer page.Close()
344
345 // Test accessing the base URL with prefix
346 _, err = page.Goto(anubisURL+basePrefix, playwright.PageGotoOptions{
347 Timeout: pwTimeout(testCases[0], time.Now().Add(5*time.Second)),
348 })

Callers

nothing calls this directly

Calls 10

startPlaywrightFunction · 0.85
setupPlaywrightFunction · 0.85
spawnAnubisWithOptionsFunction · 0.85
buildBrowserConnectFunction · 0.85
pwTimeoutFunction · 0.85
pwFailFunction · 0.85
CleanupMethod · 0.80
CookiesMethod · 0.80
StringMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected