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

`@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:
Marcel
2026-05-19 10:27:11 +02:00
parent 741b2231f2
commit 07415a5b2b
15 changed files with 282 additions and 46 deletions

View File

@@ -14,7 +14,11 @@ describe('admin/ocr — load', () => {
data: { availableBlocks: 10, ocrServiceAvailable: true, senderModels: [] }
});
const result = (await load({ fetch } as never))!;
const result = (await load({
fetch,
request: new Request('http://localhost/admin/ocr'),
url: new URL('http://localhost/admin/ocr')
} as never))!;
expect(result.trainingInfo.availableBlocks).toBe(10);
expect(result.trainingInfo.ocrServiceAvailable).toBe(true);
@@ -23,6 +27,12 @@ describe('admin/ocr — load', () => {
it('throws 503 when OCR API call fails', async () => {
mockApi.GET.mockResolvedValue({ response: { ok: false, status: 503 }, error: {} });
await expect(load({ fetch } as never)).rejects.toMatchObject({ status: 503 });
await expect(
load({
fetch,
request: new Request('http://localhost/admin/ocr'),
url: new URL('http://localhost/admin/ocr')
} as never)
).rejects.toMatchObject({ status: 503 });
});
});