Skip to content

Commit b3a72ba

Browse files
authored
Merge pull request #114 from Concurrent-Systems/fix-search-default-board
Fix search to be cross-board by default
2 parents 79ca273 + c9c2d91 commit b3a72ba

2 files changed

Lines changed: 80 additions & 4 deletions

File tree

internal/commands/search.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ var searchCmd = &cobra.Command{
4242
params = append(params, "terms[]="+term)
4343
}
4444

45-
// Add optional filters
46-
boardID := defaultBoard(searchBoard)
47-
if boardID != "" {
48-
params = append(params, "board_ids[]="+boardID)
45+
// Add optional filters (search is cross-board by default;
46+
// only scope to a board when explicitly requested via --board)
47+
if searchBoard != "" {
48+
params = append(params, "board_ids[]="+searchBoard)
4949
}
5050
if searchTag != "" {
5151
params = append(params, "tag_ids[]="+searchTag)

internal/commands/search_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,82 @@ func TestSearch(t *testing.T) {
122122
}
123123
})
124124

125+
t.Run("does not inject default board into search", func(t *testing.T) {
126+
mock := NewMockClient()
127+
mock.GetWithPaginationResponse = &client.APIResponse{
128+
StatusCode: 200,
129+
Data: []any{},
130+
}
131+
132+
SetTestModeWithSDK(mock)
133+
SetTestConfig("token", "account", "https://api.example.com")
134+
cfg.Board = "default-board-id"
135+
defer resetTest()
136+
137+
err := searchCmd.RunE(searchCmd, []string{"bug"})
138+
139+
assertExitCode(t, err, 0)
140+
if len(mock.GetWithPaginationCalls) != 1 {
141+
t.Fatalf("expected 1 GetWithPagination call, got %d", len(mock.GetWithPaginationCalls))
142+
}
143+
path := mock.GetWithPaginationCalls[0].Path
144+
if path != "/cards.json?terms[]=bug" {
145+
t.Errorf("expected no board_ids in path, got '%s'", path)
146+
}
147+
})
148+
149+
t.Run("tag filter works cross-board with default board set", func(t *testing.T) {
150+
mock := NewMockClient()
151+
mock.GetWithPaginationResponse = &client.APIResponse{
152+
StatusCode: 200,
153+
Data: []any{},
154+
}
155+
156+
SetTestModeWithSDK(mock)
157+
SetTestConfig("token", "account", "https://api.example.com")
158+
cfg.Board = "default-board-id"
159+
defer resetTest()
160+
161+
searchTag = "tag-123"
162+
err := searchCmd.RunE(searchCmd, []string{"bug"})
163+
searchTag = ""
164+
165+
assertExitCode(t, err, 0)
166+
if len(mock.GetWithPaginationCalls) != 1 {
167+
t.Fatalf("expected 1 GetWithPagination call, got %d", len(mock.GetWithPaginationCalls))
168+
}
169+
path := mock.GetWithPaginationCalls[0].Path
170+
if path != "/cards.json?terms[]=bug&tag_ids[]=tag-123" {
171+
t.Errorf("expected tag filter without board_ids, got '%s'", path)
172+
}
173+
})
174+
175+
t.Run("assignee filter works cross-board with default board set", func(t *testing.T) {
176+
mock := NewMockClient()
177+
mock.GetWithPaginationResponse = &client.APIResponse{
178+
StatusCode: 200,
179+
Data: []any{},
180+
}
181+
182+
SetTestModeWithSDK(mock)
183+
SetTestConfig("token", "account", "https://api.example.com")
184+
cfg.Board = "default-board-id"
185+
defer resetTest()
186+
187+
searchAssignee = "user-456"
188+
err := searchCmd.RunE(searchCmd, []string{"bug"})
189+
searchAssignee = ""
190+
191+
assertExitCode(t, err, 0)
192+
if len(mock.GetWithPaginationCalls) != 1 {
193+
t.Fatalf("expected 1 GetWithPagination call, got %d", len(mock.GetWithPaginationCalls))
194+
}
195+
path := mock.GetWithPaginationCalls[0].Path
196+
if path != "/cards.json?terms[]=bug&assignee_ids[]=user-456" {
197+
t.Errorf("expected assignee filter without board_ids, got '%s'", path)
198+
}
199+
})
200+
125201
t.Run("requires authentication", func(t *testing.T) {
126202
mock := NewMockClient()
127203
SetTestModeWithSDK(mock)

0 commit comments

Comments
 (0)