fix reset state

This commit is contained in:
larssand
2026-07-06 17:05:27 +02:00
parent 649c29a8c2
commit da540f81ae
4 changed files with 69 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
import json
import inspect
import unittest
from unittest.mock import patch
import fgai.dashboard as dashboard
from fgai.dashboard import HTML, _ollama_models
@@ -62,6 +64,11 @@ class DashboardTests(unittest.TestCase):
self.assertIn('id="clearAllIncidents"', HTML)
self.assertIn("/api/incidents/clear", HTML)
def test_dashboard_exposes_review_state_reset_endpoints(self):
source = inspect.getsource(dashboard)
self.assertIn("/api/feedback/clear", source)
self.assertIn("/api/review-state/clear", source)
def test_dashboard_does_not_clear_streams_when_picker_is_unloaded(self):
self.assertIn("const streamValues = Object.values(window.streamSelection || {})", HTML)
self.assertIn("if (streamValues.length)", HTML)

25
tests/test_feedback.py Normal file
View File

@@ -0,0 +1,25 @@
import tempfile
import unittest
from pathlib import Path
from fgai.feedback import FeedbackStore
class FeedbackTests(unittest.TestCase):
def test_feedback_store_can_clear_by_status_or_all(self):
with tempfile.TemporaryDirectory() as directory:
store = FeedbackStore(str(Path(directory) / "feedback.json"))
store.add({"status": "expected", "entity": "alice", "stream_id": "windows", "field": "username"})
store.add({"status": "confirmed", "entity": "bob", "stream_id": "vpn", "field": "username"})
expected = store.clear(status="expected")
self.assertEqual(expected, {"removed": 1, "remaining": 1, "status": "expected"})
self.assertEqual(store.entries()[0]["status"], "confirmed")
all_items = store.clear()
self.assertEqual(all_items, {"removed": 1, "remaining": 0, "status": "all"})
self.assertEqual(store.entries(), [])
if __name__ == "__main__":
unittest.main()