{
  "info": {
    "name": "Canygoo API - Image Upload Test",
    "description": "Colección para testear el upload de imágenes con validación completa",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Auth",
      "item": [
        {
          "name": "Login",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.environment.set('token', jsonData.token);",
                  "    console.log('Token guardado:', jsonData.token);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"email\":\"user@example.com\",\"password\":\"password123\"}"
            },
            "url": {
              "raw": "{{base_url}}auth/login",
              "host": ["{{base_url}}auth"],
              "path": ["login"]
            }
          }
        }
      ]
    },
    {
      "name": "Walkers - Image Upload",
      "item": [
        {
          "name": "✅ Crear Walker con imagen válida",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status 201 Created', function() {",
                  "    pm.expect(pm.response.code).to.equal(201);",
                  "});",
                  "",
                  "pm.test('Respuesta contiene ID', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.id).to.exist;",
                  "});",
                  "",
                  "pm.test('URL de foto está presente', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.photo).to.include('.jpg,.png,.gif,.webp');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Juan García",
                  "type": "text"
                },
                {
                  "key": "description",
                  "value": "Tengo 5 años de experiencia paseando perros. Amo los animales!",
                  "type": "text"
                },
                {
                  "key": "pricePerHour",
                  "value": "25",
                  "type": "text"
                },
                {
                  "key": "maxPets",
                  "value": "5",
                  "type": "text"
                },
                {
                  "key": "phone",
                  "value": "+34612345678",
                  "type": "text"
                },
                {
                  "key": "email",
                  "value": "juan@example.com",
                  "type": "text"
                },
                {
                  "key": "city",
                  "value": "Madrid",
                  "type": "text"
                },
                {
                  "key": "services",
                  "value": "[\"Paseo estándar\",\"Ejercicio intensivo\"]",
                  "type": "text"
                },
                {
                  "key": "availability",
                  "value": "[\"Lunes\",\"Martes\",\"Miércoles\",\"Jueves\",\"Viernes\"]",
                  "type": "text"
                },
                {
                  "key": "location",
                  "value": "{\"latitude\":40.4168,\"longitude\":-3.7038}",
                  "type": "text"
                },
                {
                  "key": "photo",
                  "type": "file",
                  "src": "/path/to/valid/image.jpg"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}walkers",
              "host": ["{{base_url}}"],
              "path": ["walkers"]
            }
          }
        },
        {
          "name": "❌ Imagen - Formato no permitido",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status 400 Bad Request', function() {",
                  "    pm.expect(pm.response.code).to.equal(400);",
                  "});",
                  "",
                  "pm.test('Error message contiene formato', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.message).to.include('no permitido');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Test Walker",
                  "type": "text"
                },
                {
                  "key": "description",
                  "value": "Descripción de prueba para walker",
                  "type": "text"
                },
                {
                  "key": "pricePerHour",
                  "value": "25",
                  "type": "text"
                },
                {
                  "key": "maxPets",
                  "value": "5",
                  "type": "text"
                },
                {
                  "key": "phone",
                  "value": "+34612345678",
                  "type": "text"
                },
                {
                  "key": "email",
                  "value": "test@example.com",
                  "type": "text"
                },
                {
                  "key": "city",
                  "value": "Madrid",
                  "type": "text"
                },
                {
                  "key": "services",
                  "value": "[\"Paseo estándar\"]",
                  "type": "text"
                },
                {
                  "key": "photo",
                  "type": "file",
                  "src": "/path/to/invalid/file.txt"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}walkers",
              "host": ["{{base_url}}"],
              "path": ["walkers"]
            }
          }
        },
        {
          "name": "❌ Imagen - Demasiado grande (>5MB)",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status 400 - Tamaño excedido', function() {",
                  "    pm.expect(pm.response.code).to.equal(400);",
                  "});",
                  "",
                  "pm.test('Error message menciona tamaño', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.message.toLowerCase()).to.include('grande');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Test Walker",
                  "type": "text"
                },
                {
                  "key": "description",
                  "value": "Descripción de prueba para walker",
                  "type": "text"
                },
                {
                  "key": "pricePerHour",
                  "value": "25",
                  "type": "text"
                },
                {
                  "key": "maxPets",
                  "value": "5",
                  "type": "text"
                },
                {
                  "key": "phone",
                  "value": "+34612345678",
                  "type": "text"
                },
                {
                  "key": "email",
                  "value": "test@example.com",
                  "type": "text"
                },
                {
                  "key": "city",
                  "value": "Madrid",
                  "type": "text"
                },
                {
                  "key": "services",
                  "value": "[\"Paseo estándar\"]",
                  "type": "text"
                },
                {
                  "key": "photo",
                  "type": "file",
                  "src": "/path/to/large/image.jpg"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}walkers",
              "host": ["{{base_url}}"],
              "path": ["walkers"]
            }
          }
        },
        {
          "name": "❌ Imagen - Dimensiones muy pequeñas",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status 400 - Dimensiones insuficientes', function() {",
                  "    pm.expect(pm.response.code).to.equal(400);",
                  "});",
                  "",
                  "pm.test('Error menciona dimensiones mínimas', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.message).to.include('dimensiones');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Test Walker",
                  "type": "text"
                },
                {
                  "key": "description",
                  "value": "Descripción de prueba para walker",
                  "type": "text"
                },
                {
                  "key": "pricePerHour",
                  "value": "25",
                  "type": "text"
                },
                {
                  "key": "maxPets",
                  "value": "5",
                  "type": "text"
                },
                {
                  "key": "phone",
                  "value": "+34612345678",
                  "type": "text"
                },
                {
                  "key": "email",
                  "value": "test@example.com",
                  "type": "text"
                },
                {
                  "key": "city",
                  "value": "Madrid",
                  "type": "text"
                },
                {
                  "key": "services",
                  "value": "[\"Paseo estándar\"]",
                  "type": "text"
                },
                {
                  "key": "photo",
                  "type": "file",
                  "src": "/path/to/tiny/image.jpg"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}walkers",
              "host": ["{{base_url}}"],
              "path": ["walkers"]
            }
          }
        },
        {
          "name": "❌ Campos requeridos faltantes",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status 400 - Validación', function() {",
                  "    pm.expect(pm.response.code).to.equal(400);",
                  "});",
                  "",
                  "pm.test('Error menciona campos faltantes', function() {",
                  "    var jsonData = pm.response.json();",
                  "    pm.expect(jsonData.error).to.equal('VALIDATION_ERROR');",
                  "    pm.expect(jsonData.missing_fields).to.be.an('array');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Incomplete Walker",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}walkers",
              "host": ["{{base_url}}"],
              "path": ["walkers"]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "https://bcea-92-59-77-88.ngrok-free.app/api/",
      "type": "string"
    },
    {
      "key": "token",
      "value": "",
      "type": "string"
    }
  ]
}
