@@ -29,6 +29,60 @@ def test_bootstrap_returns_navigation_and_current_user(client):
|
||||
|
||||
|
||||
|
||||
def test_get_recurrence_by_task_returns_rule_or_null(client):
|
||||
inbox = boot(client)
|
||||
task = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={"title": "每天复盘", "list_id": inbox["id"], "due_at": "2026-09-07T09:00:00Z"},
|
||||
).json()
|
||||
empty = client.get(f"/api/v1/tasks/{task['id']}/recurrence")
|
||||
assert empty.status_code == 200
|
||||
assert empty.json() is None
|
||||
|
||||
created = client.post(
|
||||
"/api/v1/recurrences", json={"task_id": task["id"], "rrule": "FREQ=DAILY"}
|
||||
).json()
|
||||
found = client.get(f"/api/v1/tasks/{task['id']}/recurrence")
|
||||
assert found.status_code == 200
|
||||
assert found.json()["id"] == created["id"]
|
||||
assert found.json()["rrule"] == "FREQ=DAILY"
|
||||
|
||||
|
||||
def test_export_and_restore_preserve_task_recurrence(client):
|
||||
inbox = boot(client)
|
||||
task = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={"title": "每周整理", "list_id": inbox["id"], "due_at": "2026-09-07T09:00:00Z"},
|
||||
).json()
|
||||
client.post("/api/v1/recurrences", json={"task_id": task["id"], "rrule": "FREQ=WEEKLY"})
|
||||
exported = client.get("/api/v1/export").json()
|
||||
assert exported["recurrences"][0]["task_id"] == task["id"]
|
||||
|
||||
restored = client.post("/api/v1/restore?mode=replace", json=exported)
|
||||
assert restored.status_code == 200
|
||||
restored_task = client.get("/api/v1/tasks", params={"q": "每周整理"}).json()["items"][0]
|
||||
recurrence = client.get(f"/api/v1/tasks/{restored_task['id']}/recurrence").json()
|
||||
assert recurrence["rrule"] == "FREQ=WEEKLY"
|
||||
|
||||
|
||||
def test_completing_repeating_task_advances_due_date_instead_of_closing_it(client):
|
||||
inbox = boot(client)
|
||||
task = client.post(
|
||||
"/api/v1/tasks",
|
||||
json={"title": "每日复盘", "list_id": inbox["id"], "due_at": "2026-09-07T09:00:00Z"},
|
||||
).json()
|
||||
client.post("/api/v1/recurrences", json={"task_id": task["id"], "rrule": "FREQ=DAILY"})
|
||||
|
||||
completed = client.patch(
|
||||
f"/api/v1/tasks/{task['id']}", json={"completed": True, "version": task["version"]}
|
||||
)
|
||||
assert completed.status_code == 200
|
||||
assert completed.json()["completed"] is False
|
||||
assert completed.json()["due_at"].replace("Z", "") == "2026-09-08T09:00:00"
|
||||
recurrence = client.get(f"/api/v1/tasks/{task['id']}/recurrence").json()
|
||||
assert recurrence["starts_at"].replace("Z", "") == "2026-09-08T09:00:00"
|
||||
|
||||
|
||||
def test_recurrence_mutations_keep_exact_timestamp_validation(client):
|
||||
inbox = boot(client)
|
||||
task = client.post(
|
||||
|
||||
Reference in New Issue
Block a user