refactor(chronik): remove unused form actions and broken pagination UI
Two items flagged as blockers in PR #288 review: - Markus + Sara: "Mehr laden" calls GET /api/dashboard/activity?offset=N but the backend's DashboardController only accepts `limit` — `offset` was silently ignored, and every click re-fetched the same top-40 rows. Rather than add backend offset/cursor support in this PR (scope creep), remove the Load-more UI and defer pagination to a follow-up issue. 40 items covers the default case; the feature can come back with proper backend support and its own tests. - Markus + Sara: ?/dismiss and ?/mark-all form actions were dead code — the UI calls `onMarkRead` / `onMarkAllRead` callbacks (→ singleton → raw PATCH) and never submits either form. Delete both actions and their tests. Using the form-action path would require deprecating the NotificationBell's raw-PATCH as well — that's tracked separately as #286. The Dismiss markup split from the previous commit stands on its own. Part of #285, address PR #288 review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { actions, load } from './+page.server';
|
||||
import { load } from './+page.server';
|
||||
|
||||
const mockApi = {
|
||||
GET: vi.fn(),
|
||||
POST: vi.fn(),
|
||||
PATCH: vi.fn()
|
||||
GET: vi.fn()
|
||||
};
|
||||
|
||||
vi.mock('$lib/api.server', () => ({
|
||||
@@ -93,37 +91,3 @@ describe('chronik/load', () => {
|
||||
expect(invalidResult.filter).toBe('alle');
|
||||
});
|
||||
});
|
||||
|
||||
describe('chronik/actions', () => {
|
||||
it('dismiss: PATCHes /api/notifications/{id}/read with the form id', async () => {
|
||||
mockApi.PATCH.mockResolvedValue({ response: { ok: true } });
|
||||
const formData = new FormData();
|
||||
formData.set('id', 'n-42');
|
||||
|
||||
const result = await actions.dismiss({
|
||||
request: { formData: async () => formData },
|
||||
fetch
|
||||
} as never);
|
||||
|
||||
expect(mockApi.PATCH).toHaveBeenCalledWith('/api/notifications/{id}/read', {
|
||||
params: { path: { id: 'n-42' } }
|
||||
});
|
||||
expect(result).toEqual({ success: true });
|
||||
});
|
||||
|
||||
it('dismiss: fails with 400 when id is missing', async () => {
|
||||
const formData = new FormData();
|
||||
const result = await actions.dismiss({
|
||||
request: { formData: async () => formData },
|
||||
fetch
|
||||
} as never);
|
||||
expect((result as { status: number }).status).toBe(400);
|
||||
});
|
||||
|
||||
it('mark-all: POSTs /api/notifications/read-all', async () => {
|
||||
mockApi.POST.mockResolvedValue({ response: { ok: true } });
|
||||
const result = await actions['mark-all']({ fetch } as never);
|
||||
expect(mockApi.POST).toHaveBeenCalledWith('/api/notifications/read-all');
|
||||
expect(result).toEqual({ success: true });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user