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:
@ -4,21 +4,22 @@ import { ApiError } from '../src/api/client'
|
||||
|
||||
afterEach(() => { vi.unstubAllGlobals(); localStorage.clear() })
|
||||
|
||||
it('recherche explicitement avec q/limit, suit le FIGI et retire par ID', async () => {
|
||||
it('recherche explicitement avec q/limit, suit une entreprise et retire par ID', async () => {
|
||||
localStorage.setItem('token', 'reader-token')
|
||||
const index = { symbol: 'SPX', name: 'S&P 500', figi: 'BBG-INDEX' }
|
||||
const index = { company_id: 'isin:US0378331005' }
|
||||
const company = { ...index, name: 'Apple Inc.', exchange: 'Nasdaq', country: 'United States', mic: 'XNAS' }
|
||||
const legacy = { id: 'legacy-id', symbol: 'OLD', name: 'Historic', figi: null }
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: [index] })))
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: [company] })))
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: { id: 'asset-id', ...index } }), { status: 201 }))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 204 }))
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: [legacy] })))
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
expect(await assetsApi.search('S&P 500', 20)).toEqual([index])
|
||||
expect(await assetsApi.search('Apple Inc.', 20)).toEqual([company])
|
||||
await assetsApi.add(index)
|
||||
await assetsApi.remove('asset/id')
|
||||
expect(await assetsApi.list()).toEqual([legacy])
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/indices/search?q=S%26P+500&limit=20', expect.objectContaining({ headers: expect.objectContaining({ Authorization: 'Bearer reader-token' }) }))
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/companies/search?q=Apple+Inc.&limit=20', expect.objectContaining({ headers: expect.objectContaining({ Authorization: 'Bearer reader-token' }) }))
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/me/assets', expect.objectContaining({ method: 'POST', body: JSON.stringify(index) }))
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(3, '/api/me/assets/asset%2Fid', expect.objectContaining({ method: 'DELETE' }))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user