@@ -7,38 +7,46 @@ import { installTestApp, cleanupApps } from '../../data/apps/helper';
77import { updatePermission } from '../../data/permissions.helper' ;
88import { IS_EE } from '../../e2e/config/constants' ;
99
10- ( IS_EE ? describe : describe . skip ) ( 'Apps - Logs Distinct Instances' , ( ) => {
10+ ( IS_EE ? describe : describe . skip ) ( 'Apps - Logs Distinct Values' , ( ) => {
11+ let appId : string ;
12+
1113 before ( ( done ) => getCredentials ( done ) ) ;
1214
1315 before ( async ( ) => {
1416 await cleanupApps ( ) ;
15- await installTestApp ( ) ;
17+ const app = await installTestApp ( ) ;
18+ appId = app . id ;
1619 } ) ;
1720
1821 after ( ( ) => Promise . all ( [ cleanupApps ( ) , updatePermission ( 'manage-apps' , [ 'admin' ] ) ] ) ) ;
1922
20- it ( 'should return distinct instance IDs successfully' , ( done ) => {
23+ it ( 'should return distinct values successfully' , ( done ) => {
2124 void request
22- . get ( apps ( '/ logs/instanceIds' ) )
25+ . get ( apps ( `/ ${ appId } / logs/distinctValues` ) )
2326 . set ( credentials )
2427 . expect ( 200 )
2528 . expect ( 'Content-Type' , 'application/json' )
2629 . expect ( ( res ) => {
2730 expect ( res . body ) . to . have . a . property ( 'success' , true ) ;
2831 expect ( res . body ) . to . have . a . property ( 'instanceIds' ) . that . is . an ( 'array' ) ;
32+ expect ( res . body ) . to . have . a . property ( 'methods' ) . that . is . an ( 'array' ) ;
2933
30- const { instanceIds } = res . body ;
31- const uniqueInstanceIds = [ ...new Set ( instanceIds ) ] ;
34+ const { instanceIds, methods } = res . body ;
35+ const uniqueInstanceIds = new Set ( instanceIds ) ;
36+ const uniqueMethods = new Set ( methods ) ;
3237
3338 // All instance IDs should be unique
34- expect ( instanceIds ) . to . have . lengthOf ( uniqueInstanceIds . length ) ;
39+ expect ( instanceIds ) . to . have . lengthOf ( uniqueInstanceIds . size ) ;
40+
41+ // All methods should be unique
42+ expect ( methods ) . to . have . lengthOf ( uniqueMethods . size ) ;
3543 } )
3644 . end ( done ) ;
3745 } ) ;
3846
3947 it ( 'should require authentication' , ( done ) => {
4048 void request
41- . get ( apps ( '/ logs/instanceIds' ) )
49+ . get ( apps ( `/ ${ appId } / logs/distinctValues` ) )
4250 . expect ( 401 )
4351 . expect ( 'Content-Type' , 'application/json' )
4452 . expect ( ( res ) => {
@@ -52,7 +60,7 @@ import { IS_EE } from '../../e2e/config/constants';
5260 void updatePermission ( 'manage-apps' , [ ] ) . then (
5361 ( ) =>
5462 void request
55- . get ( apps ( '/ logs/instanceIds' ) )
63+ . get ( apps ( `/ ${ appId } / logs/distinctValues` ) )
5664 . set ( credentials )
5765 . expect ( 403 )
5866 . expect ( 'Content-Type' , 'application/json' )
@@ -64,19 +72,36 @@ import { IS_EE } from '../../e2e/config/constants';
6472 ) ;
6573 } ) ;
6674
67- it ( 'should return empty array when no instances exist' , ( done ) => {
68- // Clean up all apps first to ensure no instances
69- void cleanupApps ( ) . then ( ( ) => {
75+ it ( 'should return 404 for non-existent app' , ( done ) => {
76+ void request
77+ . get ( apps ( '/non-existent-app-id/logs/distinctValues' ) )
78+ . set ( credentials )
79+ . expect ( 404 )
80+ . expect ( 'Content-Type' , 'application/json' )
81+ . expect ( ( res ) => {
82+ expect ( res . body ) . to . have . a . property ( 'success' , false ) ;
83+ expect ( res . body ) . to . have . a . property ( 'error' ) ;
84+ } )
85+ . end ( done ) ;
86+ } ) ;
87+
88+ it ( 'should return empty arrays when no logs exist' , ( done ) => {
89+ // Clean up all apps first to ensure no logs
90+ void cleanupApps ( ) . then ( async ( ) => {
91+ // Install a fresh app
92+ const app = await installTestApp ( ) ;
7093 void request
71- . get ( apps ( '/ logs/instanceIds' ) )
94+ . get ( apps ( `/ ${ app . id } / logs/distinctValues` ) )
7295 . set ( credentials )
7396 . expect ( 200 )
7497 . expect ( 'Content-Type' , 'application/json' )
7598 . expect ( ( res ) => {
7699 expect ( res . body ) . to . have . a . property ( 'success' , true ) ;
77100 expect ( res . body ) . to . have . a . property ( 'instanceIds' ) . that . is . an ( 'array' ) ;
78- // Could be empty or have instances from other tests
101+ expect ( res . body ) . to . have . a . property ( 'methods' ) . that . is . an ( 'array' ) ;
102+ // Could be empty or have values from other tests
79103 expect ( res . body . instanceIds ) . to . satisfy ( ( arr : any [ ] ) => Array . isArray ( arr ) ) ;
104+ expect ( res . body . methods ) . to . satisfy ( ( arr : any [ ] ) => Array . isArray ( arr ) ) ;
80105 } )
81106 . end ( done ) ;
82107 } ) ;
0 commit comments