Changed to pkgsite for docs browsing and then refined the chromedp test some to be nicer to write.

This commit is contained in:
Zed A. Shaw 2025-06-17 02:23:23 -04:00
parent b28e507e5e
commit 849943a01e
8 changed files with 86 additions and 91 deletions

36
tests/chromedp_test.go Normal file
View file

@ -0,0 +1,36 @@
package tests
import (
"testing"
"context"
"time"
"github.com/stretchr/testify/assert"
browser "github.com/chromedp/chromedp"
)
func Run(assert *assert.Assertions, ctx context.Context, actions ...browser.Action) {
err := browser.Run(ctx, actions...)
assert.NoError(err)
}
func Setup(timeout time.Duration) (context.Context, context.CancelFunc) {
ctx, _ := browser.NewContext(context.Background())
return context.WithTimeout(ctx, timeout * time.Second)
}
func TestStreamPage(t *testing.T) {
assert := assert.New(t)
ctx, cancel := Setup(20); defer cancel()
var example string
Run(assert, ctx,
browser.Navigate(`http://127.0.0.1:5002`),
browser.WaitVisible(`body > footer`),
browser.Click(`#streams`, browser.NodeVisible),
browser.Text(`#streams-title`, &example))
assert.Equal(example, "Past Streams")
}