fix: confirm deletes and restore recreated planning items

This commit is contained in:
2026-04-21 23:43:20 +02:00
parent 5b752ab7c4
commit 26bfa7fb64
4 changed files with 183 additions and 15 deletions
+63
View File
@@ -111,6 +111,16 @@ def test_planning_shows_budgets_and_community_accounts(logged_in_client):
assert b"Auszahlung Person B" in response.data
def test_planning_delete_actions_render_confirmation_hooks(logged_in_client):
response = logged_in_client.get("/planning/2026-04")
assert response.status_code == 200
assert b'data-confirm-submit="Einkommenszeile wirklich l\xc3\xb6schen?' in response.data
assert b'data-confirm-submit="Kategorie wirklich l\xc3\xb6schen?' in response.data
assert b'data-confirm-submit="Konto wirklich l\xc3\xb6schen?' in response.data
assert b'data-confirm-submit="Eintrag wirklich l\xc3\xb6schen?' in response.data
def test_community_account_can_assign_budget_categories(logged_in_client):
community_account = CommunityAccount.query.filter_by(slug="hauptkonto").first()
category = Category.query.filter_by(slug="wohnen").first()
@@ -130,6 +140,59 @@ def test_community_account_can_assign_budget_categories(logged_in_client):
assert category.community_account_id == community_account.id
def test_deleted_category_can_be_created_again(logged_in_client):
create_response = logged_in_client.post(
"/planning/2026-04/categories",
data={"name": "Testbudget", "area": "budget"},
)
assert create_response.status_code == 302
category = Category.query.filter_by(slug="testbudget").first()
original_id = category.id
delete_response = logged_in_client.post(f"/planning/2026-04/categories/{category.id}/delete")
assert delete_response.status_code == 302
recreate_response = logged_in_client.post(
"/planning/2026-04/categories",
data={"name": "Testbudget", "area": "budget"},
)
restored = Category.query.filter_by(slug="testbudget").first()
assert recreate_response.status_code == 302
assert restored.id == original_id
assert restored.is_active is True
def test_deleted_community_account_can_be_created_again(logged_in_client):
create_response = logged_in_client.post(
"/planning/2026-04/community-accounts",
data={"name": "Testkonto", "description": ""},
)
assert create_response.status_code == 302
community_account = CommunityAccount.query.filter_by(slug="testkonto").first()
original_id = community_account.id
delete_response = logged_in_client.post(
f"/planning/2026-04/community-accounts/{community_account.id}/delete"
)
assert delete_response.status_code == 302
recreate_response = logged_in_client.post(
"/planning/2026-04/community-accounts",
data={"name": "Testkonto", "description": "Wieder da"},
)
restored = CommunityAccount.query.filter_by(slug="testkonto").first()
assert recreate_response.status_code == 302
assert restored.id == original_id
assert restored.is_active is True
assert restored.description == "Wieder da"
def test_community_account_rejects_budget_assigned_to_other_account(logged_in_client):
primary_account = CommunityAccount.query.filter_by(slug="hauptkonto").first()
secondary_response = logged_in_client.post(