fix(health): address consolidation review findings
This commit is contained in:
@@ -23,7 +23,7 @@ router = APIRouter(prefix="/api/health", tags=["Health"])
|
||||
# @RELATION CALLS -> [Services.HealthServiceClass]
|
||||
@router.get("/summary", response_model=HealthSummaryResponse)
|
||||
async def get_health_summary(
|
||||
environment_id: str | None = Query(None),
|
||||
env_id: str | None = Query(None),
|
||||
db: Session = Depends(get_db),
|
||||
config_manager = Depends(get_config_manager),
|
||||
_ = Depends(has_permission("plugin:migration", "READ"))
|
||||
@@ -35,7 +35,7 @@ async def get_health_summary(
|
||||
if not config_manager.get_config().settings.features.health_monitor:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Health monitor feature is disabled")
|
||||
service = HealthService(db, config_manager=config_manager)
|
||||
return await service.get_health_summary(environment_id=environment_id or "")
|
||||
return await service.get_health_summary(environment_id=env_id or "")
|
||||
# #endregion Api.Health.GetHealthSummary
|
||||
|
||||
|
||||
|
||||
@@ -309,8 +309,7 @@ class TestParseCommandLlmProviders:
|
||||
assert result["operation"] == "list_llm_providers"
|
||||
|
||||
def test_llm_status_via_parser(self):
|
||||
"""'llm провер' routes to get_llm_status now that the legacy
|
||||
run_llm_validation branch (which shadowed this keyword) is removed."""
|
||||
"""'llm провер' routes to get_llm_status after legacy validation removal."""
|
||||
from src.api.routes.assistant._command_parser import _parse_command
|
||||
cm = _make_config_manager()
|
||||
result = _parse_command("llm провер", cm)
|
||||
|
||||
@@ -90,7 +90,6 @@ class TestToolCapabilities:
|
||||
{"operation": "deploy_dashboard"},
|
||||
{"operation": "execute_migration"},
|
||||
{"operation": "run_backup"},
|
||||
{"operation": "run_llm_validation"},
|
||||
{"operation": "run_llm_documentation"},
|
||||
{"operation": "get_task_status"},
|
||||
{"operation": "get_health_summary"},
|
||||
|
||||
@@ -92,7 +92,7 @@ class TestGetHealthSummary:
|
||||
with patch("src.api.routes.health.HealthService", return_value=mock_service):
|
||||
from src.dependencies import get_config_manager
|
||||
client = _make_client({get_config_manager: lambda: _enabled_config()})
|
||||
resp = client.get("/api/health/summary?environment_id=prod")
|
||||
resp = client.get("/api/health/summary?env_id=prod")
|
||||
assert resp.status_code == 200
|
||||
mock_service.get_health_summary.assert_called_with(environment_id="prod")
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
"env_id": "ss-dev"
|
||||
},
|
||||
"expected": {
|
||||
"tool_count": 9,
|
||||
"tool_names": ["search_dashboards", "get_health_summary", "deploy_dashboard", "run_llm_validation", "run_llm_documentation", "execute_migration", "create_branch", "commit_changes", "show_capabilities"],
|
||||
"tool_count": 8,
|
||||
"tool_names": ["search_dashboards", "get_health_summary", "deploy_dashboard", "run_llm_documentation", "execute_migration", "create_branch", "commit_changes", "show_capabilities"],
|
||||
"uicontext_injected": true,
|
||||
"runtime_context_contains": ["[USER CONTEXT]", "Отчёт по энергопотреблению", "dashboards/42"]
|
||||
}
|
||||
|
||||
@@ -1370,7 +1370,7 @@ describe('ApiModule — registry methods', () => {
|
||||
expect(fetch).toHaveBeenCalledWith('/api/security/encryption/recover', expect.objectContaining({ method: 'POST' }));
|
||||
});
|
||||
|
||||
// ── getValidationStatusBatch with actual params ──────────────────
|
||||
// ── task API params ─────────────────────────────────────────────
|
||||
|
||||
it('getTasks with search param', async () => {
|
||||
vi.mocked(fetch).mockResolvedValue(await _okJson({ tasks: [], total: 0 }));
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<!-- @REJECTED Rendering raw cron expressions for every schedule rejected — dense and unreadable at a
|
||||
glance; cadence labels keep the widget compact while the automation page owns the details. -->
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { ROUTES } from '$lib/routes.js';
|
||||
import { listSchedules } from '$lib/api/scenario-automation.js';
|
||||
import type { ScenarioSchedule } from '$lib/types/scenario-automation.js';
|
||||
@@ -24,6 +23,7 @@
|
||||
|
||||
type GlanceState = 'loading' | 'loaded' | 'error';
|
||||
|
||||
let { environmentId = '' }: { environmentId?: string } = $props();
|
||||
let schedules: ScenarioSchedule[] = $state([]);
|
||||
let state: GlanceState = $state('loading');
|
||||
let envFilter: string = $state('');
|
||||
@@ -46,7 +46,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => { void load(); });
|
||||
$effect(() => {
|
||||
refresh(environmentId);
|
||||
});
|
||||
|
||||
const enabled = $derived(schedules.filter((s) => s.enabled));
|
||||
|
||||
|
||||
@@ -94,6 +94,17 @@ describe("sidebarNavigation", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("places Health Center first in the Testing category", () => {
|
||||
const user = makeUser([{ name: "Admin", permissions: [] }]);
|
||||
const categories = buildSidebarSections(i18nState, user).flatMap((section) => section.categories);
|
||||
const dashboards = categories.find((category) => category.id === "dashboards");
|
||||
const testing = categories.find((category) => category.id === "dashboard_testing");
|
||||
|
||||
expect(dashboards?.subItems.map((item) => item.path)).not.toContain("/dashboards/health");
|
||||
expect(testing?.path).toBe("/dashboards/health");
|
||||
expect(testing?.subItems[0]?.path).toBe("/dashboards/health");
|
||||
});
|
||||
|
||||
it("shows only categories available to a non-admin user", () => {
|
||||
const user = makeUser([
|
||||
{
|
||||
@@ -118,6 +129,7 @@ describe("sidebarNavigation", () => {
|
||||
"datasets",
|
||||
"migration",
|
||||
"git",
|
||||
"dashboard_testing",
|
||||
"reports",
|
||||
"tools",
|
||||
]);
|
||||
@@ -212,14 +224,15 @@ describe("sidebarNavigation", () => {
|
||||
|
||||
// ── Fix 2: the dashboard-testing category makes the approval loop reachable ──
|
||||
describe("dashboard testing category (Fix 2)", () => {
|
||||
it("is shown to an admin with all four RBAC-gated subitems", () => {
|
||||
it("is shown to an admin with Health Center and four RBAC-gated subitems", () => {
|
||||
const user = makeUser([{ name: "Admin", permissions: [] }]);
|
||||
const categories = buildSidebarSections(i18nState, user).flatMap((s) => s.categories);
|
||||
const testing = categories.find((c) => c.id === "dashboard_testing");
|
||||
|
||||
expect(testing).toBeDefined();
|
||||
expect(testing!.path).toBe("/dashboard-testing");
|
||||
expect(testing!.path).toBe("/dashboards/health");
|
||||
expect(testing!.subItems.map((i: { path: string }) => i.path)).toEqual([
|
||||
"/dashboards/health",
|
||||
"/dashboard-testing/scenarios",
|
||||
"/dashboard-testing/runs",
|
||||
"/dashboard-testing/analytics",
|
||||
@@ -246,12 +259,13 @@ describe("sidebarNavigation", () => {
|
||||
expect(testing!.subItems.map((i: { path: string }) => i.path)).toEqual(["/dashboard-testing/runs"]);
|
||||
});
|
||||
|
||||
it("is hidden entirely when the user has no testing permissions", () => {
|
||||
it("shows Health Center to a migration reader without testing permissions", () => {
|
||||
const user = makeUser([
|
||||
{ name: "Viewer", permissions: [{ resource: "plugin:migration", action: "READ" }] },
|
||||
]);
|
||||
const categories = buildSidebarSections(i18nState, user).flatMap((s) => s.categories);
|
||||
expect(categories.find((c) => c.id === "dashboard_testing")).toBeUndefined();
|
||||
const testing = categories.find((c) => c.id === "dashboard_testing");
|
||||
expect(testing?.subItems.map((i: { path: string }) => i.path)).toEqual(["/dashboards/health"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -116,7 +116,6 @@ const SIDEBAR_SECTIONS: SectionDef[] = [
|
||||
requiredAction: "READ",
|
||||
subItems: [
|
||||
{ labelKey: "overview", path: "/dashboards", requiredPermission: "plugin:migration", requiredAction: "READ" },
|
||||
{ labelKey: "health_center", path: "/dashboards/health", requiredPermission: "plugin:migration", requiredAction: "READ", requiredFeature: "health_monitor" },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -188,8 +187,9 @@ const SIDEBAR_SECTIONS: SectionDef[] = [
|
||||
labelKey: "dashboard_testing",
|
||||
icon: "clipboard",
|
||||
tone: "from-category-testing-from to-category-testing-to text-category-testing-text ring-category-testing-ring",
|
||||
path: "/dashboard-testing",
|
||||
path: "/dashboards/health",
|
||||
subItems: [
|
||||
{ labelKey: "health_center", path: "/dashboards/health", requiredPermission: "plugin:migration", requiredAction: "READ", requiredFeature: "health_monitor" },
|
||||
{ labelKey: "dt_scenarios", path: "/dashboard-testing/scenarios", requiredPermission: "dashboard:testing", requiredAction: "READ" },
|
||||
{ labelKey: "dt_runs", path: "/dashboard-testing/runs", requiredPermission: "scenario", requiredAction: "RUN" },
|
||||
{ labelKey: "dt_analytics", path: "/dashboard-testing/analytics", requiredPermission: "scenario:result", requiredAction: "VIEW" },
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
"deploy_dashboard": "🚀 Deploy dashboard",
|
||||
"execute_migration": "🔄 Run migration",
|
||||
"run_backup": "💾 Backup",
|
||||
"run_llm_validation": "🤖 LLM validation",
|
||||
"run_llm_documentation": "📄 Generate documentation",
|
||||
"start_maintenance": "🛠 Start maintenance",
|
||||
"end_maintenance": "✅ End maintenance"
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
"deploy_dashboard": "🚀 Деплой дашборда",
|
||||
"execute_migration": "🔄 Миграция дашборда",
|
||||
"run_backup": "💾 Бэкап",
|
||||
"run_llm_validation": "🤖 LLM-валидация",
|
||||
"run_llm_documentation": "📄 Генерация документации",
|
||||
"start_maintenance": "🛠 Запуск обслуживания",
|
||||
"end_maintenance": "✅ Завершение обслуживания"
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
<!-- Schedules (compact) -->
|
||||
<div class="mt-5">
|
||||
<ScenarioScheduleGlance />
|
||||
<ScenarioScheduleGlance environmentId={m.selectedEnvId} />
|
||||
</div>
|
||||
|
||||
<!-- Dashboard Cards -->
|
||||
|
||||
@@ -50,6 +50,7 @@ describe('Dashboard health page contract', () => {
|
||||
expect(source).toContain('m.healthData');
|
||||
// Model imports healthStore
|
||||
expect(modelSource).toContain("import { healthStore } from '$lib/stores/health.svelte.js';");
|
||||
expect(source).toContain('<ScenarioScheduleGlance environmentId={m.selectedEnvId} />');
|
||||
expect(modelSource).toContain('? getHealthSummary(this.selectedEnvId)');
|
||||
expect(modelSource).toContain(': healthStore.refresh();');
|
||||
});
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
"env_id": "ss-dev"
|
||||
},
|
||||
"expected": {
|
||||
"tool_count": 9,
|
||||
"tool_names": ["search_dashboards", "get_health_summary", "deploy_dashboard", "run_llm_validation", "run_llm_documentation", "execute_migration", "create_branch", "commit_changes", "show_capabilities"],
|
||||
"tool_count": 8,
|
||||
"tool_names": ["search_dashboards", "get_health_summary", "deploy_dashboard", "run_llm_documentation", "execute_migration", "create_branch", "commit_changes", "show_capabilities"],
|
||||
"uicontext_injected": true,
|
||||
"runtime_context_contains": ["[USER CONTEXT]", "Отчёт по энергопотреблению", "dashboards/42"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user