chore: resolve merge conflicts with main
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Successful in 2m32s
CI / Backend Unit Tests (pull_request) Failing after 2m17s
CI / E2E Tests (pull_request) Failing after 2h43m0s
CI / Backend Unit Tests (push) Failing after 14m52s
CI / E2E Tests (push) Failing after 3h14m47s
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Successful in 2m32s
CI / Backend Unit Tests (pull_request) Failing after 2m17s
CI / E2E Tests (pull_request) Failing after 2h43m0s
CI / Backend Unit Tests (push) Failing after 14m52s
CI / E2E Tests (push) Failing after 3h14m47s
Kept our version of accessibility.spec.ts (color-contrast rule enabled, exclusion comment removed) over main's disabled version — the contrast fixes in this branch make the exclusion unnecessary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #149.
This commit is contained in:
@@ -23,6 +23,10 @@ function handleSearch() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{m.page_title_persons()}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8">
|
||||
<!-- Header Area -->
|
||||
<div
|
||||
|
||||
83
frontend/src/routes/persons/[id]/page.server.spec.ts
Normal file
83
frontend/src/routes/persons/[id]/page.server.spec.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { load } from './+page.server';
|
||||
|
||||
vi.mock('$lib/api.server', () => ({ createApiClient: vi.fn() }));
|
||||
|
||||
import { createApiClient } from '$lib/api.server';
|
||||
|
||||
const mockFetch = vi.fn() as unknown as typeof fetch;
|
||||
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
// ─── happy path ───────────────────────────────────────────────────────────────
|
||||
|
||||
describe('person detail load — happy path', () => {
|
||||
it('returns person, sentDocuments, and receivedDocuments on success', async () => {
|
||||
vi.mocked(createApiClient).mockReturnValue({
|
||||
GET: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
response: { ok: true, status: 200 },
|
||||
data: { id: 'p1', firstName: 'Hans', lastName: 'Müller' }
|
||||
})
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [{ id: 'd1', title: 'Brief' }] })
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
|
||||
} as ReturnType<typeof createApiClient>);
|
||||
|
||||
const result = await load({ params: { id: 'p1' }, fetch: mockFetch });
|
||||
|
||||
expect(result.person.firstName).toBe('Hans');
|
||||
expect(result.sentDocuments).toHaveLength(1);
|
||||
expect(result.receivedDocuments).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty arrays when sent/received document APIs fail', async () => {
|
||||
vi.mocked(createApiClient).mockReturnValue({
|
||||
GET: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
response: { ok: true, status: 200 },
|
||||
data: { id: 'p1', firstName: 'Anna', lastName: 'Schmidt' }
|
||||
})
|
||||
.mockResolvedValueOnce({ response: { ok: false }, data: null })
|
||||
.mockResolvedValueOnce({ response: { ok: false }, data: null })
|
||||
} as ReturnType<typeof createApiClient>);
|
||||
|
||||
const result = await load({ params: { id: 'p1' }, fetch: mockFetch });
|
||||
|
||||
expect(result.sentDocuments).toEqual([]);
|
||||
expect(result.receivedDocuments).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── error paths ──────────────────────────────────────────────────────────────
|
||||
|
||||
describe('person detail load — error paths', () => {
|
||||
it('throws 404 when person does not exist', async () => {
|
||||
vi.mocked(createApiClient).mockReturnValue({
|
||||
GET: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ response: { ok: false, status: 404 }, error: null })
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
|
||||
} as ReturnType<typeof createApiClient>);
|
||||
|
||||
await expect(load({ params: { id: 'missing' }, fetch: mockFetch })).rejects.toMatchObject({
|
||||
status: 404
|
||||
});
|
||||
});
|
||||
|
||||
it('throws 403 when person is not accessible', async () => {
|
||||
vi.mocked(createApiClient).mockReturnValue({
|
||||
GET: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ response: { ok: false, status: 403 }, error: null })
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
|
||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
|
||||
} as ReturnType<typeof createApiClient>);
|
||||
|
||||
await expect(load({ params: { id: 'forbidden' }, fetch: mockFetch })).rejects.toMatchObject({
|
||||
status: 403
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user