-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desobekify BrowserContextOptionParsing
Moves the Sobek-dependent option parsing part out of the business logic. Once we finish, we can entirely remove the Sobek dependency.
- Loading branch information
1 parent
2303d9c
commit 946e4cb
Showing
6 changed files
with
145 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package browser | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/grafana/xk6-browser/common" | ||
"github.com/grafana/xk6-browser/k6ext/k6test" | ||
) | ||
|
||
func TestBrowserContextOptionsPermissions(t *testing.T) { | ||
vu := k6test.NewVU(t) | ||
|
||
opts, err := parseBrowserContextOptions(vu.Context(), vu.ToSobekValue((struct { | ||
Permissions []any `js:"permissions"` | ||
}{ | ||
Permissions: []any{"camera", "microphone"}, | ||
}))) | ||
assert.NoError(t, err) | ||
assert.Len(t, opts.Permissions, 2) | ||
assert.Equal(t, opts.Permissions, []string{"camera", "microphone"}) | ||
} | ||
|
||
func TestBrowserContextSetGeolocation(t *testing.T) { | ||
vu := k6test.NewVU(t) | ||
|
||
opts, err := parseBrowserContextOptions(vu.Context(), vu.ToSobekValue((struct { | ||
GeoLocation *common.Geolocation `js:"geolocation"` | ||
}{ | ||
GeoLocation: &common.Geolocation{ | ||
Latitude: 1.0, | ||
Longitude: 2.0, | ||
Accuracy: 3.0, | ||
}, | ||
}))) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, opts) | ||
assert.Equal(t, 1.0, opts.Geolocation.Latitude) | ||
assert.Equal(t, 2.0, opts.Geolocation.Longitude) | ||
assert.Equal(t, 3.0, opts.Geolocation.Accuracy) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters