fix(tests): add missing Sentry mock event fields across 14 spec files; fix test:coverage semicolon
`@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:
@@ -29,7 +29,11 @@ beforeEach(() => {
|
||||
describe('aktivitaeten/load — core', () => {
|
||||
it('requests only unread notifications for Für-dich', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl() } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl()
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/notifications', {
|
||||
params: { query: { read: false, page: 0, size: 20 } }
|
||||
});
|
||||
@@ -45,7 +49,11 @@ describe('aktivitaeten/load — core', () => {
|
||||
return Promise.resolve({ response: { ok: true }, data: { content: unread } });
|
||||
});
|
||||
|
||||
const result = await load({ fetch, url: buildUrl() } as never);
|
||||
const result = await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl()
|
||||
} as never);
|
||||
|
||||
expect(result.activityFeed).toEqual(feed);
|
||||
expect(result.unreadNotifications).toEqual(unread);
|
||||
@@ -61,7 +69,11 @@ describe('aktivitaeten/load — core', () => {
|
||||
return Promise.resolve({ response: { ok: true }, data: { content: [] } });
|
||||
});
|
||||
|
||||
const result = await load({ fetch, url: buildUrl() } as never);
|
||||
const result = await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl()
|
||||
} as never);
|
||||
|
||||
expect(result.loadError).toBe('activity');
|
||||
expect(result.activityFeed).toEqual([]);
|
||||
@@ -69,11 +81,19 @@ describe('aktivitaeten/load — core', () => {
|
||||
|
||||
it('parses the filter query param, falling back to "alle" for invalid values', async () => {
|
||||
mockApi.GET.mockResolvedValue({ response: { ok: true }, data: [] });
|
||||
const validResult = await load({ fetch, url: buildUrl('?filter=fuer-dich') } as never);
|
||||
const validResult = await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=fuer-dich')
|
||||
} as never);
|
||||
expect(validResult.filter).toBe('fuer-dich');
|
||||
|
||||
mockApi.GET.mockResolvedValue({ response: { ok: true }, data: [] });
|
||||
const invalidResult = await load({ fetch, url: buildUrl('?filter=bogus') } as never);
|
||||
const invalidResult = await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=bogus')
|
||||
} as never);
|
||||
expect(invalidResult.filter).toBe('alle');
|
||||
});
|
||||
});
|
||||
@@ -81,7 +101,11 @@ describe('aktivitaeten/load — core', () => {
|
||||
describe('aktivitaeten/load — kinds param per filter', () => {
|
||||
it('omits kinds for filter=alle (server defaults to ROLLUP_ELIGIBLE)', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl() } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl()
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/dashboard/activity', {
|
||||
params: { query: { limit: 40 } }
|
||||
});
|
||||
@@ -89,7 +113,11 @@ describe('aktivitaeten/load — kinds param per filter', () => {
|
||||
|
||||
it('omits kinds for filter=fuer-dich (client-side filtering on youMentioned/youParticipated)', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl('?filter=fuer-dich') } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=fuer-dich')
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/dashboard/activity', {
|
||||
params: { query: { limit: 40 } }
|
||||
});
|
||||
@@ -97,7 +125,11 @@ describe('aktivitaeten/load — kinds param per filter', () => {
|
||||
|
||||
it('sends kinds=FILE_UPLOADED for filter=hochgeladen', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl('?filter=hochgeladen') } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=hochgeladen')
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/dashboard/activity', {
|
||||
params: { query: { limit: 40, kinds: ['FILE_UPLOADED'] } }
|
||||
});
|
||||
@@ -105,7 +137,11 @@ describe('aktivitaeten/load — kinds param per filter', () => {
|
||||
|
||||
it('sends TEXT_SAVED, BLOCK_REVIEWED, ANNOTATION_CREATED for filter=transkription', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl('?filter=transkription') } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=transkription')
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/dashboard/activity', {
|
||||
params: {
|
||||
query: {
|
||||
@@ -120,7 +156,11 @@ describe('aktivitaeten/load — kinds param per filter', () => {
|
||||
|
||||
it('sends COMMENT_ADDED, MENTION_CREATED for filter=kommentare', async () => {
|
||||
mockSuccess();
|
||||
await load({ fetch, url: buildUrl('?filter=kommentare') } as never);
|
||||
await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/aktivitaeten'),
|
||||
url: buildUrl('?filter=kommentare')
|
||||
} as never);
|
||||
expect(mockApi.GET).toHaveBeenCalledWith('/api/dashboard/activity', {
|
||||
params: {
|
||||
query: {
|
||||
|
||||
Reference in New Issue
Block a user