feat: delete habits from detail sheet
ci / gitleaks (push) Successful in 6s
ci / docker (push) Successful in 5m40s

This commit is contained in:
2026-09-08 20:16:25 +08:00
parent 89374f2db9
commit 9db323ac2d
5 changed files with 38 additions and 2 deletions
+16
View File
@@ -272,6 +272,22 @@ def test_habits_numeric_accumulation_pause_archive_grid_and_stats(client):
assert client.get(f"/api/v1/habits/{habit_id}/stats").json()["total"] == 8
def test_habit_permanent_delete_removes_habit_and_history(client):
boot(client)
created = client.post(
"/api/v1/habits",
json={"name": "待删除习惯", "kind": "numeric", "target": 3, "schedule_type": "daily"},
)
habit_id = created.json()["id"]
today = datetime.now(UTC).date().isoformat()
assert client.put(f"/api/v1/habits/{habit_id}/logs/{today}", json={"value": 2}).status_code == 200
assert client.delete(f"/api/v1/habits/{habit_id}/permanent").status_code == 204
assert all(row["id"] != habit_id for row in client.get("/api/v1/habits").json())
assert all(row["id"] != habit_id for row in client.get("/api/v1/habits", params={"archived": True}).json())
assert client.get(f"/api/v1/habits/{habit_id}/stats").status_code == 404
def test_boolean_interval_habit_schedule(client):
boot(client)
habit = client.post(