def test_integration_status_requires_operations_manager(employee_client): response = employee_client.get("/api/v1/integrations/status") assert response.status_code == 403 def test_integration_status_requires_authentication(client): response = client.get("/api/v1/integrations/status") assert response.status_code == 401 def test_integration_status_reflects_seeded_mixed_outcomes(ops_client): response = ops_client.get("/api/v1/integrations/status") assert response.status_code == 200 body = response.json() n8n = body["n8n"] assert n8n["dispatch_enabled"] is True assert n8n["succeeded"] >= 1 assert n8n["failed"] >= 1 # The seed deliberately carries both failed and succeeded events, so a single most- # recent-event read would misreport health -- the aggregate must call this "degraded", # not "operational" or "unavailable". assert n8n["state"] == "degraded" assert n8n["latest_success_at"] is not None assert n8n["latest_failure_at"] is not None mcp_hub = body["mcp_hub"] assert mcp_hub["registration_enabled"] is False assert mcp_hub["state"] == "not_configured" def test_integration_status_is_operational_once_all_failed_events_resolved(ops_client): failed = ops_client.get("/api/v1/workflows", params={"status": "failed"}).json() for run in failed: retried = ops_client.post(f"/api/v1/workflows/{run['event_id']}/retry") assert retried.status_code == 200 response = ops_client.get("/api/v1/integrations/status") body = response.json()["n8n"] assert body["failed"] == 0 assert body["state"] == "operational"