11import { mockDashboardConfig , mockDscStatus } from '@odh-dashboard/internal/__mocks__' ;
22import { DataScienceStackComponent } from '@odh-dashboard/internal/concepts/areas/types' ;
33import type { APIKey } from '@odh-dashboard/maas/types/api-key' ;
4- import { asProductAdminUser } from '../../../utils/mockUsers' ;
4+ import { asClusterAdminUser , asProjectAdminUser } from '../../../utils/mockUsers' ;
55import {
66 apiKeysPage ,
77 bulkRevokeAPIKeyModal ,
@@ -22,7 +22,7 @@ const mockSearchResponse = (keys: APIKey[]) => ({
2222
2323describe ( 'API Keys Page' , ( ) => {
2424 beforeEach ( ( ) => {
25- asProductAdminUser ( ) ;
25+ asClusterAdminUser ( ) ;
2626 cy . interceptOdh (
2727 'GET /api/config' ,
2828 mockDashboardConfig ( {
@@ -33,6 +33,7 @@ describe('API Keys Page', () => {
3333 cy . interceptOdh ( 'GET /maas/api/v1/user' , {
3434 data : { userId : 'test-user' , clusterAdmin : false } ,
3535 } ) ;
36+ cy . interceptOdh ( 'GET /maas/api/v1/is-maas-admin' , { data : { allowed : true } } ) ;
3637 cy . interceptOdh ( 'GET /maas/api/v1/namespaces' , { data : [ ] } ) ;
3738
3839 cy . interceptOdh (
@@ -92,6 +93,13 @@ describe('API Keys Page', () => {
9293 . should ( 'contain.text' , 'production-backend' ) ;
9394 } ) ;
9495
96+ it ( 'should not display the username filter for non-MaaS admins' , ( ) => {
97+ asProjectAdminUser ( ) ;
98+ apiKeysPage . visit ( ) ;
99+ apiKeysPage . findFilterInput ( ) . should ( 'not.exist' ) ;
100+ apiKeysPage . findUsernameFilterTooltip ( ) . should ( 'not.exist' ) ;
101+ } ) ;
102+
95103 it ( 'should filter api keys by status' , ( ) => {
96104 const nonActiveKeys = mockAPIKeys ( ) . filter ( ( k ) => k . status !== 'active' ) ;
97105
0 commit comments