Some checks failed
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 4m46s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Activity Set pro Stufe statt Gate-Titel-Recurring; Single-Active-Stufe bei Reopen; Complete heute schliesst Next Action; Heute-Panel fuer alle Uebungen der aktiven Stufe. Co-authored-by: Cursor <cursoragent@cursor.com>
109 lines
3.3 KiB
Python
109 lines
3.3 KiB
Python
"""AP A1.1 — CadenceInstance complete practice flow."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tests.factories import provision_user_in_tenant
|
|
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
|
|
|
|
|
def test_complete_daily_practice_advances_cadence(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Spagat Cadence",
|
|
archetype_key="initiative.maturity_journey",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
recurring = client.get(
|
|
f"/api/initiatives/{initiative_id}/recurring",
|
|
headers=_auth(token),
|
|
).json()
|
|
assert recurring
|
|
item = recurring[0]
|
|
assert item.get("open_cadence_instance")
|
|
assert item["open_cadence_instance"]["status"] == "open"
|
|
recurring_id = item["id"]
|
|
|
|
completed = client.post(
|
|
f"/api/recurring/{recurring_id}/complete",
|
|
json={"measurement_note": "45° Spagat gehalten"},
|
|
headers=_auth(token),
|
|
)
|
|
assert completed.status_code == 200
|
|
body = completed.json()
|
|
assert body["completed_instance"]["status"] == "completed"
|
|
assert body["completed_instance"]["measurement_note"] == "45° Spagat gehalten"
|
|
assert body["next_due_at"]
|
|
assert body["recurring"]["next_due_at"]
|
|
|
|
refreshed = client.get(
|
|
f"/api/initiatives/{initiative_id}/recurring",
|
|
headers=_auth(token),
|
|
).json()
|
|
assert refreshed[0]["today_completed"] is True
|
|
assert refreshed[0]["today_measurement_note"] == "45° Spagat gehalten"
|
|
|
|
|
|
def test_steering_next_action_includes_recurring_id(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Spagat Next",
|
|
archetype_key="initiative.maturity_journey",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
snap = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snap.status_code == 200
|
|
next_actions = snap.json().get("next_actions") or []
|
|
recurring_items = [a for a in next_actions if a.get("kind") == "recurring_due"]
|
|
assert recurring_items
|
|
assert recurring_items[0].get("recurring_id")
|
|
|
|
|
|
def test_steering_next_action_excludes_completed_today(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Spagat Complete Today",
|
|
archetype_key="initiative.maturity_journey",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
recurring = client.get(
|
|
f"/api/initiatives/{initiative_id}/recurring",
|
|
headers=_auth(token),
|
|
).json()
|
|
recurring_id = recurring[0]["id"]
|
|
|
|
completed = client.post(
|
|
f"/api/recurring/{recurring_id}/complete",
|
|
json={"measurement_note": "done"},
|
|
headers=_auth(token),
|
|
)
|
|
assert completed.status_code == 200
|
|
|
|
snap = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snap.status_code == 200
|
|
next_actions = snap.json().get("next_actions") or []
|
|
completed_again = [
|
|
a for a in next_actions if a.get("recurring_id") == recurring_id
|
|
]
|
|
assert not completed_again
|