from pathlib import Path INDEX_HTML = Path(__file__).resolve().parents[2] / "apps" / "web" / "vue3" / "index.html" MAIN_PY = Path(__file__).resolve().parents[2] / "apps" / "web" / "vue3" / "main.py" def test_execution_indicator_recovers_current_job_tasks_from_backend_runtime(): source = INDEX_HTML.read_text(encoding="utf-8") assert "resource_tasks: []" in source assert "runtimeOverview.resource_tasks = Array.isArray(data.resource_tasks) ? data.resource_tasks : [];" in source assert "const currentJobRuntimeTasks = computed" in source assert "String(task.job_id || '') === currentJobId" in source assert "const executionIndicatorTask = computed" in source def test_execution_indicator_visibility_and_stop_use_recovered_backend_task(): source = INDEX_HTML.read_text(encoding="utf-8") assert 'v-if="showExecutionIndicator"' in source assert "const showExecutionIndicator = computed" in source assert "executionIndicatorTask.value" in source assert "currentJobRuntimeTasks.value.forEach" in source assert "task.task_id" in source def test_execution_indicator_clears_only_after_backend_task_is_terminal(): source = INDEX_HTML.read_text(encoding="utf-8") assert "const ACTIVE_RUNTIME_TASK_STATUSES" in source assert "'queued', 'pending', 'running', 'started', 'waiting_resource', 'retry'" in source assert "ACTIVE_RUNTIME_TASK_STATUSES.has" in source def test_runtime_overview_does_not_truncate_active_resource_tasks(): source = MAIN_PY.read_text(encoding="utf-8") assert 'overview["resource_tasks"] = resource.get("tasks", [])' in source assert 'resource.get("tasks", [])[:20]' not in source