94 lines
2 KiB
Text
94 lines
2 KiB
Text
# Task API Tests
|
|
|
|
# Test: Create a new task (POST /api/tasks)
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Test task",
|
|
"description": "A test task for the API"
|
|
}
|
|
|
|
HTTP 201
|
|
[Captures]
|
|
task_id: jsonpath "$.id"
|
|
[Asserts]
|
|
jsonpath "$.title" == "Test task"
|
|
jsonpath "$.description" == "A test task for the API"
|
|
jsonpath "$.status" == "todo"
|
|
jsonpath "$.id" exists
|
|
jsonpath "$.created_at" exists
|
|
jsonpath "$.updated_at" exists
|
|
|
|
# Test: Create a minimal task (only required fields)
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Minimal task"
|
|
}
|
|
|
|
HTTP 201
|
|
[Captures]
|
|
minimal_task_id: jsonpath "$.id"
|
|
[Asserts]
|
|
jsonpath "$.title" == "Minimal task"
|
|
jsonpath "$.status" == "todo"
|
|
jsonpath "$.description" == null
|
|
|
|
# Test: Create task with invalid data (missing title)
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"description": "Task without title"
|
|
}
|
|
|
|
HTTP 422
|
|
[Asserts]
|
|
jsonpath "$.error" exists
|
|
|
|
# Test: Create task with invalid priority
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Invalid priority task",
|
|
"priority": "This field does not exist."
|
|
}
|
|
|
|
HTTP 422
|
|
[Asserts]
|
|
jsonpath "$.error" exists
|
|
|
|
# Test: Get a specific task by ID (GET /api/tasks/{id})
|
|
GET {{host}}/api/tasks/{{task_id}}
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == "{{task_id}}"
|
|
jsonpath "$.title" == "Test task"
|
|
jsonpath "$.description" == "A test task for the API"
|
|
jsonpath "$.status" == "todo"
|
|
jsonpath "$.created_at" exists
|
|
jsonpath "$.updated_at" exists
|
|
|
|
# Test: Get a minimal task by ID
|
|
GET {{host}}/api/tasks/{{minimal_task_id}}
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == "{{minimal_task_id}}"
|
|
jsonpath "$.title" == "Minimal task"
|
|
jsonpath "$.status" == "todo"
|
|
jsonpath "$.description" == null
|
|
|
|
# Test: Get non-existent task
|
|
GET {{host}}/api/tasks/00000000-0000-0000-0000-000000000000
|
|
|
|
HTTP 404
|
|
[Asserts]
|
|
jsonpath "$.error" exists
|
|
|
|
# Test: Get task with invalid UUID format
|
|
GET {{host}}/api/tasks/invalid-uuid
|
|
|
|
HTTP 400
|
|
[Asserts]
|
|
jsonpath "$.error" exists
|