1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

feat(ui): restrict views by role [EE-6595] (#11071)

This commit is contained in:
Chaim Lev-Ari 2024-02-15 13:29:55 +02:00 committed by GitHub
parent fe6ed55cab
commit 165d6165dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 338 additions and 83 deletions

View file

@ -1,6 +1,9 @@
import { HttpResponse } from 'msw';
import { renderWithQueryClient } from '@/react-tools/test-utils';
import { UserContext } from '@/react/hooks/useUser';
import { UserViewModel } from '@/portainer/models/user';
import { http, server } from '@/setup-tests/server';
import { NetworkContainer } from '../types';
@ -26,6 +29,8 @@ vi.mock('@uirouter/react', async (importOriginal: () => Promise<object>) => ({
}));
test('Network container values should be visible and the link should be valid', async () => {
server.use(http.get('/api/endpoints/1', () => HttpResponse.json({})));
const user = new UserViewModel({ Username: 'test', Role: 1 });
const { findByText } = renderWithQueryClient(
<UserContext.Provider value={{ user }}>

View file

@ -1,6 +1,9 @@
import { HttpResponse, http } from 'msw';
import { renderWithQueryClient } from '@/react-tools/test-utils';
import { UserContext } from '@/react/hooks/useUser';
import { UserViewModel } from '@/portainer/models/user';
import { server } from '@/setup-tests/server';
import { DockerNetwork } from '../types';
@ -48,6 +51,8 @@ test('Non system networks should have a delete button', async () => {
});
async function renderComponent(isAdmin: boolean, network: DockerNetwork) {
server.use(http.get('/api/endpoints/1', () => HttpResponse.json({})));
const user = new UserViewModel({ Username: 'test', Role: isAdmin ? 1 : 2 });
const queries = renderWithQueryClient(