143 lines
No EOL
3.5 KiB
Text
143 lines
No EOL
3.5 KiB
Text
# Task List API Tests
|
|
|
|
# Test: Get task list (may or may not be empty)
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Captures]
|
|
initial_count: jsonpath "$ length"
|
|
[Asserts]
|
|
jsonpath "$" isCollection
|
|
|
|
# Setup: Create multiple tasks with different properties
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Test Task Alpha",
|
|
"description": "Alpha task description"
|
|
}
|
|
|
|
HTTP 201
|
|
[Captures]
|
|
alpha_task_id: jsonpath "$.id"
|
|
alpha_created_at: jsonpath "$.created_at"
|
|
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Test Task Beta"
|
|
}
|
|
|
|
HTTP 201
|
|
[Captures]
|
|
beta_task_id: jsonpath "$.id"
|
|
beta_created_at: jsonpath "$.created_at"
|
|
|
|
POST {{host}}/api/tasks
|
|
Content-Type: application/json
|
|
{
|
|
"title": "Test Task Gamma",
|
|
"description": "Gamma task with description"
|
|
}
|
|
|
|
HTTP 201
|
|
[Captures]
|
|
gamma_task_id: jsonpath "$.id"
|
|
gamma_created_at: jsonpath "$.created_at"
|
|
|
|
# Test: List includes our newly created tasks
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$" isCollection
|
|
jsonpath "$ length" >= {{initial_count}}
|
|
jsonpath "$[*].id" includes "{{alpha_task_id}}"
|
|
jsonpath "$[*].id" includes "{{beta_task_id}}"
|
|
jsonpath "$[*].id" includes "{{gamma_task_id}}"
|
|
jsonpath "$[*].title" includes "Test Task Alpha"
|
|
jsonpath "$[*].title" includes "Test Task Beta"
|
|
jsonpath "$[*].title" includes "Test Task Gamma"
|
|
|
|
# Test: Verify all tasks have required fields
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].title" exists
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" exists
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].created_at" exists
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].updated_at" exists
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].title" exists
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" exists
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].created_at" exists
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].updated_at" exists
|
|
|
|
# Test: Verify our tasks have correct initial values
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].title" nth 0 == "Test Task Alpha"
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].description" nth 0 == "Alpha task description"
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" nth 0 == "todo"
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].title" nth 0 == "Test Task Beta"
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].description" nth 0 == null
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" nth 0 == "todo"
|
|
|
|
# Setup: Update tasks to test mixed statuses
|
|
PUT {{host}}/api/tasks/{{beta_task_id}}
|
|
Content-Type: application/json
|
|
{
|
|
"status": "done"
|
|
}
|
|
|
|
HTTP 200
|
|
|
|
PUT {{host}}/api/tasks/{{gamma_task_id}}
|
|
Content-Type: application/json
|
|
{
|
|
"status": "backlog"
|
|
}
|
|
|
|
HTTP 200
|
|
|
|
# Test: List shows updated statuses
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$[?(@.id=='{{alpha_task_id}}')].status" nth 0 == "todo"
|
|
jsonpath "$[?(@.id=='{{beta_task_id}}')].status" nth 0 == "done"
|
|
jsonpath "$[?(@.id=='{{gamma_task_id}}')].status" nth 0 == "backlog"
|
|
|
|
# Setup: Delete one task
|
|
DELETE {{host}}/api/tasks/{{alpha_task_id}}
|
|
|
|
HTTP 204
|
|
|
|
# Test: Deleted task no longer appears in list
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$[*].id" not includes "{{alpha_task_id}}"
|
|
jsonpath "$[*].id" includes "{{beta_task_id}}"
|
|
jsonpath "$[*].id" includes "{{gamma_task_id}}"
|
|
|
|
# Cleanup: Delete remaining test tasks
|
|
DELETE {{host}}/api/tasks/{{beta_task_id}}
|
|
|
|
HTTP 204
|
|
|
|
DELETE {{host}}/api/tasks/{{gamma_task_id}}
|
|
|
|
HTTP 204
|
|
|
|
# Test: Our test tasks are gone
|
|
GET {{host}}/api/tasks
|
|
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$[*].id" not includes "{{beta_task_id}}"
|
|
jsonpath "$[*].id" not includes "{{gamma_task_id}}" |