{
  "name": "ItemMaster Field API CRUD Flow Test",
  "description": "품목기준관리 필드(Field) 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_field_name": "테스트필드_{{$timestamp}}",
    "test_field_key": "test_field_{{$timestamp}}"
  },
  "steps": [
    {
      "id": "login",
      "name": "1. 로그인",
      "method": "POST",
      "endpoint": "/login",
      "body": {
        "user_id": "{{user_id}}",
        "user_pwd": "{{user_pwd}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.access_token": "@isString"
        }
      },
      "extract": {
        "token": "$.access_token"
      }
    },
    {
      "id": "list_fields",
      "name": "2. 독립 필드 목록 조회",
      "method": "GET",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_field_textbox",
      "name": "3. 독립 필드 생성 (텍스트박스)",
      "method": "POST",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}",
        "field_key": "test_textbox",
        "field_type": "textbox",
        "is_required": false,
        "placeholder": "텍스트를 입력하세요",
        "default_value": ""
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "field_id": "$.data.id",
        "field_name": "$.data.field_name"
      }
    },
    {
      "id": "create_field_dropdown",
      "name": "4. 독립 필드 생성 (드롭다운)",
      "method": "POST",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}_드롭다운",
        "field_key": "test_dropdown",
        "field_type": "dropdown",
        "is_required": true,
        "options": [
          {"label": "옵션1", "value": "opt1"},
          {"label": "옵션2", "value": "opt2"},
          {"label": "옵션3", "value": "opt3"}
        ]
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "dropdown_field_id": "$.data.id"
      }
    },
    {
      "id": "update_field",
      "name": "5. 필드 수정",
      "method": "PUT",
      "endpoint": "/item-master/fields/{{create_field_textbox.field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}_수정됨",
        "field_key": "test_textbox_updated",
        "field_type": "textbox",
        "is_required": true,
        "placeholder": "필수 입력 필드입니다"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "clone_field",
      "name": "6. 필드 복제",
      "method": "POST",
      "endpoint": "/item-master/fields/{{create_field_textbox.field_id}}/clone",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "cloned_field_id": "$.data.id"
      }
    },
    {
      "id": "get_field_usage",
      "name": "7. 필드 사용처 조회",
      "method": "GET",
      "endpoint": "/item-master/fields/{{create_field_textbox.field_id}}/usage",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "verify_fields",
      "name": "8. 필드 목록 재조회",
      "method": "GET",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_cloned_field",
      "name": "9. 복제된 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{clone_field.cloned_field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_dropdown_field",
      "name": "10. 드롭다운 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{create_field_dropdown.dropdown_field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_original_field",
      "name": "11. 원본 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{create_field_textbox.field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "verify_cleanup",
      "name": "12. 정리 확인 - 목록 조회",
      "method": "GET",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    }
  ]
}
