From dc1fbfcc0f7f5b291d5b6425c353d53b891f9508 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Sat, 6 Jul 2024 15:36:26 +0800 Subject: [PATCH] fix flaky test --- page_test.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/page_test.go b/page_test.go index 8241a99c..cec9ba5c 100644 --- a/page_test.go +++ b/page_test.go @@ -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() }) @@ -109,7 +109,7 @@ 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") @@ -117,15 +117,12 @@ func TestSetExtraHeaders(t *testing.T) { 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) { @@ -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)