From c7ed58a99ebd0a90360f45d1e502b766aa669712 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Tue, 5 Dec 2023 12:14:39 +0000 Subject: [PATCH] Add test for mouse DblClick This will help ensure that the DblClick behaviour matches the two separate behaviours. --- tests/mouse_test.go | 25 +++++++++++++++++++++++++ tests/static/dbl_click.html | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/mouse_test.go create mode 100644 tests/static/dbl_click.html diff --git a/tests/mouse_test.go b/tests/mouse_test.go new file mode 100644 index 000000000..ad7051e7c --- /dev/null +++ b/tests/mouse_test.go @@ -0,0 +1,25 @@ +package tests + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestMouseDblClick(t *testing.T) { + t.Parallel() + + b := newTestBrowser(t, withFileServer()) + p := b.NewPage(nil) + _, err := p.Goto(b.staticURL("dbl_click.html"), nil) + require.NoError(t, err) + + p.Mouse.DblClick(35, 17, nil) + + v := p.Evaluate(b.toGojaValue(`() => window.dblclick`)) + assert.True(t, b.asGojaBool(v), "failed to double click the link") + + got := p.InnerText("#counter", nil) + assert.Equal(t, "2", got) +} diff --git a/tests/static/dbl_click.html b/tests/static/dbl_click.html new file mode 100644 index 000000000..02d7cf3e1 --- /dev/null +++ b/tests/static/dbl_click.html @@ -0,0 +1,26 @@ + + + + + Clickable link test + + + + Dblclick + Counter: 0 + + + + +