Skip to content

Commit

Permalink
Refactor dialog test to reduce noise
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ankur22 and inancgumus committed Nov 30, 2022
1 parent df85e63 commit 40b4a87
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions tests/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,15 @@ func TestFramePress(t *testing.T) {
func TestFrameDismissDialogBox(t *testing.T) {
t.Parallel()

tests := []struct {
name string
}{
{
name: "alert",
},
{
name: "confirm",
},
{
name: "prompt",
},
{
name: "beforeunload",
},
tests := []string{
"alert",
"confirm",
"prompt",
"beforeunload",
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, test := range tests {
t.Run(test, func(t *testing.T) {
t.Parallel()

b := newTestBrowser(t, withFileServer())
Expand All @@ -59,21 +49,21 @@ func TestFrameDismissDialogBox(t *testing.T) {
WaitUntil: "networkidle",
})
pageGoto := p.Goto(
b.staticURL("dialog.html?dialogType="+tt.name),
b.staticURL("dialog.html?dialogType="+test),
opts,
)
b.promise(pageGoto).then(func() *goja.Promise {
if tt.name == "beforeunload" {
if test == "beforeunload" {
return p.Click("#clickHere", nil)
}

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

return nil
}).then(func() {
result := p.TextContent("#textField", nil)
assert.EqualValues(t, tt.name+" dismissed", result)
assert.EqualValues(t, test+" dismissed", result)
})

return nil
Expand Down

0 comments on commit 40b4a87

Please sign in to comment.