@@ -1324,6 +1324,31 @@ describe('contract-selected list rendering', () => {
13241324} )
13251325
13261326describe ( 'pagination slot' , ( ) => {
1327+ it . each ( [
1328+ { argv : [ 'files' , 'list' ] , cursors : [ 'c1' , 'c1' ] } ,
1329+ { argv : [ 'files' , 'list' ] , cursors : [ 'c1' , 'c2' , 'c1' ] } ,
1330+ { argv : [ 'tables' , 'rows' , 'query' , 'tbl_1' , '--limit' , '0' ] , cursors : [ 'c1' , 'c1' ] } ,
1331+ { argv : [ 'logs' , 'list' , '--cursor' , 'c1' ] , cursors : [ 'c1' ] } ,
1332+ { argv : [ 'tables' , 'rows' , 'query' , 'tbl_1' , '--cursor' , 'c1' ] , cursors : [ 'c1' ] } ,
1333+ ] ) (
1334+ 'rejects cursor cycles in $argv without printing partial results' ,
1335+ async ( { argv, cursors } ) => {
1336+ mockRequest . mockReset ( )
1337+ mockRequest . mockRejectedValue ( new Error ( 'Pagination did not stop at the cycle' ) )
1338+ for ( const nextCursor of cursors ) {
1339+ mockRequest . mockResolvedValueOnce ( { data : [ { id : 'r1' } ] , nextCursor } )
1340+ }
1341+ const printed = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
1342+ printed . mockClear ( )
1343+
1344+ await expect ( program ( ) . parseAsync ( [ 'node' , 'sim' , ...argv ] ) ) . rejects . toThrow (
1345+ 'repeated pagination cursor'
1346+ )
1347+ expect ( mockRequest ) . toHaveBeenCalledTimes ( cursors . length )
1348+ expect ( printed ) . not . toHaveBeenCalled ( )
1349+ }
1350+ )
1351+
13271352 it . each ( [
13281353 [ 'files' , 'list' ] ,
13291354 [ 'tables' , 'list' ] ,
0 commit comments