feat(web/m7-381): admin overview Library Scan section + manual trigger

Adds getScanStatus/triggerScan helpers, createScanStatusQuery factory
(3s poll), qk.scanStatus(), and a Library Scan section on the admin
overview page with per-stage tallies and inline Run scan button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-04 20:16:29 -04:00
parent 3d0e213081
commit 05bc2628a3
4 changed files with 201 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { getScanStatus, triggerScan } from './admin';
vi.mock('./client', () => ({
api: { get: vi.fn(), post: vi.fn() }
}));
import { api } from './client';
describe('admin scan API', () => {
beforeEach(() => vi.clearAllMocks());
it('getScanStatus GETs the correct path', async () => {
(api.get as unknown as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
id: 's1', started_at: '2026-05-04T00:00:00Z', finished_at: null, in_flight: true
});
const got = await getScanStatus();
expect(api.get).toHaveBeenCalledWith('/api/admin/scan/status');
expect(got.in_flight).toBe(true);
});
it('triggerScan POSTs an empty body to /run', async () => {
(api.post as unknown as ReturnType<typeof vi.fn>).mockResolvedValueOnce({ id: 's2' });
const got = await triggerScan();
expect(api.post).toHaveBeenCalledWith('/api/admin/scan/run', {});
expect(got.id).toBe('s2');
});
});