Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 40b4a87

Browse files
ankur22inancgumus
andcommitted
Refactor dialog test to reduce noise
We don't need the struct yet to define each of the tests in the table test. Instead use a slice of string. Resolves: #663 (comment) Co-authored-by: Inanc Gumus <inanc.gumus@grafana.com>
1 parent df85e63 commit 40b4a87

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

tests/frame_test.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,15 @@ func TestFramePress(t *testing.T) {
2727
func TestFrameDismissDialogBox(t *testing.T) {
2828
t.Parallel()
2929

30-
tests := []struct {
31-
name string
32-
}{
33-
{
34-
name: "alert",
35-
},
36-
{
37-
name: "confirm",
38-
},
39-
{
40-
name: "prompt",
41-
},
42-
{
43-
name: "beforeunload",
44-
},
30+
tests := []string{
31+
"alert",
32+
"confirm",
33+
"prompt",
34+
"beforeunload",
4535
}
4636

47-
for _, tt := range tests {
48-
t.Run(tt.name, func(t *testing.T) {
37+
for _, test := range tests {
38+
t.Run(test, func(t *testing.T) {
4939
t.Parallel()
5040

5141
b := newTestBrowser(t, withFileServer())
@@ -59,21 +49,21 @@ func TestFrameDismissDialogBox(t *testing.T) {
5949
WaitUntil: "networkidle",
6050
})
6151
pageGoto := p.Goto(
62-
b.staticURL("dialog.html?dialogType="+tt.name),
52+
b.staticURL("dialog.html?dialogType="+test),
6353
opts,
6454
)
6555
b.promise(pageGoto).then(func() *goja.Promise {
66-
if tt.name == "beforeunload" {
56+
if test == "beforeunload" {
6757
return p.Click("#clickHere", nil)
6858
}
6959

7060
result := p.TextContent("#textField", nil)
71-
assert.EqualValues(t, tt.name+" dismissed", result)
61+
assert.EqualValues(t, test+" dismissed", result)
7262

7363
return nil
7464
}).then(func() {
7565
result := p.TextContent("#textField", nil)
76-
assert.EqualValues(t, tt.name+" dismissed", result)
66+
assert.EqualValues(t, test+" dismissed", result)
7767
})
7868

7969
return nil

0 commit comments

Comments
 (0)