@@ -617,54 +617,3 @@ it("removes deleted permission definition from team creator default permissions"
617617 ` ) ;
618618} ) ;
619619
620- it ( "paginates and filters team permission definitions via limit, cursor, and query" , async ( { expect } ) => {
621- backendContext . set ( { projectKeys : InternalProjectKeys } ) ;
622- const { adminAccessToken } = await Project . createAndGetAdminToken ( ) ;
623-
624- // Page 1 with limit=3 should return the first 3 items + a cursor
625- const page1 = await niceBackendFetch ( `/api/v1/team-permission-definitions?limit=3` , {
626- accessType : "admin" ,
627- method : "GET" ,
628- headers : { 'x-stack-admin-access-token' : adminAccessToken } ,
629- } ) ;
630- expect ( page1 . status ) . toBe ( 200 ) ;
631- expect ( page1 . body . is_paginated ) . toBe ( true ) ;
632- expect ( page1 . body . items . length ) . toBe ( 3 ) ;
633- expect ( page1 . body . pagination . next_cursor ) . not . toBeNull ( ) ;
634-
635- // Page 2 using the cursor should return the next slice; combined results must be distinct
636- const cursor = page1 . body . pagination . next_cursor ;
637- const page2 = await niceBackendFetch ( `/api/v1/team-permission-definitions?limit=3&cursor=${ encodeURIComponent ( cursor ) } ` , {
638- accessType : "admin" ,
639- method : "GET" ,
640- headers : { 'x-stack-admin-access-token' : adminAccessToken } ,
641- } ) ;
642- expect ( page2 . status ) . toBe ( 200 ) ;
643- expect ( page2 . body . is_paginated ) . toBe ( true ) ;
644- expect ( page2 . body . items . length ) . toBeGreaterThan ( 0 ) ;
645- const page1Ids = new Set ( page1 . body . items . map ( ( p : any ) => p . id ) ) ;
646- for ( const item of page2 . body . items ) {
647- expect ( page1Ids . has ( item . id ) ) . toBe ( false ) ;
648- }
649-
650- // `query` performs case-insensitive free-text matching on id and description
651- const queryResp = await niceBackendFetch ( `/api/v1/team-permission-definitions?query=ADMIN` , {
652- accessType : "admin" ,
653- method : "GET" ,
654- headers : { 'x-stack-admin-access-token' : adminAccessToken } ,
655- } ) ;
656- expect ( queryResp . status ) . toBe ( 200 ) ;
657- expect ( queryResp . body . items . length ) . toBeGreaterThan ( 0 ) ;
658- for ( const item of queryResp . body . items ) {
659- const haystack = `${ item . id } ${ item . description ?? "" } ` . toLowerCase ( ) ;
660- expect ( haystack . includes ( "admin" ) ) . toBe ( true ) ;
661- }
662-
663- // `cursor` requires `limit`
664- const badCursor = await niceBackendFetch ( `/api/v1/team-permission-definitions?cursor=team_admin` , {
665- accessType : "admin" ,
666- method : "GET" ,
667- headers : { 'x-stack-admin-access-token' : adminAccessToken } ,
668- } ) ;
669- expect ( badCursor . status ) . toBe ( 400 ) ;
670- } ) ;
0 commit comments