Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions tests/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

"github.com/chromedp/cdproto/runtime"
"github.com/chromedp/chromedp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -22,6 +23,7 @@ const (
chromeDebuggingPort = "9222"
basePort = 7800
namespacePrefix = "tmpbbs-test-"
chromeTimeout = 1 * time.Minute
)

var (
Expand Down Expand Up @@ -84,12 +86,8 @@ var _ = SynchronizedAfterSuite(func() {}, func() {
})

var _ = BeforeEach(func() {
var cancel context.CancelFunc

mainTab, cancel = chromedp.NewContext(browser)
DeferCleanup(cancel)
checkTab, cancel = chromedp.NewContext(browser)
DeferCleanup(cancel)
mainTab = newTab()
checkTab = newTab()
})

func TestIntegration(t *testing.T) {
Expand Down Expand Up @@ -129,6 +127,21 @@ func deployOverlay(name string, port int) string {
return fmt.Sprintf("%s://localhost:%d/", scheme, port)
}

func newTab() context.Context {
tab, tabCancel := chromedp.NewContext(browser)
DeferCleanup(tabCancel)
tab, tabCancelTimeout := context.WithTimeout(tab, chromeTimeout)
DeferCleanup(tabCancelTimeout)

chromedp.ListenTarget(tab, func(ev any) {
if ev, ok := ev.(*runtime.EventExceptionThrown); ok {
GinkgoWriter.Printf("javascript exception: %s\n", ev.ExceptionDetails.Error())
}
})

return tab
}

func post(ctx context.Context, url string, title string, author string, body string) {
Expect(chromedp.Run(ctx,
chromedp.Navigate(url),
Expand Down
Loading