feat(watchlist): add company identity catalog

Embed a pinned FinanceDatabase equity snapshot, add authenticated company search and identity-based follows, preserve legacy assets, and map selected Yahoo symbols for collection.

Refs #19

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:08:22 +01:00
parent 1123360914
commit d65222169a
50 changed files with 49897 additions and 193 deletions

View File

@ -0,0 +1,20 @@
import { afterEach, expect, it, vi } from 'vitest'
import { assetsApi } from '../src/api/assets'
afterEach(() => vi.unstubAllGlobals())
it('uses the company search API and submits only company_id when following a company', async () => {
const fetchMock = vi.fn()
.mockResolvedValueOnce({ ok: true, status: 200, json: async () => ({ data: [{ company_id: 'isin:CNE100001526', name: 'BYD Company Limited', exchange: 'Shenzhen Stock Exchange', country: 'China', mic: 'XSHE' }] }) })
.mockResolvedValueOnce({ ok: true, status: 201, json: async () => ({ data: { id: 'asset-1', company_id: 'isin:CNE100001526' } }) })
vi.stubGlobal('fetch', fetchMock)
expect(await assetsApi.search('BYD', 20)).toEqual([{ company_id: 'isin:CNE100001526', name: 'BYD Company Limited', exchange: 'Shenzhen Stock Exchange', country: 'China', mic: 'XSHE' }])
await assetsApi.add({ company_id: 'isin:CNE100001526' })
expect.soft(fetchMock.mock.calls[0][0]).toBe('/api/companies/search?q=BYD&limit=20')
expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/me/assets', expect.objectContaining({
method: 'POST',
body: JSON.stringify({ company_id: 'isin:CNE100001526' }),
}))
})