{
  "name": "Employee API CRUD 테스트",
  "description": "사원 관리 API 전체 CRUD 및 계정 생성 테스트",
  "version": "1.0",
  "config": {
    "baseUrl": "",
    "timeout": 30000,
    "stopOnFailure": true
  },
  "variables": {
    "user_id": "{{$env.FLOW_TESTER_USER_ID}}",
    "user_pwd": "{{$env.FLOW_TESTER_USER_PWD}}",
    "test_email": "test.employee.{{$timestamp}}@example.com",
    "test_name": "테스트사원{{$random:4}}"
  },
  "steps": [
    {
      "id": "login",
      "name": "로그인",
      "method": "POST",
      "endpoint": "/login",
      "body": {
        "user_id": "{{user_id}}",
        "user_pwd": "{{user_pwd}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.message": "로그인 성공",
          "$.access_token": "@isString"
        }
      },
      "extract": {
        "token": "$.access_token",
        "current_user_id": "$.user.id"
      }
    },
    {
      "id": "get_stats",
      "name": "사원 통계 조회",
      "method": "GET",
      "endpoint": "/employees/stats",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.total": "@isNumber",
          "$.data.active": "@isNumber",
          "$.data.leave": "@isNumber",
          "$.data.resigned": "@isNumber"
        }
      }
    },
    {
      "id": "list_employees",
      "name": "사원 목록 조회",
      "method": "GET",
      "endpoint": "/employees",
      "query": {
        "page": 1,
        "per_page": 10
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.data": "@isArray"
        }
      }
    },
    {
      "id": "create_employee",
      "name": "사원 등록",
      "method": "POST",
      "endpoint": "/employees",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "name": "{{test_name}}",
        "email": "{{test_email}}",
        "phone": "010-1234-5678",
        "employee_number": "EMP{{$random:6}}",
        "employee_status": "active",
        "position": "사원",
        "hire_date": "{{$date}}",
        "json_extra": {
          "emergency_contact": "010-9999-8888",
          "address": "서울시 강남구"
        }
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber",
          "$.data.user.name": "{{test_name}}"
        }
      },
      "extract": {
        "employee_id": "$.data.id",
        "user_id": "$.data.user_id"
      }
    },
    {
      "id": "show_employee",
      "name": "사원 상세 조회",
      "method": "GET",
      "endpoint": "/employees/{{create_employee.employee_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "{{create_employee.employee_id}}",
          "$.data.employee_status": "active"
        }
      }
    },
    {
      "id": "update_employee",
      "name": "사원 정보 수정",
      "method": "PATCH",
      "endpoint": "/employees/{{create_employee.employee_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "position": "대리",
        "employee_status": "active",
        "json_extra": {
          "emergency_contact": "010-1111-2222",
          "address": "서울시 서초구",
          "skills": ["Laravel", "React"]
        }
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      }
    },
    {
      "id": "list_filtered",
      "name": "사원 필터 조회 (재직자)",
      "method": "GET",
      "endpoint": "/employees",
      "query": {
        "status": "active",
        "q": "{{test_name}}"
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_employee",
      "name": "사원 삭제",
      "method": "DELETE",
      "endpoint": "/employees/{{create_employee.employee_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    }
  ]
}
