Halte Kapitel am gewaehlten Vorgang fest und raeume die Arbeitsflaeche, damit Ziel, Auswahl und Rechte nicht an der Akte haengen bleiben.
Deploy Development / deploy (push) Successful in 23s
Test Suite / pytest-backend (push) Successful in 1m1s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 5s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 11:33:54 +02:00
1 parent 67d48378c9
commit cafa4e8b92
8 files changed
+523 -132

No files matched your search

+96
View File
@@ -413,6 +413,102 @@ def test_teilvorgang_keeps_its_parent_in_the_trail(client, db):
assert contained["Prüfung"]["bindings"][0]["element"]["title"] == "Einwendung"
def test_chapters_follow_the_container_not_the_entry(client, db):
ada = Actor(client, "ada-ziel@example.test", "Ada Ziel")
ben = Actor(client, "ben-ziel@example.test", "Ben Ziel")
register(db, ada.email, ada.name)
register(db, ben.email, ben.name)
ada.login()
case = case_of(ada, "Wohnung")
matter = matter_of(ada, "Nebenkosten 2025")
child = ada.request(
"POST",
"/api/v1/matters",
json={"title": "Belegeinsicht", "parent_matter_id": matter["id"]},
status=201,
)
ada.request("POST", f"/api/v1/matters/{matter['id']}/case-links", json={"case_id": case["id"]}, status=201)
case_chapter = ada.request("POST", f"/api/v1/cases/{case['id']}/chapters", json={"title": "Aktenkapitel"}, status=201)
abrechnung = ada.request("POST", f"/api/v1/matters/{matter['id']}/chapters", json={"title": "Abrechnung"}, status=201)
schrift = ada.request("POST", f"/api/v1/matters/{matter['id']}/chapters", json={"title": "Schriftverkehr"}, status=201)
belege = ada.request(
"POST",
f"/api/v1/matters/{child['id']}/chapters?context_kind=case&context_id={case['id']}",
json={"title": "Belege"},
status=201,
)
ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Abrechnungsschreiben",
"document": document("Abrechnungstext"),
"context": {"kind": "matter", "id": matter["id"]},
"chapter_id": abrechnung["id"],
},
status=201,
)
ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Einwendung",
"document": document("Einwendungstext"),
"context": {"kind": "matter", "id": child["id"]},
"chapter_id": belege["id"],
},
status=201,
)
ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Fremdes Kapitel",
"document": document("nein"),
"context": {"kind": "matter", "id": matter["id"]},
"chapter_id": case_chapter["id"],
},
status=422,
)
direct = _matter(ada, matter["id"])
via_case = ada.request("GET", f"/api/v1/matters/{matter['id']}?context_kind=case&context_id={case['id']}")
assert [item["title"] for item in direct["chapters"]] == ["Abrechnung", "Schriftverkehr"]
assert [item["id"] for item in via_case["chapters"]] == [item["id"] for item in direct["chapters"]]
assert via_case["context"]["kind"] == "case"
child_view = ada.request("GET", f"/api/v1/matters/{child['id']}?context_kind=case&context_id={case['id']}")
assert [item["title"] for item in child_view["chapters"]] == ["Belege"]
case_view = ada.request("GET", f"/api/v1/cases/{case['id']}")
assert [item["title"] for item in case_view["chapters"]] == ["Aktenkapitel"]
contained = {item["title"]: item for item in case_view["contained"]}
assert [item["title"] for item in contained["Nebenkosten 2025"]["chapters"]] == ["Abrechnung", "Schriftverkehr"]
assert [item["title"] for item in contained["Belegeinsicht"]["chapters"]] == ["Belege"]
binding = binding_for(direct, "Abrechnungsschreiben")
before = len(direct["bindings"])
ada.request(
"PATCH",
f"/api/v1/bindings/{binding['id']}/chapter",
json={"expected_version": direct["version"], "chapter_id": schrift["id"]},
)
moved = _matter(ada, matter["id"])
assert binding_for(moved, "Abrechnungsschreiben")["chapter_id"] == schrift["id"]
assert binding_for(moved, "Abrechnungsschreiben")["element"]["excerpt"] == "Abrechnungstext"
assert len(moved["bindings"]) == before
grant(ada, case["id"], ben.email)
ben.login()
ben.request(
"POST",
f"/api/v1/matters/{matter['id']}/chapters?context_kind=case&context_id={case['id']}",
json={"title": "Unerlaubt"},
status=403,
)
ben.request(
"PATCH",
f"/api/v1/bindings/{binding['id']}/chapter",
json={"expected_version": moved["version"], "chapter_id": abrechnung["id"], "context": {"kind": "case", "id": case["id"]}},
status=403,
)
_PNG = bytes.fromhex(
"89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c489"
"0000000a49444154789c63000100000500010d0a2db40000000049454e44ae426082"