@@ -2672,3 +2672,71 @@ test('activeAppDeployments filters by name combined with lastUsedBefore', async
26722672 expect ( result . target ?. activeAppDeployments . edges ) . toHaveLength ( 1 ) ;
26732673 expect ( result . target ?. activeAppDeployments . edges [ 0 ] ?. node . name ) . toBe ( 'frontend-app' ) ;
26742674} ) ;
2675+
2676+ test ( 'activeAppDeployments check pagination clamp' , async ( ) => {
2677+ const { createOrg, ownerToken } = await initSeed ( ) . createOwner ( ) ;
2678+ const { createProject, setFeatureFlag, organization } = await createOrg ( ) ;
2679+ await setFeatureFlag ( 'appDeployments' , true ) ;
2680+ const { createTargetAccessToken, project, target } = await createProject ( ) ;
2681+ const token = await createTargetAccessToken ( { } ) ;
2682+
2683+ await token . publishSchema ( {
2684+ sdl : /* GraphQL */ `
2685+ type Query {
2686+ hello: String
2687+ }
2688+ ` ,
2689+ } ) ;
2690+
2691+ // Create 25 active app deployments
2692+ for ( let i = 0 ; i < 25 ; i ++ ) {
2693+ const appName = `app-${ i . toString ( ) . padStart ( 2 , '0' ) } ` ;
2694+ await execute ( {
2695+ document : CreateAppDeployment ,
2696+ variables : { input : { appName, appVersion : '1.0.0' } } ,
2697+ authToken : token . secret ,
2698+ } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
2699+
2700+ await execute ( {
2701+ document : AddDocumentsToAppDeployment ,
2702+ variables : {
2703+ input : {
2704+ appName,
2705+ appVersion : '1.0.0' ,
2706+ documents : [ { hash : `hash-${ i } ` , body : 'query { hello }' } ] ,
2707+ } ,
2708+ } ,
2709+ authToken : token . secret ,
2710+ } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
2711+
2712+ await execute ( {
2713+ document : ActivateAppDeployment ,
2714+ variables : { input : { appName, appVersion : '1.0.0' } } ,
2715+ authToken : token . secret ,
2716+ } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
2717+ }
2718+
2719+ const tomorrow = new Date ( ) ;
2720+ tomorrow . setDate ( tomorrow . getDate ( ) + 1 ) ;
2721+
2722+ // Request 100 items, should only get 20 (max limit)
2723+ const result = await execute ( {
2724+ document : GetActiveAppDeployments ,
2725+ variables : {
2726+ targetSelector : {
2727+ organizationSlug : organization . slug ,
2728+ projectSlug : project . slug ,
2729+ targetSlug : target . slug ,
2730+ } ,
2731+ filter : {
2732+ neverUsedAndCreatedBefore : tomorrow . toISOString ( ) ,
2733+ } ,
2734+ first : 100 ,
2735+ } ,
2736+ authToken : ownerToken ,
2737+ } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
2738+
2739+ // Should be clamped to 20
2740+ expect ( result . target ?. activeAppDeployments . edges ) . toHaveLength ( 20 ) ;
2741+ expect ( result . target ?. activeAppDeployments . pageInfo . hasNextPage ) . toBe ( true ) ;
2742+ } ) ;
0 commit comments