Add host path browser to config page

This commit is contained in:
Dymas
2026-05-25 17:20:55 +02:00
parent ece4ce0d5e
commit aef3be9d2d
7 changed files with 318 additions and 6 deletions
+18
View File
@@ -1892,6 +1892,19 @@ class HandlerRouteTests(unittest.TestCase):
self.assertEqual(handler.json_payload["version"], APP.VERSION)
self.assertIn("ani_cli_version", handler.json_payload)
def test_filesystem_browse_route_lists_directories(self):
with tempfile.TemporaryDirectory() as temp_root:
Path(temp_root, "folder-a").mkdir()
Path(temp_root, "folder-b").mkdir()
Path(temp_root, "file.txt").write_text("example", encoding="utf-8")
handler = DummyHandler(f"/api/fs/browse?path={APP.quote(temp_root)}&mode=dir")
APP.Handler.do_GET(handler)
self.assertEqual(handler.json_status, HTTPStatus.OK)
self.assertEqual(handler.json_payload["path"], temp_root)
self.assertEqual([entry["name"] for entry in handler.json_payload["entries"]], ["folder-a", "folder-b"])
self.assertTrue(all(entry["is_dir"] for entry in handler.json_payload["entries"]))
def test_config_post_accepts_discord_webhook_fields(self):
body = b'{"download_dir":"/tmp/example","mode":"sub","quality":"best","discord_webhook_url":"https://discord.example/webhook","discord_webhook_events":["runtime_error","watchlist_refresh_failed","bad"]}'
handler = DummyHandler("/api/config", body=body, content_length=len(body))
@@ -2160,6 +2173,11 @@ class TemplateHelperTests(unittest.TestCase):
self.assertIn('id="aniCliVersionLine"', APP.CONFIG_HTML)
self.assertIn('ani-cli ${data.ani_cli_version || "Unavailable"}', APP.CONFIG_HTML)
def test_config_page_includes_host_path_browser_controls(self):
self.assertIn('class="ghost browse-path-btn"', APP.CONFIG_HTML)
self.assertIn('id="pathBrowserOverlay"', APP.CONFIG_HTML)
self.assertIn('/api/fs/browse?path=${encodeURIComponent(path || state.pathBrowser.path || "")}', APP.CONFIG_HTML)
def test_search_page_sends_watchlist_auto_download_series(self):
self.assertIn('auto_download_series: $("seasonInput").value || "1"', APP.INDEX_HTML)