{
  "name": "Attendance API 근태관리 테스트",
  "description": "근태 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_date": "{{$date}}"
  },
  "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": "check_in",
      "name": "출근 기록",
      "method": "POST",
      "endpoint": "/attendances/check-in",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "check_in": "09:00:00",
        "gps_data": {
          "latitude": 37.5665,
          "longitude": 126.978,
          "accuracy": 10
        }
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber",
          "$.data.status": "@isString"
        }
      },
      "extract": {
        "attendance_id": "$.data.id"
      }
    },
    {
      "id": "show_attendance",
      "name": "근태 상세 조회",
      "method": "GET",
      "endpoint": "/attendances/{{check_in.attendance_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "{{check_in.attendance_id}}",
          "$.data.base_date": "@isString"
        }
      }
    },
    {
      "id": "check_out",
      "name": "퇴근 기록",
      "method": "POST",
      "endpoint": "/attendances/check-out",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "check_out": "18:00:00",
        "gps_data": {
          "latitude": 37.5665,
          "longitude": 126.978,
          "accuracy": 15
        }
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      }
    },
    {
      "id": "list_attendances",
      "name": "근태 목록 조회",
      "method": "GET",
      "endpoint": "/attendances",
      "query": {
        "page": 1,
        "per_page": 10,
        "date": "{{test_date}}"
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.data": "@isArray"
        }
      }
    },
    {
      "id": "monthly_stats",
      "name": "월간 통계 조회",
      "method": "GET",
      "endpoint": "/attendances/monthly-stats",
      "query": {
        "year": 2025,
        "month": 12
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_attendance",
      "name": "근태 수동 등록 (관리자)",
      "method": "POST",
      "endpoint": "/attendances",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "user_id": "{{login.current_user_id}}",
        "base_date": "2025-12-01",
        "status": "onTime",
        "json_details": {
          "check_in": "09:00:00",
          "check_out": "18:00:00",
          "work_minutes": 480
        },
        "remarks": "Flow Tester 테스트 데이터"
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "manual_attendance_id": "$.data.id"
      }
    },
    {
      "id": "update_attendance",
      "name": "근태 수정",
      "method": "PATCH",
      "endpoint": "/attendances/{{create_attendance.manual_attendance_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "status": "late",
        "remarks": "수정된 테스트 데이터"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.status": "late"
        }
      }
    },
    {
      "id": "delete_manual_attendance",
      "name": "수동 등록 근태 삭제",
      "method": "DELETE",
      "endpoint": "/attendances/{{create_attendance.manual_attendance_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "delete_checkin_attendance",
      "name": "출퇴근 기록 삭제 (정리)",
      "method": "DELETE",
      "endpoint": "/attendances/{{check_in.attendance_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    }
  ]
}
