Skip to content

Commit fb614bd

Browse files
committed
fix and add test
1 parent 6b3a907 commit fb614bd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/cypress/cypress/support/commands/odh.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,10 @@ declare global {
11311131
type: 'POST /maas/api/v1/api-keys',
11321132
response: { data: OdhResponse<CreateAPIKeyResponse> },
11331133
) => Cypress.Chainable<null>) &
1134+
((
1135+
type: 'GET /maas/api/v1/is-maas-admin',
1136+
response: OdhResponse<{ data: { allowed: boolean } }>,
1137+
) => Cypress.Chainable<null>) &
11341138
((
11351139
type: 'GET /maas/api/v1/user',
11361140
response: OdhResponse<{ data: { userId: string; clusterAdmin: boolean } }>,

packages/cypress/cypress/tests/mocked/modelsAsAService/maasApiKeys.cy.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mockDashboardConfig, mockDscStatus } from '@odh-dashboard/internal/__mocks__';
22
import { DataScienceStackComponent } from '@odh-dashboard/internal/concepts/areas/types';
33
import type { APIKey } from '@odh-dashboard/maas/types/api-key';
4-
import { asProductAdminUser } from '../../../utils/mockUsers';
4+
import { asClusterAdminUser, asProjectAdminUser } from '../../../utils/mockUsers';
55
import {
66
apiKeysPage,
77
bulkRevokeAPIKeyModal,
@@ -22,7 +22,7 @@ const mockSearchResponse = (keys: APIKey[]) => ({
2222

2323
describe('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

Comments
 (0)