fix: reset subtasks for recurring tasks
This commit is contained in:
@@ -134,6 +134,47 @@ def test_completing_repeating_task_advances_due_date_instead_of_closing_it(clien
|
||||
assert recurrence["starts_at"].replace("Z", "") == "2026-09-08T09:00:00"
|
||||
|
||||
|
||||
def test_completing_repeating_task_resets_completed_subtasks_for_next_occurrence(client):
|
||||
inbox = boot(client)
|
||||
parent = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={
|
||||
"title": "每日清理",
|
||||
"list_id": inbox["id"],
|
||||
"due_at": "2026-09-07T09:00:00Z",
|
||||
"rrule": "FREQ=DAILY",
|
||||
},
|
||||
).json()
|
||||
first = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={"title": "清理下载", "list_id": inbox["id"], "parent_id": parent["id"]},
|
||||
).json()
|
||||
second = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={"title": "清理缓存", "list_id": inbox["id"], "parent_id": parent["id"]},
|
||||
).json()
|
||||
for child in (first, second):
|
||||
response = client.patch(
|
||||
f"/api/v1/tasks/{child['id']}",
|
||||
json={"completed": True, "version": child["version"]},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
completed = client.patch(
|
||||
f"/api/v1/tasks/{parent['id']}",
|
||||
json={"completed": True, "version": parent["version"]},
|
||||
)
|
||||
|
||||
assert completed.status_code == 200
|
||||
assert completed.json()["completed"] is False
|
||||
assert completed.json()["due_at"].replace("Z", "") == "2026-09-08T09:00:00"
|
||||
assert [child["completed"] for child in completed.json()["subtasks"]] == [False, False]
|
||||
listed = client.get("/api/v1/tasks", params={"list_id": inbox["id"], "page": 1}).json()["items"]
|
||||
repeated = next(task for task in listed if task["id"] == parent["id"])
|
||||
assert [child["completed"] for child in repeated["subtasks"]] == [False, False]
|
||||
|
||||
|
||||
|
||||
def test_recurrence_mutations_keep_exact_timestamp_validation(client):
|
||||
inbox = boot(client)
|
||||
task = client.post(
|
||||
|
||||
Reference in New Issue
Block a user