From a4997a5fbc65913b55f2215eb3b868693bd76c51 Mon Sep 17 00:00:00 2001
From: Adam Mathes <adam@adammathes.com>
Date: Sat, 14 Feb 2026 10:03:35 -0800
Subject: test: increase frontend coverage for Settings and improve FeedItem
 css

---
 frontend/src/components/Settings.test.tsx | 38 +++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

(limited to 'frontend/src/components/Settings.test.tsx')

diff --git a/frontend/src/components/Settings.test.tsx b/frontend/src/components/Settings.test.tsx
index f46ce6f..b7de3bb 100644
--- a/frontend/src/components/Settings.test.tsx
+++ b/frontend/src/components/Settings.test.tsx
@@ -98,4 +98,42 @@ describe('Settings Component', () => {
       expect(screen.queryByText('Tech News')).not.toBeInTheDocument();
     });
   });
+
+  it('imports an OPML file', async () => {
+    (global.fetch as any)
+      .mockResolvedValueOnce({ ok: true, json: async () => [] }) // Initial load
+      .mockResolvedValueOnce({ ok: true, json: async () => ({ status: 'ok' }) }) // Import
+      .mockResolvedValueOnce({
+        ok: true,
+        json: async () => [{ _id: 1, title: 'Imported Feed', url: 'http://imported.com/rss' }],
+      }); // Refresh load
+
+    render(<Settings />);
+
+    const file = new File(['<opml>...</opml>'], 'feeds.opml', { type: 'text/xml' });
+    const fileInput = screen.getByLabelText(/import feeds/i, { selector: 'input[type="file"]' });
+    const importButton = screen.getByText('Import');
+
+    fireEvent.change(fileInput, { target: { files: [file] } });
+    await waitFor(() => {
+      expect(importButton).not.toBeDisabled();
+    });
+
+    fireEvent.click(importButton);
+
+    await waitFor(() => {
+      expect(global.fetch).toHaveBeenCalledWith(
+        '/api/import',
+        expect.objectContaining({
+          method: 'POST',
+          body: expect.any(FormData),
+        })
+      );
+    });
+
+    // Check if refresh happens
+    await waitFor(() => {
+      expect(screen.getByText('Imported Feed')).toBeInTheDocument();
+    });
+  });
 });
-- 
cgit v1.2.3

