Enhance job logging and UI updates

- Implement job logging functionality to track progress and events for each job.
- Add a new section in the job card to display session logs with detailed entries.
- Update job statistics to include pages fetched, pages found, and assets processed.
- Modify the UI theme and text for better clarity and aesthetics.
- Adjust tests to validate new logging features and ensure proper event handling.
This commit is contained in:
kstyagi23
2026-09-05 07:36:34 +05:30
parent 8f9210d6be
commit 2059c275c2
10 changed files with 762 additions and 593 deletions
+9
View File
@@ -121,6 +121,15 @@ def test_capture_service_creates_private_archive(tmp_path) -> None:
names = archive.namelist()
assert any(name.endswith("siteharbor-manifest.json") for name in names)
assert any(name.endswith("site.css") for name in names)
page_logs = [
event["payload"]["detail"]
for event in database.get_events(job["id"])
if event["kind"] == "progress"
and isinstance(event["payload"].get("detail"), dict)
and event["payload"]["detail"].get("kind") == "page"
]
assert {log["action"] for log in page_logs} == {"fetching", "captured"}
assert {log["url"] for log in page_logs} == {source_url}
def test_capture_cancels_while_a_resource_is_stalled(tmp_path) -> None:
+9 -2
View File
@@ -63,7 +63,7 @@ def test_crawler_captures_and_rewrites_static_fixture(tmp_path) -> None:
respect_robots=True,
fetch_concurrency=3,
)
events: list[tuple[str, str]] = []
events: list[tuple[str, str, dict[str, object] | None]] = []
crawler = SiteCrawler(
settings=test_settings,
options=CaptureOptions(
@@ -75,7 +75,9 @@ def test_crawler_captures_and_rewrites_static_fixture(tmp_path) -> None:
max_duration_seconds=30,
),
cancelled=lambda: False,
on_progress=lambda phase, message, stats, warnings: events.append((phase, message)),
on_progress=lambda phase, message, stats, warnings, detail: events.append(
(phase, message, detail)
),
)
try:
@@ -99,3 +101,8 @@ def test_crawler_captures_and_rewrites_static_fixture(tmp_path) -> None:
assert (host_dir / "assets" / "chunk.js").is_file()
assert (result.site_dir / "siteharbor-manifest.json").is_file()
assert events
page_events = [detail for _, _, detail in events if detail and detail["kind"] == "page"]
assert len(page_events) == 4
assert {str(detail["action"]) for detail in page_events} == {"fetching", "captured"}
assert all(isinstance(detail["url"], str) for detail in page_events)
assert all(isinstance(detail["pages_remaining"], int) for detail in page_events)
+1
View File
@@ -36,6 +36,7 @@ def test_capture_routes_are_scoped_to_the_browser_session(tmp_path, monkeypatch)
assert "Archive the web." in homepage.text
assert "Website Downloader & Offline Archive Tool" in homepage.text
assert "https://git.zerofucks.io/kstyagi/website-downloader" in homepage.text
assert "Geist+Mono" in homepage.text
assert client.get("/api/captures").status_code == 401
created = client.post(