Create hurl test for updating tasks.
This commit is contained in:
parent
d32f6be813
commit
e2284c7421
1 changed files with 162 additions and 0 deletions
162
backend/tests/api/update_tasks.hurl
Normal file
162
backend/tests/api/update_tasks.hurl
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
# Task Update API Tests
|
||||
|
||||
# Setup: Create a task to update
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Original Task",
|
||||
"description": "Original description"
|
||||
}
|
||||
|
||||
HTTP 201
|
||||
[Captures]
|
||||
task_id: jsonpath "$.id"
|
||||
created_at: jsonpath "$.created_at"
|
||||
|
||||
# Test: Update task title only
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Updated Task Title"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.title" == "Updated Task Title"
|
||||
jsonpath "$.description" == "Original description"
|
||||
jsonpath "$.status" == "todo"
|
||||
jsonpath "$.updated_at" != "{{created_at}}"
|
||||
|
||||
# Test: Update description only
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"description": "Updated description"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.title" == "Updated Task Title"
|
||||
jsonpath "$.description" == "Updated description"
|
||||
jsonpath "$.status" == "todo"
|
||||
|
||||
# Test: Update status to done
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"status": "done"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.status" == "done"
|
||||
jsonpath "$.completed_at" exists
|
||||
|
||||
# Test: Update status to backlog
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"status": "backlog"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.status" == "backlog"
|
||||
jsonpath "$.completed_at" == null
|
||||
|
||||
# Test: Update multiple fields together
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Completely Updated Task",
|
||||
"description": "Completely updated description",
|
||||
"status": "done"
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.title" == "Completely Updated Task"
|
||||
jsonpath "$.description" == "Completely updated description"
|
||||
jsonpath "$.status" == "done"
|
||||
jsonpath "$.completed_at" exists
|
||||
|
||||
# Test: Clear description (set to null)
|
||||
PUT {{host}}/api/tasks/{{task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"description": null
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.description" == null
|
||||
|
||||
# Setup: Create another task for error tests
|
||||
POST {{host}}/api/tasks
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "Task for Error Tests"
|
||||
}
|
||||
|
||||
HTTP 201
|
||||
[Captures]
|
||||
error_test_task_id: jsonpath "$.id"
|
||||
|
||||
# Test: Update non-existent task
|
||||
PUT {{host}}/api/tasks/00000000-0000-0000-0000-000000000000
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "This should fail"
|
||||
}
|
||||
|
||||
HTTP 404
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Update with invalid UUID format
|
||||
PUT {{host}}/api/tasks/invalid-uuid-format
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": "This should also fail"
|
||||
}
|
||||
|
||||
HTTP 400
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Update with empty title
|
||||
PUT {{host}}/api/tasks/{{error_test_task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"title": ""
|
||||
}
|
||||
|
||||
HTTP 422
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Update with invalid status
|
||||
PUT {{host}}/api/tasks/{{error_test_task_id}}
|
||||
Content-Type: application/json
|
||||
{
|
||||
"status": "invalid_status"
|
||||
}
|
||||
|
||||
HTTP 422
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
|
||||
# Test: Update with no fields (empty object)
|
||||
PUT {{host}}/api/tasks/{{error_test_task_id}}
|
||||
Content-Type: application/json
|
||||
{}
|
||||
|
||||
HTTP 422
|
||||
[Asserts]
|
||||
jsonpath "$.error" exists
|
||||
Loading…
Add table
Add a link
Reference in a new issue