Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/browsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type BrowsersListInput struct {
Status string
Limit int
Offset int
Query string
}

func (b BrowsersCmd) List(ctx context.Context, in BrowsersListInput) error {
Expand Down Expand Up @@ -257,6 +258,9 @@ func (b BrowsersCmd) List(ctx context.Context, in BrowsersListInput) error {
if in.Offset > 0 {
params.Offset = kernel.Opt(int64(in.Offset))
}
if in.Query != "" {
params.Query = kernel.Opt(in.Query)
}

page, err := b.browsers.List(ctx, params)
if err != nil {
Expand Down Expand Up @@ -2139,6 +2143,7 @@ func init() {
browsersListCmd.Flags().String("status", "", "Filter by status: 'active' (default), 'deleted', or 'all'")
browsersListCmd.Flags().Int("limit", 0, "Maximum number of results to return (default 20, max 100)")
browsersListCmd.Flags().Int("offset", 0, "Number of results to skip (for pagination)")
browsersListCmd.Flags().String("query", "", "Search browsers by session ID, profile ID, or proxy ID")

// get flags
browsersGetCmd.Flags().StringP("output", "o", "", "Output format: json for raw API response")
Expand Down Expand Up @@ -2418,12 +2423,14 @@ func runBrowsersList(cmd *cobra.Command, args []string) error {
status, _ := cmd.Flags().GetString("status")
limit, _ := cmd.Flags().GetInt("limit")
offset, _ := cmd.Flags().GetInt("offset")
query, _ := cmd.Flags().GetString("query")
return b.List(cmd.Context(), BrowsersListInput{
Output: out,
IncludeDeleted: includeDeleted,
Status: status,
Limit: limit,
Offset: offset,
Query: query,
})
}

Expand Down
20 changes: 20 additions & 0 deletions cmd/browsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@ func TestBrowsersList_PrintsErrorOnFailure(t *testing.T) {
assert.Contains(t, err.Error(), "list failed")
}

func TestBrowsersList_WithQuery_PassesParam(t *testing.T) {
setupStdoutCapture(t)

var captured kernel.BrowserListParams
fake := &FakeBrowsersService{
ListFunc: func(ctx context.Context, query kernel.BrowserListParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.BrowserListResponse], error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the other list tests in this file name this parameter params — worth matching for consistency

captured = query
return &pagination.OffsetPagination[kernel.BrowserListResponse]{Items: []kernel.BrowserListResponse{
{SessionID: "sess-matched"},
}}, nil
},
}
b := BrowsersCmd{browsers: fake}
err := b.List(context.Background(), BrowsersListInput{Query: "sess-matched"})

assert.NoError(t, err)
assert.True(t, captured.Query.Valid())
assert.Equal(t, "sess-matched", captured.Query.Value)
}

func TestBrowsersCreate_PrintsResponse(t *testing.T) {
setupStdoutCapture(t)

Expand Down