diff --git a/cypress/e2e/1_acess_management.cy.js b/cypress/e2e/1_acess_management.cy.js index 84f0cf79..41c87be2 100644 --- a/cypress/e2e/1_acess_management.cy.js +++ b/cypress/e2e/1_acess_management.cy.js @@ -70,4 +70,26 @@ describe('Global stats', () => { cy.contains('aRole description').should('not.exist'); }); + it('successfully creates, updates and removes a principal', () => { + cy.login(Cypress.env('username'), Cypress.env('password'), '/access-management'); + cy.get('[aria-label=nav-item-principals').click(); + cy.contains('No principals').click(); + cy.get('[data-cy=grantAccessPrincipalButton').click(); + cy.get("[aria-label=principal-name-input]").type("aPrincipal"); + cy.get("[data-cy=menu-toogle-roles]").click(); + cy.get("[data-cy=option-typeahead-deployer]").click(); + cy.get("[data-cy=menu-toogle-roles]").click(); + cy.get('[aria-label=Save').click(); + // cy.contains('Access granted to aPrincipal.'); + // cy.get("[aria-label=aPrincipal-menu]").click(); + // cy.get("[aria-label=manageRoles]").click(); + // cy.get("[data-cy=menu-toogle-roles]").click(); + // cy.get("[data-cy=option-typeahead-admin]").click(); + // cy.get("[data-cy=option-typeahead-deployer]").click(); + // cy.get("[data-cy=menu-toogle-roles]").click(); + // cy.get('[aria-label=Save').click(); + // cy.contains('Roles [admin] granted to aPrincipal.'); + // TODO: remove needs to be tested with REST API fixes + }); + }); diff --git a/src/__tests__/views/NotFound.test.tsx b/src/__tests__/views/NotFound.test.tsx index 006ef466..d52a7e9d 100644 --- a/src/__tests__/views/NotFound.test.tsx +++ b/src/__tests__/views/NotFound.test.tsx @@ -7,7 +7,7 @@ const mockNavigate = jest.fn(); jest.mock('react-router', () => ({ ...jest.requireActual('react-router'), - useNavigate: () => mockNavigate, + useNavigate: () => mockNavigate })); describe('Not found page', () => { diff --git a/src/app/AccessManagement/AccessManager.tsx b/src/app/AccessManagement/AccessManager.tsx index d6c047b8..e6e64b7e 100644 --- a/src/app/AccessManagement/AccessManager.tsx +++ b/src/app/AccessManagement/AccessManager.tsx @@ -25,11 +25,12 @@ import { useTranslation } from 'react-i18next'; import { RoleTableDisplay } from '@app/AccessManagement/RoleTableDisplay'; import { FlushRoleCacheModal } from '@app/AccessManagement/FlushRoleCacheModal'; import { PrincipalTableDisplay } from '@app/AccessManagement/PrincipalTableDisplay'; +import { IAction } from '@patternfly/react-table'; const AccessManager = () => { const { t } = useTranslation(); const brandname = t('brandname.brandname'); - const [activeTabKey, setActiveTabKey] = useState('0'); + const [activeTabKey, setActiveTabKey] = useState<'roles' | 'principals'>('roles'); const [showRoles, setShowRoles] = useState(true); const [showAccessControl, setShowAccessControl] = useState(false); const [isOpen, setIsOpen] = useState(false); @@ -51,21 +52,23 @@ const AccessManager = () => { const handleTabClick = (ev, nav) => { const tabIndex = nav.itemId; setActiveTabKey(tabIndex); - setShowRoles(tabIndex == '0'); - setShowAccessControl(tabIndex == '1'); + setShowRoles(tabIndex == 'roles'); + setShowAccessControl(tabIndex == 'principals'); }; + const buildTabs = () => { const tabs: AccessTab[] = [ - { name: t('access-management.tab-roles'), key: '0' }, - { name: t('access-management.tab-access-control'), key: '1' }, + { name: t('access-management.tab-roles'), key: 'roles' }, + { name: t('access-management.tab-access-control'), key: 'principals' } ]; return ( -