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>
140 lines
4.2 KiB
Python
140 lines
4.2 KiB
Python
"""AP2.2a — Archetyp Starter-Kits."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tests.factories import provision_user_in_tenant
|
|
from tests.test_initiatives_actions import _auth, _login
|
|
|
|
|
|
def test_starter_preview_a2(client):
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
token = _login(client, user)
|
|
|
|
resp = client.get(
|
|
"/api/entity-archetypes/initiative.linear_project/starter-preview",
|
|
headers=_auth(token),
|
|
)
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["supported"] is True
|
|
assert body["method_key"] == "sequential_dependency"
|
|
assert any(item["kind"] == "milestone" for item in body["items"])
|
|
|
|
|
|
def test_create_initiative_a1_applies_starter_kit(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = client.post(
|
|
"/api/initiatives",
|
|
json={
|
|
"title": "Test Spagat",
|
|
"archetype_key": "initiative.maturity_journey",
|
|
"apply_starter_kit": True,
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
assert created.status_code == 201
|
|
initiative_id = created.json()["id"]
|
|
assert created.json()["starter_kit"]["applied"] is True
|
|
|
|
roadmap = client.get(
|
|
f"/api/initiatives/{initiative_id}/roadmap/items",
|
|
headers=_auth(token),
|
|
)
|
|
assert roadmap.status_code == 200
|
|
titles = {item["title"] for item in roadmap.json()}
|
|
assert "Stufe 1 — Basis" in titles
|
|
|
|
recurring = client.get(
|
|
f"/api/initiatives/{initiative_id}/recurring",
|
|
headers=_auth(token),
|
|
)
|
|
assert recurring.status_code == 200
|
|
assert any(r["title"] == "Vorbeuge-Dehnung" for r in recurring.json())
|
|
assert any(r["roadmap_item_id"] for r in recurring.json())
|
|
|
|
|
|
def test_create_initiative_b2b_starter_kit(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = client.post(
|
|
"/api/initiatives",
|
|
json={
|
|
"title": "Test Product",
|
|
"archetype_key": "initiative.product",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
assert created.status_code == 201
|
|
initiative_id = created.json()["id"]
|
|
|
|
backlog = client.get(
|
|
f"/api/initiatives/{initiative_id}/backlog",
|
|
headers=_auth(token),
|
|
)
|
|
assert backlog.status_code == 200
|
|
assert any(b["title"] == "Idee / Issue" for b in backlog.json())
|
|
|
|
projects = client.get(
|
|
f"/api/initiatives/{initiative_id}/projects",
|
|
headers=_auth(token),
|
|
)
|
|
assert projects.status_code == 200
|
|
titles = {p["title"] for p in projects.json()}
|
|
assert "Entwicklung" in titles
|
|
assert "Betrieb" in titles
|
|
|
|
|
|
def test_create_initiative_a2_starter_kit_includes_action(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = client.post(
|
|
"/api/initiatives",
|
|
json={
|
|
"title": "Test Projekt",
|
|
"archetype_key": "initiative.linear_project",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
assert created.status_code == 201
|
|
initiative_id = created.json()["id"]
|
|
assert created.json()["starter_kit"]["applied"] is True
|
|
|
|
actions = client.get(
|
|
f"/api/initiatives/{initiative_id}/actions",
|
|
headers=_auth(token),
|
|
)
|
|
assert actions.status_code == 200
|
|
assert any(
|
|
a["title"] == "Erster Schritt — Planung konkretisieren" for a in actions.json()
|
|
)
|
|
|
|
|
|
def test_starter_kit_skipped_when_structure_exists(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = client.post(
|
|
"/api/initiatives",
|
|
json={
|
|
"title": "Kit Once",
|
|
"archetype_key": "initiative.linear_project",
|
|
},
|
|
headers=_auth(token),
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
assert created.json()["starter_kit"]["applied"] is True
|
|
|
|
from services.archetype_starter_kit import apply_starter_kit
|
|
|
|
again = apply_starter_kit(
|
|
tenant_id=user["tenant_id"],
|
|
initiative_id=initiative_id,
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
assert again["applied"] is False
|
|
assert again["reason"] == "structure_exists"
|