Polish live runs status layout
This commit is contained in:
parent
ba33491479
commit
73617cd40c
6 changed files with 203 additions and 48 deletions
|
|
@ -119,6 +119,39 @@ def test_load_runs_view_humanizes_running_execution_summary_bytes(
|
|||
assert view["running"][0]["stats"] == "14 requests • 11 items • 1.5 KiB"
|
||||
|
||||
|
||||
def test_load_runs_view_projects_running_execution_duration(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
initialize_database(tmp_path / "jobs-running-duration.db")
|
||||
source = create_source(
|
||||
name="Running source",
|
||||
slug="running-source",
|
||||
source_type="feed",
|
||||
notes="",
|
||||
spider_arguments="",
|
||||
enabled=False,
|
||||
cron_minute="*/5",
|
||||
cron_hour="*",
|
||||
cron_day_of_month="*",
|
||||
cron_day_of_week="*",
|
||||
cron_month="*",
|
||||
feed_url="https://example.com/running.xml",
|
||||
)
|
||||
job = Job.get(Job.source == source)
|
||||
JobExecution.create(
|
||||
job=job,
|
||||
running_status=JobExecutionStatus.RUNNING,
|
||||
started_at=datetime(2026, 3, 30, 11, 59, 12, tzinfo=UTC),
|
||||
)
|
||||
|
||||
view = load_runs_view(
|
||||
log_dir=tmp_path / "out" / "logs",
|
||||
now=datetime(2026, 3, 30, 12, 0, tzinfo=UTC),
|
||||
)
|
||||
|
||||
assert view["running"][0]["duration"] == "00:00:48"
|
||||
|
||||
|
||||
def test_load_runs_view_projects_queued_executions_in_fifo_order(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
|
|
|||
|
|
@ -911,6 +911,45 @@ def test_load_runs_view_humanizes_completed_execution_end_time(
|
|||
assert completed["ended_at_iso"] == ended_at.isoformat()
|
||||
|
||||
|
||||
def test_load_runs_view_humanizes_running_execution_start_time(
|
||||
monkeypatch, tmp_path: Path
|
||||
) -> None:
|
||||
db_path = tmp_path / "runs-running-view.db"
|
||||
log_dir = tmp_path / "out" / "logs"
|
||||
monkeypatch.setenv("REPUBLISHER_DB_PATH", str(db_path))
|
||||
|
||||
app = create_app()
|
||||
app.config["REPUB_LOG_DIR"] = log_dir
|
||||
source = create_source(
|
||||
name="Running source",
|
||||
slug="running-source",
|
||||
source_type="feed",
|
||||
notes="",
|
||||
spider_arguments="",
|
||||
enabled=False,
|
||||
cron_minute="*/5",
|
||||
cron_hour="*",
|
||||
cron_day_of_month="*",
|
||||
cron_day_of_week="*",
|
||||
cron_month="*",
|
||||
feed_url="https://example.com/running.xml",
|
||||
)
|
||||
job = Job.get(Job.source == source)
|
||||
reference_time = datetime(2026, 1, 15, 12, 0, tzinfo=UTC)
|
||||
started_at = reference_time - timedelta(hours=2)
|
||||
JobExecution.create(
|
||||
job=job,
|
||||
running_status=JobExecutionStatus.RUNNING,
|
||||
started_at=started_at,
|
||||
)
|
||||
|
||||
view = load_runs_view(log_dir=app.config["REPUB_LOG_DIR"], now=reference_time)
|
||||
running = view["running"][0]
|
||||
|
||||
assert running["started_at"] == "2 hours ago"
|
||||
assert running["started_at_iso"] == started_at.isoformat()
|
||||
|
||||
|
||||
def test_render_runs_uses_database_backed_jobs_and_executions(
|
||||
monkeypatch, tmp_path: Path
|
||||
) -> None:
|
||||
|
|
|
|||
|
|
@ -217,9 +217,58 @@ def test_runs_page_renders_combined_running_jobs_table() -> None:
|
|||
assert "Running jobs" in body
|
||||
assert "queued-source" in body
|
||||
assert ">Queued<" in body
|
||||
assert "bg-amber-200 text-amber-950" in body
|
||||
assert "/actions/queued-executions/42/cancel" in body
|
||||
|
||||
|
||||
def test_runs_page_renders_running_state_cell_with_duration_and_started_at() -> None:
|
||||
started_at = "2026-03-30T12:00:00+00:00"
|
||||
body = str(
|
||||
runs_page(
|
||||
running_executions=(
|
||||
{
|
||||
"source": "Running source",
|
||||
"slug": "running-source",
|
||||
"job_id": 1,
|
||||
"execution_id": 11,
|
||||
"started_at": "2 minutes ago",
|
||||
"started_at_iso": started_at,
|
||||
"duration": "00:00:10",
|
||||
"runtime": "running for 10s",
|
||||
"status": "Running",
|
||||
"stats": "1 requests • 1 items • 1 byte",
|
||||
"worker": "streaming stats from worker",
|
||||
"log_href": "/job/1/execution/11/logs",
|
||||
"cancel_label": "Stop",
|
||||
"cancel_post_path": "/actions/executions/11/cancel",
|
||||
},
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assert re.search(
|
||||
r"<th[^>]*>State</th>\s*<th[^>]*>Source</th>\s*<th[^>]*>Details</th>",
|
||||
body,
|
||||
)
|
||||
assert not re.search(
|
||||
r"<th[^>]*>#</th>\s*<th[^>]*>Source</th>\s*<th[^>]*>Activity</th>\s*<th[^>]*>State</th>",
|
||||
body,
|
||||
)
|
||||
assert ">#11<" in body
|
||||
assert ">00:00:10<" in body
|
||||
assert ">2 minutes ago<" in body
|
||||
assert 'data-started-at="2026-03-30T12:00:00+00:00"' in body
|
||||
assert 'title="2026-03-30T12:00:00+00:00"' in body
|
||||
assert "bg-sky-100 text-sky-800" in body
|
||||
assert 'viewBox="0 0 640 640"' in body
|
||||
assert "rotate-180" in body
|
||||
assert "M512 320C512 214 426 128 320 128L320 512" in body
|
||||
assert "M12 6v6h4.5" in body
|
||||
assert "M6.75 3v2.25M17.25 3v2.25" in body
|
||||
assert "Running" in body
|
||||
assert "time[data-next-run-at], time[data-ended-at], time[data-started-at]" in body
|
||||
|
||||
|
||||
def test_runs_page_moves_scheduled_jobs_state_column_to_second_position() -> None:
|
||||
body = str(
|
||||
runs_page(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue