Add link search

This commit is contained in:
2026-06-20 22:08:52 +10:00
parent a3ba6dd395
commit b6212d8b3e
9 changed files with 780 additions and 14 deletions
+40
View File
@@ -160,6 +160,46 @@ describe('api client', () => {
expect(calls[0].path).toBe('/api/links/public');
});
it('listPublicLinks appends q query parameter when search is provided', async () => {
const { calls } = mockFetch(() => ({ body: { links: [] } }));
await listPublicLinks('opencode');
expect(calls[0].path).toBe('/api/links/public?q=opencode');
});
it('listPublicLinks encodes special characters in the search query', async () => {
const { calls } = mockFetch(() => ({ body: { links: [] } }));
await listPublicLinks('go links');
expect(calls[0].path).toBe('/api/links/public?q=go%20links');
});
it('listPublicLinks ignores blank/whitespace-only queries', async () => {
const { calls } = mockFetch(() => ({ body: { links: [] } }));
await listPublicLinks(' ');
expect(calls[0].path).toBe('/api/links/public');
});
it('listPrivateLinks appends q query parameter when search is provided', async () => {
const { calls } = mockFetch(() => ({ body: { links: [] } }));
await listPrivateLinks('docs');
expect(calls[0].path).toBe('/api/links/private?q=docs');
});
it('listPrivateLinks ignores blank/whitespace-only queries', async () => {
const { calls } = mockFetch(() => ({ body: { links: [] } }));
await listPrivateLinks(' ');
expect(calls[0].path).toBe('/api/links/private');
});
it('public detail endpoints use the readable /api/links/public routes', async () => {
const { calls } = mockFetch(() => ({ body: { link: {}, stats: [], history: [] } }));