fix(coroner): playbook-kind postmortems stop rendering dead buttons

A kind=playbook process change drafts into the playbook queue at propose
time and both approve/reject refuse it - but legacy rows carry no marker
status, so the response defaulted to proposed and the panel rendered
approve/dismiss buttons that bounce forever. The list route now derives
not_applicable for playbook-kind changes regardless of stored status,
which the panel already renders as its Drafted-as-playbook badge.
This commit is contained in:
Renn F
2026-07-29 05:50:20 +02:00
parent 87332346ce
commit 1c3c313c1e
3 changed files with 36 additions and 5 deletions
+22
View File
@@ -200,6 +200,28 @@ async def test_list_postmortems_returns_completed_autopsy(
assert row["failed_stage"] == "awaiting_qa"
@pytest.mark.asyncio
async def test_list_postmortems_derives_not_applicable_for_playbook_kind(
db_session: AsyncSession, ceo_client: AsyncClient
) -> None:
"""A playbook-kind process change reads as not_applicable even when the
stored marker has NO status key — legacy rows predate the propose-time
stamp, and the raw default ("proposed") left the panel rendering
approve/dismiss buttons both verbs refuse forever."""
task = await _seed_completed_postmortem(db_session)
payload = markers.get_coroner_postmortem(task)
assert payload is not None
payload["process_change"] = {
"kind": "playbook",
"description": "run the named command end-to-end",
}
markers.set_coroner_postmortem(task, payload)
await db_session.flush()
resp = await ceo_client.get("/api/coroner/postmortems")
assert resp.status_code == HTTPStatus.OK
assert resp.json()[0]["process_change_status"] == "not_applicable"
@pytest.mark.asyncio
async def test_list_postmortems_forbidden_for_non_ceo(
dev_client: AsyncClient,