fix: preserve tasks when archiving lists
This commit is contained in:
+12
-2
@@ -314,15 +314,25 @@ def test_inbox_is_protected_and_deleted_collections_are_hidden(client):
|
||||
task = client.post(
|
||||
"/api/v1/tasks", json={"title": "保留任务", "list_id": task_list["id"]}
|
||||
).json()
|
||||
completed_task = client.post(
|
||||
"/api/v1/tasks", json={"title": "已完成任务", "list_id": task_list["id"]}
|
||||
).json()
|
||||
completed_task = client.patch(
|
||||
f"/api/v1/tasks/{completed_task['id']}",
|
||||
json={"completed": True, "version": completed_task["version"]},
|
||||
).json()
|
||||
assert client.delete(f"/api/v1/lists/{task_list['id']}").status_code == 204
|
||||
assert all(row["id"] != task_list["id"] for row in client.get("/api/v1/lists").json())
|
||||
assert client.get("/api/v1/tasks", params={"q": "保留任务"}).json()["items"] == []
|
||||
assert client.get(f"/api/v1/tasks/{task['id']}").status_code == 404
|
||||
archived = client.get("/api/v1/lists", params={"archived": True})
|
||||
assert archived.status_code == 200
|
||||
assert [row["id"] for row in archived.json()] == [task_list["id"]]
|
||||
assert client.post(f"/api/v1/lists/{task_list['id']}/restore").status_code == 200
|
||||
assert any(row["id"] == task_list["id"] for row in client.get("/api/v1/lists").json())
|
||||
moved = client.get(f"/api/v1/tasks/{task['id']}").json()
|
||||
assert moved["list_id"] == inbox["id"]
|
||||
restored = client.get("/api/v1/tasks", params={"list_id": task_list["id"]}).json()["items"]
|
||||
assert [row["id"] for row in restored] == [task["id"], completed_task["id"]]
|
||||
assert restored[1]["completed"] is True
|
||||
assert client.delete(f"/api/v1/folders/{folder['id']}").status_code == 204
|
||||
assert client.get("/api/v1/folders").json() == []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user