Some checks failed
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled
Schliesst den Backlog/Epic-Track mit kernel-basiertem Fortschritt pro Epic, Steuerungs-Attention und UI-Fortschrittsanzeige im Plan-Eingang ab. Co-authored-by: Cursor <cursoragent@cursor.com>
142 lines
4.1 KiB
Python
142 lines
4.1 KiB
Python
"""AP2.2h — Epic Roll-up Read Model (ADP P4)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tests.factories import provision_user_in_tenant
|
|
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
|
|
|
|
|
def _create_product_initiative(client, token, title="Epic Rollup"):
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title=title,
|
|
archetype_key="initiative.product",
|
|
)
|
|
assert created.status_code == 201
|
|
return created.json()["id"]
|
|
|
|
|
|
def test_steering_snapshot_includes_epic_rollup(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
initiative_id = _create_product_initiative(client, token)
|
|
|
|
epic = client.post(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
json={"title": "Checkout Epic", "item_kind": "epic", "status": "accepted"},
|
|
headers=_auth(token),
|
|
)
|
|
epic_id = epic.json()["id"]
|
|
|
|
story_a = client.post(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
json={
|
|
"title": "Login Story",
|
|
"item_kind": "story",
|
|
"parent_backlog_id": epic_id,
|
|
"status": "accepted",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
story_a_id = story_a.json()["id"]
|
|
|
|
client.post(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
json={
|
|
"title": "Payment Story",
|
|
"item_kind": "story",
|
|
"parent_backlog_id": epic_id,
|
|
"status": "accepted",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
|
|
converted = client.post(
|
|
f"/api/backlog/{story_a_id}/convert-to-action",
|
|
json={},
|
|
headers=_auth(token),
|
|
)
|
|
assert converted.status_code == 201
|
|
action_id = converted.json()["action"]["id"]
|
|
|
|
done = client.patch(
|
|
f"/api/actions/{action_id}",
|
|
json={"status": "done"},
|
|
headers=_auth(token),
|
|
)
|
|
assert done.status_code == 200
|
|
|
|
snapshot = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snapshot.status_code == 200
|
|
body = snapshot.json()
|
|
assert "epic_rollup" in body
|
|
assert len(body["epic_rollup"]) == 1
|
|
|
|
rollup = body["epic_rollup"][0]
|
|
assert rollup["epic_backlog_id"] == epic_id
|
|
assert rollup["child_total"] == 2
|
|
assert rollup["child_uncommitted"] == 1
|
|
assert rollup["child_committed"] == 1
|
|
assert rollup["actions_done"] == 1
|
|
assert rollup["status"] == "in_progress"
|
|
assert rollup["completion_ratio"] == 0.5
|
|
|
|
|
|
def test_steering_snapshot_epic_attention_awaiting_commit(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
initiative_id = _create_product_initiative(client, token, title="Epic Attention")
|
|
|
|
epic = client.post(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
json={"title": "Epic", "item_kind": "epic", "status": "accepted"},
|
|
headers=_auth(token),
|
|
)
|
|
epic_id = epic.json()["id"]
|
|
|
|
client.post(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
json={
|
|
"title": "Story",
|
|
"item_kind": "story",
|
|
"parent_backlog_id": epic_id,
|
|
"status": "accepted",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
|
|
snapshot = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snapshot.status_code == 200
|
|
attention_codes = [
|
|
item.get("code") or item.get("reason_code")
|
|
for item in snapshot.json().get("attention_items", [])
|
|
]
|
|
assert "epic_awaiting_commit" in attention_codes
|
|
|
|
|
|
def test_linear_initiative_has_no_epic_rollup(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Linear Rollup",
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
snapshot = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snapshot.status_code == 200
|
|
assert snapshot.json().get("epic_rollup") == []
|