info:
  name: Duplicate Name Validation
  type: http
  seq: 1
http:
  method: POST
  url: '{{base_url}}/api/saved-filters'
  auth: inherit
  body:
    type: json
    jsonBody: "{\n    \"name\": \"Duplicate Test\",\n    \"resource_type\":\
      \ \"media-items\",\n    \"filters\": {\n      \"search\": \"test\",\n      \"genre_filter\"\
      : \"Science Fiction\"\n    }\n  }"

docs: |-
  ## Duplicate Name Validation

  Tests that the API correctly prevents creating duplicate filter names for the same user + resource type combination.

  **Scenario:**
  1. Create first filter with name "Duplicate Test"
  2. Attempt to create second filter with same name
  3. Expect 409 Conflict error

  **Expected Behavior:**
  - First request: 201 Created
  - Second request: 409 Conflict with error message

  **Error Response:**
  ```json
  {
    "error": "filter with name 'Duplicate Test' already exists for this resource type"
  }
  ```

  **Test Steps:**
  ```bash
  # First request - should succeed
  curl -X POST \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Duplicate Test",
      "resource_type": "media-items",
      "filters": {"search": "test"}
    }' \
    "{{base_url}}/api/saved-filters"

  # Response: 201 Created

  # Second request - should fail with 409
  curl -X POST \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Duplicate Test",
      "resource_type": "media-items",
      "filters": {"search": "test"}
    }' \
    "{{base_url}}/api/saved-filters"

  # Response: 409 Conflict
  # {
  #   "error": "filter with name 'Duplicate Test' already exists for this resource type"
  # }
  ```

  **Important Notes:**
  - Duplicate check is per user + resource type
  - Same filter name can be used for different resource types
  - Different users can have filters with the same name
  - Validation happens in service layer before database insertion

  **Related Tests:**
  - Update filter with name that conflicts with another filter (should also return 409)
  - Create filter with different name for different resource type (should succeed)
