Kairo-Jinkendo/backend/tests/test_ap20e_maturity_transition.py
Lars 192a65a798
All checks were successful
Deploy Development / deploy (push) Successful in 1m1s
Test Suite / pytest-backend (push) Successful in 4m43s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 16s
fix(A1): enforce_single_active via roadmaps join (pytest)
roadmap_items hat kein initiative_id — Single-Active-Update join auf roadmaps. test_ap20e an Uebungssets angepasst.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 13:46:54 +02:00

66 lines
2.0 KiB
Python

"""AP2.0e — maturity stage transition on verify reached."""
from __future__ import annotations
from tests.factories import provision_user_in_tenant
from tests.test_initiatives_actions import _auth, _login
def test_maturity_stage_reached_rotates_recurring(client):
user = provision_user_in_tenant(tenant_role="admin")
token = _login(client, user)
created = client.post(
"/api/initiatives",
json={
"title": "Spagat Test",
"archetype_key": "initiative.maturity_journey",
},
headers=_auth(token),
)
assert created.status_code == 201
initiative_id = created.json()["id"]
items = client.get(
f"/api/initiatives/{initiative_id}/roadmap/items",
headers=_auth(token),
).json()
stage1 = next(i for i in items if i["title"] == "Stufe 1 — Basis")
client.post(
f"/api/initiatives/{initiative_id}/evidence",
json={
"title": "Stufe 1 geschafft",
"roadmap_item_id": stage1["id"],
"status": "accepted",
},
headers=_auth(token),
)
verify = client.post(
f"/api/roadmap-items/{stage1['id']}/verify-reached",
headers=_auth(token),
)
assert verify.status_code == 200
body = verify.json()
assert body["status"] == "reached"
assert body.get("maturity_transition", {}).get("new_recurring_id")
recurring = client.get(
f"/api/initiatives/{initiative_id}/recurring",
headers=_auth(token),
).json()
titles = {r["title"]: r["status"] for r in recurring}
assert titles.get("Vorbeuge-Dehnung") == "paused"
assert titles.get("Hüftöffner (Schmetterling)") == "paused"
assert any(
t.startswith("Seitlicher Spagat") and titles[t] == "active" for t in titles
)
items_after = client.get(
f"/api/initiatives/{initiative_id}/roadmap/items",
headers=_auth(token),
).json()
stage2 = next(i for i in items_after if i["title"] == "Stufe 2 — Aufbau")
assert stage2["status"] == "active"