feat: add task and habit reordering
ci / docker (push) Successful in 3m33s

This commit is contained in:
2026-09-08 06:51:31 +08:00
parent a02b6f660c
commit 988d131d9b
13 changed files with 329 additions and 22 deletions
+23
View File
@@ -75,6 +75,29 @@ def test_recurrence_rejects_occurrence_after_cutoff(client):
).status_code == 422
def test_habit_reorder_persists_in_lists_and_grid(client):
boot(client)
first = client.post("/api/v1/habits", json={"name": "第一个", "kind": "boolean", "schedule_type": "daily"}).json()
second = client.post("/api/v1/habits", json={"name": "第二个", "kind": "boolean", "schedule_type": "daily"}).json()
response = client.put("/api/v1/habits/reorder", json={"habit_ids": [second["id"], first["id"]]})
assert response.status_code == 204
client.post("/api/v1/habits", json={"name": "第三个", "kind": "boolean", "schedule_type": "daily"})
assert [habit["name"] for habit in client.get("/api/v1/habits").json()] == ["第二个", "第一个", "第三个"]
grid = client.get("/api/v1/habits/grid", params={"week": "2026-09-07"}).json()
assert [habit["name"] for habit in grid["habits"]] == ["第二个", "第一个", "第三个"]
def test_habit_reorder_rejects_foreign_or_missing_ids(client):
boot(client)
habit = client.post("/api/v1/habits", json={"name": "自己的习惯", "kind": "boolean", "schedule_type": "daily"}).json()
response = client.put(
"/api/v1/habits/reorder",
json={"habit_ids": [habit["id"], "00000000-0000-0000-0000-000000000001"]},
)
assert response.status_code == 404
def test_habit_logs_support_date_range_filter(client):
boot(client)
habit = client.post("/api/v1/habits", json={"name": "跑步", "kind": "boolean", "schedule_type": "daily"}).json()