Files
sam-api/claudedocs/flow-tester-item-delete.json
hskwon fbaf2720d8 fix: 품목 삭제 시 BOM 참조 무결성 체크 추가
- 삭제 전 product_components 테이블에서 사용 여부 확인
- BOM 구성품으로 사용 중인 품목 삭제 차단 (400 에러)
- 일괄 삭제에도 동일한 참조 체크 적용
- 품목 관련 에러 메시지 추가 (error.item.*)
- 품목 삭제 API 테스트 플로우 JSON 추가
2025-12-03 22:35:38 +09:00

287 lines
9.9 KiB
JSON

{
"name": "품목 삭제 API 테스트",
"description": "품목 삭제 시 참조 무결성 체크 및 soft delete 동작을 테스트합니다.",
"version": "1.0",
"config": {
"apiKey": "42Jfwc6EaRQ04GNRmLR5kzJp5UudSOzGGqjmdk1a",
"baseUrl": "https://api.sam.kr/api/v1",
"timeout": 30000,
"stopOnFailure": false
},
"variables": {
"user_id": "codebridgex",
"user_pwd": "code1234",
"testProductCode": "TEST-DEL-001",
"testProductName": "삭제 테스트용 품목",
"testBomParentCode": "TEST-BOM-PARENT-001",
"testBomParentName": "BOM 부모 품목"
},
"steps": [
{
"id": "login",
"name": "로그인",
"description": "API 테스트를 위한 로그인",
"method": "POST",
"endpoint": "/login",
"body": {
"user_id": "{{variables.user_id}}",
"user_pwd": "{{variables.user_pwd}}"
},
"extract": {
"accessToken": "$.access_token",
"refreshToken": "$.refresh_token"
},
"expect": {
"status": [200],
"jsonPath": {
"$.access_token": "@isString"
}
}
},
{
"id": "create_product_for_delete",
"name": "삭제 테스트용 품목 생성",
"description": "단순 삭제 테스트용 품목 생성 (BOM에 미사용)",
"method": "POST",
"endpoint": "/items",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"body": {
"code": "{{variables.testProductCode}}",
"name": "{{variables.testProductName}}",
"unit": "EA",
"product_type": "FG",
"is_active": true
},
"dependsOn": ["login"],
"extract": {
"createdProductId": "$.data.id",
"createdProductCode": "$.data.code"
},
"expect": {
"status": [200, 201],
"jsonPath": {
"$.success": true,
"$.data.id": "@isNumber"
}
}
},
{
"id": "get_items_list",
"name": "품목 목록 조회",
"description": "생성된 품목이 목록에 있는지 확인",
"method": "GET",
"endpoint": "/items?type=FG&search={{create_product_for_delete.createdProductCode}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["create_product_for_delete"],
"expect": {
"status": [200],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "delete_product_success",
"name": "품목 삭제 (정상)",
"description": "BOM에서 사용되지 않는 품목 삭제 - 성공해야 함",
"method": "DELETE",
"endpoint": "/items/{{create_product_for_delete.createdProductId}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["get_items_list"],
"expect": {
"status": [200],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "verify_deleted_not_in_list",
"name": "삭제된 품목 목록 미포함 확인",
"description": "삭제된 품목이 기본 목록에서 제외되는지 확인",
"method": "GET",
"endpoint": "/items?type=FG&search={{create_product_for_delete.createdProductCode}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["delete_product_success"],
"expect": {
"status": [200],
"jsonPath": {
"$.success": true
}
},
"note": "data.total이 0이어야 함 (삭제된 품목 미포함)"
},
{
"id": "delete_already_deleted_item",
"name": "이미 삭제된 품목 재삭제 시도",
"description": "soft delete된 품목을 다시 삭제하면 404 반환해야 함",
"method": "DELETE",
"endpoint": "/items/{{create_product_for_delete.createdProductId}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["verify_deleted_not_in_list"],
"expect": {
"status": [404],
"jsonPath": {
"$.success": false
}
}
},
{
"id": "create_bom_parent",
"name": "BOM 부모 품목 생성",
"description": "BOM 테스트를 위한 부모 품목 생성",
"method": "POST",
"endpoint": "/items",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"body": {
"code": "{{variables.testBomParentCode}}",
"name": "{{variables.testBomParentName}}",
"unit": "EA",
"product_type": "FG",
"is_active": true
},
"dependsOn": ["login"],
"extract": {
"bomParentId": "$.data.id"
},
"expect": {
"status": [200, 201],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "create_bom_child",
"name": "BOM 자식 품목 생성",
"description": "BOM 구성품으로 사용될 품목 생성",
"method": "POST",
"endpoint": "/items",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"body": {
"code": "TEST-BOM-CHILD-001",
"name": "BOM 자식 품목",
"unit": "EA",
"product_type": "PT",
"is_active": true
},
"dependsOn": ["create_bom_parent"],
"extract": {
"bomChildId": "$.data.id"
},
"expect": {
"status": [200, 201],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "add_bom_component",
"name": "BOM 구성품 추가",
"description": "부모 품목에 자식 품목을 BOM으로 등록",
"method": "POST",
"endpoint": "/items/{{create_bom_parent.bomParentId}}/bom",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"body": {
"items": [
{
"ref_type": "PRODUCT",
"ref_id": "{{create_bom_child.bomChildId}}",
"quantity": 2,
"sort_order": 1
}
]
},
"dependsOn": ["create_bom_child"],
"expect": {
"status": [200, 201],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "delete_bom_used_item_fail",
"name": "BOM 사용 중인 품목 삭제 시도",
"description": "다른 BOM에서 구성품으로 사용 중인 품목 삭제 - 400 에러 반환해야 함",
"method": "DELETE",
"endpoint": "/items/{{create_bom_child.bomChildId}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["add_bom_component"],
"expect": {
"status": [400],
"jsonPath": {
"$.success": false,
"$.message": "@contains:BOM"
}
}
},
{
"id": "cleanup_bom",
"name": "BOM 구성품 제거",
"description": "테스트 정리 - BOM 구성품 제거",
"method": "DELETE",
"endpoint": "/items/{{create_bom_parent.bomParentId}}/bom",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["delete_bom_used_item_fail"],
"expect": {
"status": [200, 204]
}
},
{
"id": "delete_bom_child_after_cleanup",
"name": "BOM 해제 후 자식 품목 삭제",
"description": "BOM에서 제거된 품목은 삭제 가능해야 함",
"method": "DELETE",
"endpoint": "/items/{{create_bom_child.bomChildId}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["cleanup_bom"],
"expect": {
"status": [200],
"jsonPath": {
"$.success": true
}
}
},
{
"id": "cleanup_bom_parent",
"name": "BOM 부모 품목 삭제",
"description": "테스트 정리 - 부모 품목 삭제",
"method": "DELETE",
"endpoint": "/items/{{create_bom_parent.bomParentId}}",
"headers": {
"Authorization": "Bearer {{login.accessToken}}"
},
"dependsOn": ["delete_bom_child_after_cleanup"],
"expect": {
"status": [200],
"jsonPath": {
"$.success": true
}
}
}
]
}