Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Jul 6, 2024
1 parent 1bc7792 commit dc1fbfc
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestSetExtraHeaders(t *testing.T) {

wg := sync.WaitGroup{}
var header http.Header
s.Mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) {
s.Mux.HandleFunc("/set-header", func(_ http.ResponseWriter, r *http.Request) {
header = r.Header
wg.Done()
})
Expand All @@ -109,23 +109,20 @@ func TestSetExtraHeaders(t *testing.T) {
cleanup := p.MustSetExtraHeaders("a", "1", "b", "2")

wg.Add(1)
p.MustNavigate(s.URL())
p.MustNavigate(s.URL("/set-header"))
wg.Wait()

g.Eq(header.Get("a"), "1")
g.Eq(header.Get("b"), "2")

cleanup()

// TODO: I don't know why it will fail randomly
if false {
wg.Add(1)
p.MustReload()
wg.Wait()
wg.Add(1)
p.MustReload()
wg.Wait()

g.Eq(header.Get("a"), "")
g.Eq(header.Get("b"), "")
}
g.Eq(header.Get("a"), "")
g.Eq(header.Get("b"), "")
}

func TestSetUserAgent(t *testing.T) {
Expand Down Expand Up @@ -892,7 +889,7 @@ func TestFonts(t *testing.T) {
func TestPagePDF(t *testing.T) {
g := setup(t)

p := g.page.MustNavigate(g.srcFile("fixtures/click.html"))
p := g.newPage(g.srcFile("fixtures/click.html"))

s, err := p.PDF(&proto.PagePrintToPDF{})
g.E(err)
Expand Down

0 comments on commit dc1fbfc

Please sign in to comment.