fix(tests): add missing Sentry mock event fields across 14 spec files; fix test:coverage semicolon
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m25s
CI / OCR Service Tests (pull_request) Successful in 21s
CI / Backend Unit Tests (pull_request) Successful in 3m23s
CI / fail2ban Regex (pull_request) Successful in 41s
CI / Semgrep Security Scan (pull_request) Successful in 20s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m2s
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m25s
CI / OCR Service Tests (pull_request) Successful in 21s
CI / Backend Unit Tests (pull_request) Successful in 3m23s
CI / fail2ban Regex (pull_request) Successful in 41s
CI / Semgrep Security Scan (pull_request) Successful in 20s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m2s
`@sentry/sveltekit` wraps load functions and reads `event.request.method` and `event.url.pathname`. Mock events that omitted `request` or `url` threw `TypeError: Cannot read properties of undefined` on every invocation, silently masking 86 test failures on main. Two root causes fixed: - Added `request: new Request(...)` (and `url: new URL(...)` where absent) to all mock event objects in 14 `*.server.spec.ts` files - Changed `;` to `&&` in the `test:coverage` npm script so a failing server run propagates its exit code instead of being swallowed by the client run All 576 server-project tests now pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,9 @@ describe('document detail load — happy path', () => {
|
||||
|
||||
const result = await load({
|
||||
params: { id: '123' },
|
||||
fetch: mockFetch as unknown as typeof fetch
|
||||
fetch: mockFetch as unknown as typeof fetch,
|
||||
request: new Request('http://localhost/documents/123'),
|
||||
url: new URL('http://localhost/documents/123')
|
||||
});
|
||||
|
||||
expect(result.document.title).toBe('Testbrief');
|
||||
@@ -44,7 +46,12 @@ describe('document detail load — error paths', () => {
|
||||
const mockFetch = vi.fn();
|
||||
|
||||
await expect(
|
||||
load({ params: { id: 'missing' }, fetch: mockFetch as unknown as typeof fetch })
|
||||
load({
|
||||
params: { id: 'missing' },
|
||||
fetch: mockFetch as unknown as typeof fetch,
|
||||
request: new Request('http://localhost/documents/123'),
|
||||
url: new URL('http://localhost/documents/123')
|
||||
})
|
||||
).rejects.toMatchObject({ status: 404 });
|
||||
});
|
||||
|
||||
@@ -59,7 +66,12 @@ describe('document detail load — error paths', () => {
|
||||
const mockFetch = vi.fn();
|
||||
|
||||
await expect(
|
||||
load({ params: { id: 'secret' }, fetch: mockFetch as unknown as typeof fetch })
|
||||
load({
|
||||
params: { id: 'secret' },
|
||||
fetch: mockFetch as unknown as typeof fetch,
|
||||
request: new Request('http://localhost/documents/123'),
|
||||
url: new URL('http://localhost/documents/123')
|
||||
})
|
||||
).rejects.toMatchObject({ status: 403 });
|
||||
});
|
||||
|
||||
@@ -74,7 +86,12 @@ describe('document detail load — error paths', () => {
|
||||
const mockFetch = vi.fn();
|
||||
|
||||
await expect(
|
||||
load({ params: { id: 'any' }, fetch: mockFetch as unknown as typeof fetch })
|
||||
load({
|
||||
params: { id: 'any' },
|
||||
fetch: mockFetch as unknown as typeof fetch,
|
||||
request: new Request('http://localhost/documents/123'),
|
||||
url: new URL('http://localhost/documents/123')
|
||||
})
|
||||
).rejects.toMatchObject({ location: '/login' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user