@@ -21,6 +21,8 @@ import * as apiClient from "../../../src/lib/api-client.js";
2121// biome-ignore lint/performance/noNamespaceImport: needed for spyOn mocking
2222import * as browser from "../../../src/lib/browser.js" ;
2323// biome-ignore lint/performance/noNamespaceImport: needed for spyOn mocking
24+ import * as polling from "../../../src/lib/polling.js" ;
25+ // biome-ignore lint/performance/noNamespaceImport: needed for spyOn mocking
2426import * as resolveTarget from "../../../src/lib/resolve-target.js" ;
2527import type { DashboardListItem } from "../../../src/types/dashboard.js" ;
2628
@@ -71,19 +73,28 @@ describe("dashboard list command", () => {
7173 let listDashboardsSpy : ReturnType < typeof spyOn > ;
7274 let resolveOrgSpy : ReturnType < typeof spyOn > ;
7375 let openInBrowserSpy : ReturnType < typeof spyOn > ;
76+ let withProgressSpy : ReturnType < typeof spyOn > ;
7477
7578 beforeEach ( ( ) => {
7679 listDashboardsSpy = spyOn ( apiClient , "listDashboards" ) ;
7780 resolveOrgSpy = spyOn ( resolveTarget , "resolveOrg" ) ;
7881 openInBrowserSpy = spyOn ( browser , "openInBrowser" ) . mockResolvedValue (
7982 undefined as never
8083 ) ;
84+ // Bypass spinner — just run the callback directly
85+ withProgressSpy = spyOn ( polling , "withProgress" ) . mockImplementation (
86+ ( _opts , fn ) =>
87+ fn ( ( ) => {
88+ /* no-op setMessage */
89+ } )
90+ ) ;
8191 } ) ;
8292
8393 afterEach ( ( ) => {
8494 listDashboardsSpy . mockRestore ( ) ;
8595 resolveOrgSpy . mockRestore ( ) ;
8696 openInBrowserSpy . mockRestore ( ) ;
97+ withProgressSpy . mockRestore ( ) ;
8798 } ) ;
8899
89100 test ( "outputs JSON array of dashboards with --json" , async ( ) => {
@@ -94,7 +105,7 @@ describe("dashboard list command", () => {
94105 const func = await listCommand . loader ( ) ;
95106 await func . call (
96107 context ,
97- { json : true , web : false , fresh : false } ,
108+ { json : true , web : false , fresh : false , limit : 30 } ,
98109 undefined
99110 ) ;
100111
@@ -115,7 +126,7 @@ describe("dashboard list command", () => {
115126 const func = await listCommand . loader ( ) ;
116127 await func . call (
117128 context ,
118- { json : true , web : false , fresh : false } ,
129+ { json : true , web : false , fresh : false , limit : 30 } ,
119130 undefined
120131 ) ;
121132
@@ -131,7 +142,7 @@ describe("dashboard list command", () => {
131142 const func = await listCommand . loader ( ) ;
132143 await func . call (
133144 context ,
134- { json : false , web : false , fresh : false } ,
145+ { json : false , web : false , fresh : false , limit : 30 } ,
135146 undefined
136147 ) ;
137148
@@ -151,7 +162,7 @@ describe("dashboard list command", () => {
151162 const func = await listCommand . loader ( ) ;
152163 await func . call (
153164 context ,
154- { json : false , web : false , fresh : false } ,
165+ { json : false , web : false , fresh : false , limit : 30 } ,
155166 undefined
156167 ) ;
157168
@@ -167,7 +178,7 @@ describe("dashboard list command", () => {
167178 const func = await listCommand . loader ( ) ;
168179 await func . call (
169180 context ,
170- { json : false , web : false , fresh : false } ,
181+ { json : false , web : false , fresh : false , limit : 30 } ,
171182 undefined
172183 ) ;
173184
@@ -184,11 +195,11 @@ describe("dashboard list command", () => {
184195 const func = await listCommand . loader ( ) ;
185196 await func . call (
186197 context ,
187- { json : true , web : false , fresh : false } ,
198+ { json : true , web : false , fresh : false , limit : 30 } ,
188199 "my-org/"
189200 ) ;
190201
191- expect ( listDashboardsSpy ) . toHaveBeenCalledWith ( "my-org" ) ;
202+ expect ( listDashboardsSpy ) . toHaveBeenCalledWith ( "my-org" , { perPage : 30 } ) ;
192203 } ) ;
193204
194205 test ( "throws ContextError when org cannot be resolved" , async ( ) => {
@@ -198,7 +209,11 @@ describe("dashboard list command", () => {
198209 const func = await listCommand . loader ( ) ;
199210
200211 await expect (
201- func . call ( context , { json : false , web : false , fresh : false } , undefined )
212+ func . call (
213+ context ,
214+ { json : false , web : false , fresh : false , limit : 30 } ,
215+ undefined
216+ )
202217 ) . rejects . toThrow ( "Organization" ) ;
203218 } ) ;
204219
@@ -209,11 +224,29 @@ describe("dashboard list command", () => {
209224 const func = await listCommand . loader ( ) ;
210225 await func . call (
211226 context ,
212- { json : false , web : true , fresh : false } ,
227+ { json : false , web : true , fresh : false , limit : 30 } ,
213228 undefined
214229 ) ;
215230
216231 expect ( openInBrowserSpy ) . toHaveBeenCalled ( ) ;
217232 expect ( listDashboardsSpy ) . not . toHaveBeenCalled ( ) ;
218233 } ) ;
234+
235+ test ( "passes limit to API via withProgress" , async ( ) => {
236+ resolveOrgSpy . mockResolvedValue ( { org : "test-org" } ) ;
237+ listDashboardsSpy . mockResolvedValue ( [ DASHBOARD_A ] ) ;
238+
239+ const { context } = createMockContext ( ) ;
240+ const func = await listCommand . loader ( ) ;
241+ await func . call (
242+ context ,
243+ { json : true , web : false , fresh : false , limit : 10 } ,
244+ undefined
245+ ) ;
246+
247+ expect ( withProgressSpy ) . toHaveBeenCalled ( ) ;
248+ expect ( listDashboardsSpy ) . toHaveBeenCalledWith ( "test-org" , {
249+ perPage : 10 ,
250+ } ) ;
251+ } ) ;
219252} ) ;
0 commit comments