-
-
Sources de news
-
Activez ou désactivez les sources de données
-
-
- {sources.map(s => (
-
-
-
- {s.name}
- ({s.type})
-
-
-
- {s.enabled ? 'Activée' : 'Désactivée'}
-
-
-
-
-
- ))}
-
+
Sources et plafonds
+ {loading ?
Chargement des sources et plafonds…
: loadError ? (
+
{loadError}
+ ) : <>
+
+ Plafond global
+
+
+
+
+ {sources.length === 0 &&
Aucune source disponible.
}
+ {sources.map(source =>
)}
+ >}
)
}
diff --git a/frontend/tests/admin-article-limits.test.tsx b/frontend/tests/admin-article-limits.test.tsx
new file mode 100644
index 0000000..5288498
--- /dev/null
+++ b/frontend/tests/admin-article-limits.test.tsx
@@ -0,0 +1,152 @@
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { MemoryRouter } from 'react-router-dom'
+import { AdminSettings } from '../src/pages/admin/AdminSettings'
+import { Sources } from '../src/pages/admin/Sources'
+
+const { listSettings, getDefaultPrompt, updateSettings, listSources, updateSource } = vi.hoisted(() => ({
+ listSettings: vi.fn(),
+ getDefaultPrompt: vi.fn(),
+ updateSettings: vi.fn(),
+ listSources: vi.fn(),
+ updateSource: vi.fn(),
+}))
+
+vi.mock('@/api/admin', () => ({
+ adminApi: { listSettings, getDefaultPrompt, updateSettings, listSources, updateSource },
+}))
+
+describe('plafonds d’articles administrateur', () => {
+ afterEach(cleanup)
+ beforeEach(() => {
+ listSettings.mockResolvedValue([{ key: 'summary_max_articles', value: '700' }])
+ getDefaultPrompt.mockResolvedValue({ prompt: 'system' })
+ updateSettings.mockResolvedValue(undefined)
+ listSources.mockResolvedValue([{ id: 'source-1', name: 'Yahoo Finance', type: 'yahoo', enabled: true, article_limit: 240 }])
+ updateSource.mockResolvedValue(undefined)
+ })
+
+ it('borne le plafond global de 1 à 500 sans écrêter une valeur historique', async () => {
+ render(