-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v16] Disable Enroll New Integration button on missing permissions
Backport #50173
- Loading branch information
Showing
5 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
web/packages/teleport/src/Integrations/IntegrationsAddButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { MemoryRouter } from 'react-router'; | ||
import { render, screen } from 'design/utils/testing'; | ||
|
||
import { IntegrationsAddButton } from './IntegrationsAddButton'; | ||
|
||
test('is disables if all permissions are missing', async () => { | ||
render( | ||
<MemoryRouter> | ||
<IntegrationsAddButton | ||
requiredPermissions={[ | ||
{ value: false, label: 'permissions.1' }, | ||
{ value: false, label: 'permissions.2' }, | ||
]} | ||
/> | ||
</MemoryRouter> | ||
); | ||
|
||
expect( | ||
screen.getByTitle('You do not have access to add new integrations') | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
test('is enabled if at least one permission is true', async () => { | ||
render( | ||
<MemoryRouter> | ||
<IntegrationsAddButton | ||
requiredPermissions={[ | ||
{ value: false, label: 'permissions.1' }, | ||
{ value: true, label: 'permissions.2' }, | ||
]} | ||
/> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText('Enroll New Integration')).toBeEnabled(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters