{
  "name": "ItemMaster 전체 API CRUD Flow Test",
  "description": "품목기준관리(ItemMaster) 전체 API 테스트 - Init, Pages, Sections, Fields, BomItems 통합 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_page_name": "FlowTest_Page_{{$timestamp}}",
    "test_section_title": "FlowTest_Section_{{$timestamp}}",
    "test_field_name": "FlowTest_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": "init",
      "name": "2. ItemMaster 초기화 데이터 조회",
      "method": "GET",
      "endpoint": "/item-master/init",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "list_pages_before",
      "name": "3. 페이지 목록 조회 (FG)",
      "method": "GET",
      "endpoint": "/item-master/pages",
      "params": {
        "item_type": "FG"
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_page",
      "name": "4. 페이지 생성 (FG)",
      "method": "POST",
      "endpoint": "/item-master/pages",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "page_name": "{{test_page_name}}",
        "item_type": "FG",
        "absolute_path": "/flow-test/fg"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "page_id": "$.data.id"
      }
    },
    {
      "id": "update_page",
      "name": "5. 페이지 수정",
      "method": "PUT",
      "endpoint": "/item-master/pages/{{create_page.page_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "page_name": "{{test_page_name}}_수정됨",
        "item_type": "FG",
        "absolute_path": "/flow-test/fg/updated"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "list_sections_before",
      "name": "6. 독립 섹션 목록 조회",
      "method": "GET",
      "endpoint": "/item-master/sections",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_independent_section",
      "name": "7. 독립 섹션 생성 (fields 타입)",
      "method": "POST",
      "endpoint": "/item-master/sections",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "title": "{{test_section_title}}",
        "type": "fields",
        "is_template": false,
        "is_default": false,
        "description": "Flow Test 독립 섹션"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "section_id": "$.data.id"
      }
    },
    {
      "id": "create_page_section",
      "name": "8. 페이지에 섹션 생성",
      "method": "POST",
      "endpoint": "/item-master/pages/{{create_page.page_id}}/sections",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "title": "{{test_section_title}}_페이지연결",
        "type": "fields",
        "is_default": false
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "page_section_id": "$.data.id"
      }
    },
    {
      "id": "update_section",
      "name": "9. 섹션 수정",
      "method": "PUT",
      "endpoint": "/item-master/sections/{{create_page_section.page_section_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "title": "{{test_section_title}}_수정됨",
        "type": "fields",
        "description": "수정된 섹션 설명"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "section_usage",
      "name": "10. 섹션 사용처 조회",
      "method": "GET",
      "endpoint": "/item-master/sections/{{create_page_section.page_section_id}}/usage",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "list_fields_before",
      "name": "11. 독립 필드 목록 조회",
      "method": "GET",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_independent_field",
      "name": "12. 독립 필드 생성",
      "method": "POST",
      "endpoint": "/item-master/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}",
        "field_key": "flow_test_field",
        "field_type": "textbox",
        "is_required": false,
        "placeholder": "테스트 입력",
        "is_locked": false
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "field_id": "$.data.id"
      }
    },
    {
      "id": "create_section_field",
      "name": "13. 섹션에 필드 생성",
      "method": "POST",
      "endpoint": "/item-master/sections/{{create_page_section.page_section_id}}/fields",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}_섹션연결",
        "field_key": "flow_test_section_field",
        "field_type": "number",
        "is_required": true,
        "default_value": "0",
        "placeholder": "숫자 입력"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "section_field_id": "$.data.id"
      }
    },
    {
      "id": "update_field",
      "name": "14. 필드 수정",
      "method": "PUT",
      "endpoint": "/item-master/fields/{{create_section_field.section_field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "field_name": "{{test_field_name}}_수정됨",
        "field_type": "number",
        "is_required": false,
        "default_value": "100"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "field_usage",
      "name": "15. 필드 사용처 조회",
      "method": "GET",
      "endpoint": "/item-master/fields/{{create_section_field.section_field_id}}/usage",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "clone_field",
      "name": "16. 필드 복제",
      "method": "POST",
      "endpoint": "/item-master/fields/{{create_section_field.section_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": "clone_section",
      "name": "17. 섹션 복제",
      "method": "POST",
      "endpoint": "/item-master/sections/{{create_page_section.page_section_id}}/clone",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "cloned_section_id": "$.data.id"
      }
    },
    {
      "id": "get_page_structure",
      "name": "18. 페이지 구조 조회",
      "method": "GET",
      "endpoint": "/item-master/pages/{{create_page.page_id}}/structure",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "get_page_relationships",
      "name": "19. 페이지 관계 조회",
      "method": "GET",
      "endpoint": "/item-master/pages/{{create_page.page_id}}/relationships",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_cloned_field",
      "name": "20. 복제된 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{clone_field.cloned_field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_section_field",
      "name": "21. 섹션 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{create_section_field.section_field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_independent_field",
      "name": "22. 독립 필드 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/fields/{{create_independent_field.field_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_cloned_section",
      "name": "23. 복제된 섹션 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/sections/{{clone_section.cloned_section_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_page_section",
      "name": "24. 페이지 섹션 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/sections/{{create_page_section.page_section_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_independent_section",
      "name": "25. 독립 섹션 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/sections/{{create_independent_section.section_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_page",
      "name": "26. 페이지 삭제",
      "method": "DELETE",
      "endpoint": "/item-master/pages/{{create_page.page_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "verify_cleanup",
      "name": "27. 정리 확인 - 페이지 목록 재조회",
      "method": "GET",
      "endpoint": "/item-master/pages",
      "params": {
        "item_type": "FG"
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    }
  ]
}