Create the remaining task api methods on the server. (#3)
Create the remaining task api methods along with hurl tests for each. Reviewed-on: #3 Co-authored-by: Drew Galbraith <drew@tiramisu.one> Co-committed-by: Drew Galbraith <drew@tiramisu.one>
This commit is contained in:
parent
d32f6be813
commit
ef247e6e29
5 changed files with 457 additions and 3 deletions
154
backend/tests/api/update_tasks.hurl
Normal file
154
backend/tests/api/update_tasks.hurl
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
# 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": ""
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.id" == "{{task_id}}"
|
||||
jsonpath "$.description" == ""
|
||||
|
||||
# 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue