AP1.13b: Gate-Abhaengigkeiten auf der Detailseite pflegen.
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 2m11s
Test Suite / lint-backend (push) Successful in 3s
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 12s

DELETE fuer Roadmap-Kanten, Duplikat-Schutz beim Anlegen, GateDependenciesSection mit ausgehenden/eingehenden Kanten auf der Gate-Detailseite.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-10 15:53:03 +02:00
1 parent 7f03504c2d
commit 7cd8f4b90e
9 files changed
+385 -5

No files matched your search

+1
View File
@@ -98,6 +98,7 @@ app.include_router(backlog.router)
app.include_router(milestones.router)
app.include_router(roadmap.initiative_router)
app.include_router(roadmap.items_router)
app.include_router(roadmap.deps_router)
app.include_router(roadmap.criteria_router)
app.include_router(evidence.router)
app.include_router(decisions.router)
+16
View File
@@ -81,6 +81,7 @@ class ReopenRequest(BaseModel):
initiative_router = APIRouter(prefix="/api/initiatives", tags=["roadmap"])
items_router = APIRouter(prefix="/api/roadmap-items", tags=["roadmap"])
deps_router = APIRouter(prefix="/api/roadmap-dependencies", tags=["roadmap"])
@initiative_router.get("/{initiative_id}/roadmap")
@@ -270,6 +271,21 @@ def create_roadmap_item_criterion(
raise HTTPException(status_code=400, detail=str(exc)) from exc
@deps_router.delete("/{dependency_id}", status_code=204)
def delete_roadmap_dependency(
dependency_id: str,
ctx: TenantContext = Depends(require_capability("kairo.milestone.manage")),
):
try:
roadmap_service.delete_dependency(
tenant_id=ctx.tenant_id,
dependency_id=dependency_id,
user_id=ctx.user_id,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
criteria_router = APIRouter(prefix="/api/roadmap-criteria", tags=["roadmap"])
+54
View File
@@ -542,6 +542,17 @@ def add_dependency(
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute(
"""
SELECT 1 FROM roadmap_item_dependencies
WHERE tenant_id = %s AND from_item_id = %s AND to_item_id = %s
AND dependency_type = %s
""",
(tenant_id, from_item_id, to_item_id, dependency_type),
)
if cur.fetchone():
raise ValueError("Abhängigkeit existiert bereits")
cur.execute(
"""
INSERT INTO roadmap_item_dependencies (
@@ -573,6 +584,49 @@ def add_dependency(
return row
def delete_dependency(
*, tenant_id: str, dependency_id: str, user_id: Optional[str] = None
) -> bool:
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute(
"""
SELECT id, from_item_id, to_item_id, dependency_type
FROM roadmap_item_dependencies
WHERE id = %s AND tenant_id = %s
""",
(dependency_id, tenant_id),
)
row = cur.fetchone()
if not row:
raise ValueError("Abhängigkeit nicht gefunden")
cur.execute(
"""
DELETE FROM roadmap_item_dependencies
WHERE id = %s AND tenant_id = %s
""",
(dependency_id, tenant_id),
)
conn.commit()
finally:
conn.close()
log_audit(
"roadmap_item.dependency_removed",
user_id=user_id,
tenant_id=tenant_id,
details={
"dependency_id": dependency_id,
"from_item_id": str(row["from_item_id"]),
"to_item_id": str(row["to_item_id"]),
"dependency_type": row["dependency_type"],
},
)
return True
def verify_reached(
*, tenant_id: str, item_id: str, user_id: Optional[str] = None
) -> dict[str, Any]:
+50
View File
@@ -146,3 +146,53 @@ def test_initiative_roadmap_dependencies_list(client):
assert deps[0]["from_item_id"] == gate_a["id"]
assert deps[0]["to_item_id"] == gate_b["id"]
assert deps[0]["dependency_type"] == "requires"
def test_roadmap_dependency_delete(client):
user = provision_user_in_tenant(tenant_role="member")
token = _login(client, user)
initiative_id = _create_initiative(client, token).json()["id"]
gate_a = _create_roadmap_item(client, token, initiative_id, title="Gate A").json()
gate_b = _create_roadmap_item(client, token, initiative_id, title="Gate B").json()
created = client.post(
f"/api/roadmap-items/{gate_a['id']}/dependencies",
json={"to_item_id": gate_b["id"], "dependency_type": "requires"},
headers=_auth(token),
)
dep_id = created.json()["id"]
deleted = client.delete(
f"/api/roadmap-dependencies/{dep_id}",
headers=_auth(token),
)
assert deleted.status_code == 204
listed = client.get(
f"/api/initiatives/{initiative_id}/roadmap/dependencies",
headers=_auth(token),
)
assert listed.json() == []
def test_roadmap_dependency_duplicate_rejected(client):
user = provision_user_in_tenant(tenant_role="member")
token = _login(client, user)
initiative_id = _create_initiative(client, token).json()["id"]
gate_a = _create_roadmap_item(client, token, initiative_id, title="Gate A").json()
gate_b = _create_roadmap_item(client, token, initiative_id, title="Gate B").json()
body = {"to_item_id": gate_b["id"], "dependency_type": "requires"}
assert client.post(
f"/api/roadmap-items/{gate_a['id']}/dependencies",
json=body,
headers=_auth(token),
).status_code == 201
dup = client.post(
f"/api/roadmap-items/{gate_a['id']}/dependencies",
json=body,
headers=_auth(token),
)
assert dup.status_code == 400
assert "existiert bereits" in dup.json()["detail"]