feat(sources): replace WatcherGuru with CNBC Business

Add the CNBC Business RSS source, switch supported-source wiring and reporting, and migrate existing WatcherGuru rows to disabled historical status without rewriting references.

Refs #23

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 17:17:15 +01:00
parent 1ff78a7b31
commit 64a7124889
18 changed files with 511 additions and 26 deletions

View File

@ -149,22 +149,25 @@ describe('plafonds d’articles administrateur', () => {
expect(updateSource).not.toHaveBeenCalled()
})
it('ne rend activables que Yahoo, Bloomberg et Watcher Guru; garde StockTwits et Reuters en historique sans commandes', async () => {
it('ne rend activables que Yahoo, Bloomberg et CNBC Business; garde Watcher Guru, StockTwits et Reuters en historique sans commandes', async () => {
listSources.mockResolvedValue([
{ id: 'y', name: 'Yahoo Finance', type: 'stocktwits', source_key: 'yahoo_finance', supported: true, operational: true, enabled: true, article_limit: 83 },
{ id: 'b', name: 'Bloomberg', type: 'bloomberg', source_key: 'bloomberg', supported: true, operational: true, enabled: false, article_limit: 77 },
{ id: 'w', name: 'Watcher.Guru', type: 'watcherguru', source_key: 'watcher_guru', supported: true, operational: true, enabled: true, article_limit: 64 },
{ id: 'c', name: 'CNBC Business', type: 'cnbc_business', source_key: 'cnbc_business', supported: true, operational: true, enabled: true, article_limit: 20 },
{ id: 'w', name: 'Watcher.Guru', type: 'watcherguru', source_key: 'watcher_guru', supported: false, operational: false, enabled: false, article_limit: 64 },
{ id: 's', name: 'StockTwits', type: 'stocktwits', source_key: null, supported: false, operational: false, enabled: false, article_limit: 31 },
{ id: 'r', name: 'Reuters', type: 'reuters', source_key: null, supported: false, operational: false, enabled: false, article_limit: 42 },
])
render(<Sources />)
expect(await screen.findByRole('heading', { name: 'Anciennes sources exclues' })).toBeInTheDocument()
for (const name of ['Yahoo Finance', 'Bloomberg', 'Watcher.Guru']) {
for (const name of ['Yahoo Finance', 'Bloomberg', 'CNBC Business']) {
expect(screen.getByRole('button', { name: new RegExp(`^(?:Activer|Désactiver) ${name}$`) })).toBeInTheDocument()
expect(screen.getByLabelText(`Plafond ${name}`)).toBeInTheDocument()
}
const historical = screen.getByRole('region', { name: 'Anciennes sources exclues' })
expect(within(historical).getByText('StockTwits')).toBeInTheDocument()
expect(within(historical).getByText('Watcher.Guru')).toBeInTheDocument()
expect(within(historical).getByText('Exclue des synthèses · Plafond historique : 64')).toBeInTheDocument()
expect(within(historical).getByText('Reuters')).toBeInTheDocument()
expect(within(historical).queryByRole('button')).not.toBeInTheDocument()
expect(within(historical).queryByRole('spinbutton')).not.toBeInTheDocument()
@ -173,7 +176,8 @@ describe('plafonds d’articles administrateur', () => {
expect(within(yahooCard as HTMLElement).queryByText(/stocktwits/i)).not.toBeInTheDocument()
expect(screen.getByLabelText('Plafond Yahoo Finance')).toHaveValue(83)
expect(screen.getByLabelText('Plafond Bloomberg')).toHaveValue(77)
expect(screen.getByLabelText('Plafond Watcher.Guru')).toHaveValue(64)
expect(screen.getByLabelText('Plafond CNBC Business')).toHaveValue(20)
expect(screen.queryByLabelText('Plafond Watcher.Guru')).not.toBeInTheDocument()
})
it('garde les anciennes sources repliées et en lecture seule même si enabled est historique', async () => {
@ -220,4 +224,27 @@ describe('plafonds d’articles administrateur', () => {
expect(await screen.findByLabelText('Plafond Yahoo Finance')).toHaveValue(240)
})
it('sauvegarde le plafond CNBC et refuse toute commande Watcher Guru même avec un ancien DTO activable', async () => {
listSources.mockResolvedValue([
{ id: 'cnbc-new', name: 'CNBC Business', type: 'cnbc_business', source_key: 'cnbc_business', supported: true, operational: true, enabled: true, article_limit: 37 },
{ id: 'watcher-old', name: 'Watcher.Guru', type: 'watcherguru', source_key: 'watcher_guru', supported: true, operational: true, enabled: true, article_limit: 64 },
])
const user = userEvent.setup()
render(<Sources />)
const cap = await screen.findByLabelText('Plafond CNBC Business')
expect(cap).toHaveValue(37)
expect(screen.queryByRole('button', { name: /^(Activer|Désactiver) Watcher/ })).not.toBeInTheDocument()
const historical = screen.getByRole('region', { name: 'Anciennes sources exclues' })
expect(within(historical).getByText('Watcher.Guru')).toBeInTheDocument()
expect(within(historical).queryByRole('spinbutton')).not.toBeInTheDocument()
expect(within(historical).queryByRole('button')).not.toBeInTheDocument()
await user.clear(cap)
await user.type(cap, '42')
await user.click(screen.getByRole('button', { name: 'Enregistrer le plafond CNBC Business' }))
await waitFor(() => expect(updateSource).toHaveBeenCalledWith('cnbc-new', true, 42))
expect(updateSource).toHaveBeenCalledTimes(1)
expect(await screen.findByRole('status')).toHaveTextContent('Plafond CNBC Business enregistré pour les prochaines synthèses.')
expect(screen.getByText(/Seules Yahoo Finance, Bloomberg et CNBC Business/)).toBeInTheDocument()
})
})