feat: simplify className prop in StatusDot and refactor conditional check in tasks.py
This commit is contained in:
@@ -184,9 +184,7 @@ def _coerce_task_event_rows(
|
|||||||
msg = "Expected (ActivityEvent, Task | None) rows"
|
msg = "Expected (ActivityEvent, Task | None) rows"
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
if isinstance(first, ActivityEvent) and (
|
if isinstance(first, ActivityEvent) and (isinstance(second, Task) or second is None):
|
||||||
isinstance(second, Task) or second is None
|
|
||||||
):
|
|
||||||
rows.append((first, second))
|
rows.append((first, second))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from fastapi.testclient import TestClient
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
|
|
||||||
|
from app.core import error_handling
|
||||||
from app.core.error_handling import (
|
from app.core.error_handling import (
|
||||||
REQUEST_ID_HEADER,
|
REQUEST_ID_HEADER,
|
||||||
_error_payload,
|
_error_payload,
|
||||||
@@ -111,6 +112,60 @@ def test_client_provided_request_id_is_preserved():
|
|||||||
assert resp.headers.get(REQUEST_ID_HEADER) == "req-123"
|
assert resp.headers.get(REQUEST_ID_HEADER) == "req-123"
|
||||||
|
|
||||||
|
|
||||||
|
def test_slow_request_emits_slow_log(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
warnings: list[tuple[str, dict[str, object]]] = []
|
||||||
|
|
||||||
|
def _fake_warning(message: str, *args: object, **kwargs: object) -> None:
|
||||||
|
_ = args
|
||||||
|
extra = kwargs.get("extra")
|
||||||
|
warnings.append((message, extra if isinstance(extra, dict) else {}))
|
||||||
|
|
||||||
|
perf_ticks = iter((100.0, 100.2))
|
||||||
|
|
||||||
|
def _fake_perf_counter() -> float:
|
||||||
|
return next(perf_ticks)
|
||||||
|
|
||||||
|
monkeypatch.setattr(error_handling.settings, "request_log_slow_ms", 1)
|
||||||
|
monkeypatch.setattr(error_handling, "perf_counter", _fake_perf_counter)
|
||||||
|
monkeypatch.setattr(error_handling.logger, "warning", _fake_warning)
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
install_error_handling(app)
|
||||||
|
|
||||||
|
@app.get("/slow")
|
||||||
|
def slow() -> dict[str, str]:
|
||||||
|
return {"ok": "1"}
|
||||||
|
|
||||||
|
client = TestClient(app)
|
||||||
|
resp = client.get("/slow")
|
||||||
|
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert any(
|
||||||
|
message == "http.request.slow" and extra.get("slow_threshold_ms") == 1
|
||||||
|
for message, extra in warnings
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_health_route_skips_request_logs_when_disabled(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
) -> None:
|
||||||
|
monkeypatch.setattr(error_handling.settings, "request_log_include_health", False)
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
install_error_handling(app)
|
||||||
|
|
||||||
|
@app.get("/healthz")
|
||||||
|
def healthz() -> dict[str, str]:
|
||||||
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
client = TestClient(app)
|
||||||
|
resp = client.get("/healthz")
|
||||||
|
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert resp.json() == {"status": "ok"}
|
||||||
|
assert isinstance(resp.headers.get(REQUEST_ID_HEADER), str)
|
||||||
|
|
||||||
|
|
||||||
def test_get_request_id_returns_none_for_missing_or_invalid_state() -> None:
|
def test_get_request_id_returns_none_for_missing_or_invalid_state() -> None:
|
||||||
# Empty state
|
# Empty state
|
||||||
req = Request({"type": "http", "headers": [], "state": {}})
|
req = Request({"type": "http", "headers": [], "state": {}})
|
||||||
|
|||||||
@@ -582,9 +582,7 @@ export function BoardApprovalsPanel({
|
|||||||
<StatusDot
|
<StatusDot
|
||||||
status={selectedApproval.status}
|
status={selectedApproval.status}
|
||||||
variant="approval"
|
variant="approval"
|
||||||
className={cn(
|
className={cn("h-2 w-2 rounded-full")}
|
||||||
"h-2 w-2 rounded-full",
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-[11px] font-semibold uppercase tracking-[0.2em] text-slate-500">
|
<p className="text-[11px] font-semibold uppercase tracking-[0.2em] text-slate-500">
|
||||||
|
|||||||
Reference in New Issue
Block a user