Some checks failed
CI / Unit & Component Tests (push) Failing after 2m37s
CI / OCR Service Tests (push) Successful in 32s
CI / OCR Service Tests (pull_request) Successful in 30s
CI / Backend Unit Tests (push) Failing after 2m47s
CI / Unit & Component Tests (pull_request) Failing after 2m29s
CI / Backend Unit Tests (pull_request) Failing after 2m46s
- Add /register route with invite code prefill, password show/hide - Add /login?registered=1 success banner - Add /admin/invites page: list, create, revoke, copy link - Add Einladungen nav section to admin sidebar (ADMIN_USER perm) - Add invite error codes to errors.ts - Add 48 i18n keys across de/en/es - Update hooks.server.ts to allow public access to invite/register API Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
/**
|
||
* Tests for the admin root page — the mobile entity picker.
|
||
* On md+ viewports the page immediately redirects to /admin/users (tested
|
||
* in e2e). Here we verify the mobile-only list of entity links.
|
||
*/
|
||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||
import { cleanup, render } from 'vitest-browser-svelte';
|
||
import { page } from 'vitest/browser';
|
||
import Page from './+page.svelte';
|
||
|
||
vi.mock('$app/navigation', () => ({ goto: vi.fn() }));
|
||
|
||
const fullData = {
|
||
userCount: 4,
|
||
groupCount: 3,
|
||
tagCount: 7,
|
||
inviteCount: 2,
|
||
canManageUsers: true,
|
||
canManageTags: true,
|
||
canManagePermissions: true,
|
||
canRunMaintenance: true
|
||
};
|
||
|
||
afterEach(cleanup);
|
||
|
||
describe('Admin root page – entity picker', () => {
|
||
it('renders the admin heading', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect.element(page.getByRole('heading')).toBeInTheDocument();
|
||
});
|
||
|
||
it('renders users link pointing to /admin/users', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect
|
||
.element(page.getByRole('link', { name: /benutzer/i }))
|
||
.toHaveAttribute('href', '/admin/users');
|
||
});
|
||
|
||
it('renders groups link pointing to /admin/groups', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect
|
||
.element(page.getByRole('link', { name: /gruppen/i }))
|
||
.toHaveAttribute('href', '/admin/groups');
|
||
});
|
||
|
||
it('renders tags link pointing to /admin/tags', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect
|
||
.element(page.getByRole('link', { name: /schlagworte/i }))
|
||
.toHaveAttribute('href', '/admin/tags');
|
||
});
|
||
|
||
it('renders system link pointing to /admin/system', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect
|
||
.element(page.getByRole('link', { name: /system/i }))
|
||
.toHaveAttribute('href', '/admin/system');
|
||
});
|
||
|
||
it('hides users link when canManageUsers is false', async () => {
|
||
render(Page, { data: { ...fullData, canManageUsers: false } });
|
||
await expect.element(page.getByRole('link', { name: /benutzer/i })).not.toBeInTheDocument();
|
||
});
|
||
|
||
it('hides system link when canRunMaintenance is false', async () => {
|
||
render(Page, { data: { ...fullData, canRunMaintenance: false } });
|
||
await expect.element(page.getByRole('link', { name: /system/i })).not.toBeInTheDocument();
|
||
});
|
||
|
||
it('shows user count', async () => {
|
||
render(Page, { data: fullData });
|
||
await expect.element(page.getByText('4')).toBeInTheDocument();
|
||
});
|
||
});
|