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:
@@ -33,6 +33,7 @@ it('never calls /api/documents/search regardless of URL params', async () => {
|
||||
|
||||
await load({
|
||||
url: makeUrl({ q: 'Urlaub', from: '2020-01-01' }),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -49,6 +50,7 @@ it('always fetches dashboard data regardless of URL params', async () => {
|
||||
|
||||
await load({
|
||||
url: makeUrl({ q: 'Urlaub' }),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -110,6 +112,7 @@ describe('home page load — dashboard', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -147,6 +150,7 @@ describe('home page load — dashboard', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -168,6 +172,7 @@ describe('home page load — dashboard', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -189,6 +194,7 @@ describe('home page load — dashboard', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -213,6 +219,7 @@ describe('home page load — dashboard', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -232,6 +239,7 @@ describe('home page load — auth redirect', () => {
|
||||
await expect(
|
||||
load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0])
|
||||
@@ -249,6 +257,7 @@ describe('home page load — network error fallback', () => {
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: contributorParent()
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -268,6 +277,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi
|
||||
.fn()
|
||||
@@ -289,6 +299,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi
|
||||
.fn()
|
||||
@@ -310,6 +321,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi
|
||||
.fn()
|
||||
@@ -332,6 +344,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi.fn().mockResolvedValue({ canWrite: false, canAnnotate: false, canBlogWrite: true })
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -352,6 +365,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi
|
||||
.fn()
|
||||
@@ -369,6 +383,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi.fn().mockResolvedValue({ canWrite: true, canAnnotate: false, canBlogWrite: false })
|
||||
} as Parameters<typeof load>[0]);
|
||||
@@ -398,6 +413,7 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl(),
|
||||
request: new Request('http://localhost/'),
|
||||
fetch: vi.fn() as unknown as typeof fetch,
|
||||
parent: vi
|
||||
.fn()
|
||||
|
||||
Reference in New Issue
Block a user