Site-instellingen: ook Beheerder mag lezen en wijzigen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,12 +32,12 @@ describe('Sidebar role filtering (BR-U3-01 – BR-U3-06)', () => {
|
|||||||
expect(screen.queryByTestId('nav-profile')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('nav-profile')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Administrator sees Dashboard and Users — not Settings or CMS', async () => {
|
it('Administrator sees Dashboard, Users and Settings — not CMS', async () => {
|
||||||
mockAuthenticatedAs('Administrator');
|
mockAuthenticatedAs('Administrator');
|
||||||
renderApp('/dashboard');
|
renderApp('/dashboard');
|
||||||
expect(await screen.findByTestId('nav-dashboard')).toBeInTheDocument();
|
expect(await screen.findByTestId('nav-dashboard')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('nav-users')).toBeInTheDocument();
|
expect(screen.getByTestId('nav-users')).toBeInTheDocument();
|
||||||
expect(screen.queryByTestId('nav-settings')).not.toBeInTheDocument();
|
expect(screen.getByTestId('nav-settings')).toBeInTheDocument();
|
||||||
expect(screen.queryByTestId('nav-cms')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('nav-cms')).not.toBeInTheDocument();
|
||||||
expect(screen.queryByTestId('nav-profile')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('nav-profile')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { useAuth } from '@/features/auth/context/auth-context';
|
|||||||
import { useAvailabilityStatus } from '@/features/availability/services/useAvailability';
|
import { useAvailabilityStatus } from '@/features/availability/services/useAvailability';
|
||||||
import { useSystemCapabilities } from '@/features/system/services/useSystemCapabilities';
|
import { useSystemCapabilities } from '@/features/system/services/useSystemCapabilities';
|
||||||
import { LanguageSwitcher } from '@/i18n/LanguageSwitcher';
|
import { LanguageSwitcher } from '@/i18n/LanguageSwitcher';
|
||||||
|
import { BrandLogo } from './BrandLogo';
|
||||||
import { ThemeToggle } from './ThemeToggle';
|
import { ThemeToggle } from './ThemeToggle';
|
||||||
import { UserMenu } from './UserMenu';
|
import { UserMenu } from './UserMenu';
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ const NAV_ITEMS: NavItem[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const SETTINGS_ITEM: NavItem = {
|
const SETTINGS_ITEM: NavItem = {
|
||||||
to: '/settings', labelKey: 'nav.settings', icon: Settings, testId: 'nav-settings', roles: ['Owner'],
|
to: '/settings', labelKey: 'nav.settings', icon: Settings, testId: 'nav-settings', roles: ['Owner', 'Administrator'],
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SidebarProps {
|
interface SidebarProps {
|
||||||
@@ -66,10 +67,7 @@ export function Sidebar({ onClose }: SidebarProps = {}) {
|
|||||||
data-testid="app-sidebar"
|
data-testid="app-sidebar"
|
||||||
>
|
>
|
||||||
<div className="flex h-16 items-center justify-between border-b border-border px-6">
|
<div className="flex h-16 items-center justify-between border-b border-border px-6">
|
||||||
<div className="flex items-center gap-2">
|
<BrandLogo />
|
||||||
<span className="h-3 w-3 rounded-full bg-primary" aria-hidden="true" />
|
|
||||||
<span className="text-lg font-semibold">{t('common.appName')}</span>
|
|
||||||
</div>
|
|
||||||
{onClose && (
|
{onClose && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
|||||||
import { http, HttpResponse } from 'msw';
|
import { http, HttpResponse } from 'msw';
|
||||||
import { renderApp, mockAuthenticated, mockGuest } from '@/test/utils';
|
import { renderApp, mockAuthenticated, mockGuest } from '@/test/utils';
|
||||||
import { server } from '@/mocks/server';
|
import { server } from '@/mocks/server';
|
||||||
import { API_BASE } from '@/features/auth/mocks/fixtures';
|
import { API_BASE, makeAuthResponse, mockUser } from '@/features/auth/mocks/fixtures';
|
||||||
import { _resetSetupStatusCache } from '@/router';
|
import { _resetSetupStatusCache } from '@/router';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -19,6 +19,19 @@ describe('SettingsPage', () => {
|
|||||||
expect(await screen.findByTestId('settings-title', {}, { timeout: 10000 })).toBeInTheDocument();
|
expect(await screen.findByTestId('settings-title', {}, { timeout: 10000 })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('lets an Administrator open the site settings', async () => {
|
||||||
|
server.use(
|
||||||
|
http.post(`${API_BASE}/api/v1/auth/refresh`, () =>
|
||||||
|
HttpResponse.json(
|
||||||
|
makeAuthResponse({ user: { ...mockUser, role: 'Administrator', name: 'Test Admin' } }),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
renderApp('/settings');
|
||||||
|
|
||||||
|
expect(await screen.findByTestId('settings-title', {}, { timeout: 10000 })).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('shows the current availability status badge', async () => {
|
it('shows the current availability status badge', async () => {
|
||||||
mockAuthenticated();
|
mockAuthenticated();
|
||||||
renderApp('/settings');
|
renderApp('/settings');
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ const settingsRoute = createRoute({
|
|||||||
getParentRoute: () => authenticatedRoute,
|
getParentRoute: () => authenticatedRoute,
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
component: () => (
|
component: () => (
|
||||||
<RoleGuard allowedRoles={['Owner']}>
|
<RoleGuard allowedRoles={['Owner', 'Administrator']}>
|
||||||
{lazyPage(() => import('@/features/settings/pages/SettingsPage'), 'SettingsPage')()}
|
{lazyPage(() => import('@/features/settings/pages/SettingsPage'), 'SettingsPage')()}
|
||||||
</RoleGuard>
|
</RoleGuard>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class AvailabilityController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("admin/status")]
|
[HttpPost("admin/status")]
|
||||||
[Authorize(Policy = "OwnerOnly")]
|
[Authorize(Policy = "AdminOnly")]
|
||||||
public async Task<IActionResult> UpdateStatus([FromBody] UpdateStatusRequest request)
|
public async Task<IActionResult> UpdateStatus([FromBody] UpdateStatusRequest request)
|
||||||
{
|
{
|
||||||
if (_availabilityService is not PersistentAvailabilityService persistentService)
|
if (_availabilityService is not PersistentAvailabilityService persistentService)
|
||||||
|
|||||||
Reference in New Issue
Block a user