Files
tk-factory-services/system1-factory/api/tests/helpers/mockData.js
Hyungi Ahn 550633b89d feat: 3-System 분리 프로젝트 초기 코드 작성
TK-FB(공장관리+신고)와 M-Project(부적합관리)를 3개 독립 시스템으로
분리하기 위한 전체 코드 구조 작성.
- SSO 인증 서비스 (bcrypt + pbkdf2 이중 해시 지원)
- System 1: 공장관리 (TK-FB 기반, 신고 코드 제거)
- System 2: 신고 (TK-FB에서 workIssue 코드 추출)
- System 3: 부적합관리 (M-Project 기반)
- Gateway 포털 (path-based 라우팅)
- 통합 docker-compose.yml 및 배포 스크립트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:40:11 +09:00

226 lines
4.4 KiB
JavaScript

/**
* 테스트용 더미 데이터
*
* 테스트에서 재사용 가능한 모킹 데이터
*/
// 사용자 더미 데이터
const mockUsers = {
admin: {
id: 1,
username: 'admin',
role: 'admin',
access_level: 5
},
groupLeader: {
id: 2,
username: 'group_leader',
role: 'group_leader',
access_level: 3
},
worker: {
id: 3,
username: 'worker',
role: 'worker',
access_level: 1
}
};
// 작업자 더미 데이터
const mockWorkers = [
{
worker_id: 1,
worker_name: '김철수',
job_type: 'developer',
is_active: 1,
created_at: '2025-01-01 00:00:00'
},
{
worker_id: 2,
worker_name: '이영희',
job_type: 'designer',
is_active: 1,
created_at: '2025-01-01 00:00:00'
},
{
worker_id: 3,
worker_name: '박민수',
job_type: 'developer',
is_active: 0,
created_at: '2025-01-01 00:00:00'
}
];
// 프로젝트 더미 데이터
const mockProjects = [
{
project_id: 1,
project_name: '프로젝트 A',
job_no: 'PRJ-001',
created_at: '2025-01-01 00:00:00'
},
{
project_id: 2,
project_name: '프로젝트 B',
job_no: 'PRJ-002',
created_at: '2025-01-15 00:00:00'
}
];
// 작업 유형 더미 데이터
const mockWorkTypes = [
{ id: 1, name: '개발' },
{ id: 2, name: '디자인' },
{ id: 3, name: '테스트' },
{ id: 4, name: '회의' }
];
// 에러 유형 더미 데이터
const mockErrorTypes = [
{ id: 1, name: '버그 수정' },
{ id: 2, name: '재작업' },
{ id: 3, name: '긴급 수정' }
];
// 작업 보고서 더미 데이터
const mockWorkReports = [
{
id: 1,
report_date: '2025-12-11',
worker_id: 1,
project_id: 1,
work_type_id: 1,
work_hours: 8.0,
work_content: '기능 개발',
error_type_id: null,
work_status_id: 1,
created_by: 1,
created_at: '2025-12-11 09:00:00',
updated_at: '2025-12-11 09:00:00'
},
{
id: 2,
report_date: '2025-12-11',
worker_id: 2,
project_id: 1,
work_type_id: 2,
work_hours: 7.5,
work_content: 'UI 디자인',
error_type_id: null,
work_status_id: 1,
created_by: 2,
created_at: '2025-12-11 09:00:00',
updated_at: '2025-12-11 09:00:00'
},
{
id: 3,
report_date: '2025-12-11',
worker_id: 1,
project_id: 2,
work_type_id: 1,
work_hours: 2.0,
work_content: '버그 수정',
error_type_id: 1,
work_status_id: 2,
created_by: 1,
created_at: '2025-12-11 14:00:00',
updated_at: '2025-12-11 14:00:00'
}
];
// 출석 더미 데이터
const mockAttendance = [
{
id: 1,
worker_id: 1,
attendance_date: '2025-12-11',
status: 'work',
regular_hours: 8.0,
overtime_hours: 0.0,
created_by: 1,
created_at: '2025-12-11 09:00:00'
},
{
id: 2,
worker_id: 2,
attendance_date: '2025-12-11',
status: 'vacation',
regular_hours: 0.0,
overtime_hours: 0.0,
created_by: 2,
created_at: '2025-12-11 09:00:00'
}
];
// 분석 데이터 더미
const mockAnalysisData = {
summary: {
total_entries: 100,
total_hours: 800.0,
unique_workers: 10,
unique_projects: 5,
working_days: 20,
avg_hours_per_entry: 8.0,
contributors: 3,
error_entries: 5,
error_rate: 5.0
},
dailyStats: [
{ report_date: '2025-12-01', daily_hours: 40.0, daily_entries: 5, daily_workers: 5 },
{ report_date: '2025-12-02', daily_hours: 35.0, daily_entries: 5, daily_workers: 4 }
]
};
// API 응답 형식
const createSuccessResponse = (data, message = '성공') => ({
success: true,
data,
message
});
const createErrorResponse = (error, message = '오류 발생') => ({
success: false,
error,
message
});
// 날짜 헬퍼
const createDateString = (daysFromToday = 0) => {
const date = new Date();
date.setDate(date.getDate() + daysFromToday);
return date.toISOString().split('T')[0];
};
// DB 쿼리 결과 모킹 헬퍼
const createDbResult = (data, affectedRows = 1, insertId = 1) => {
if (Array.isArray(data)) {
return [data, []]; // [rows, fields]
}
return [
{
affectedRows,
insertId,
changedRows: affectedRows
},
[]
];
};
module.exports = {
// 더미 데이터
mockUsers,
mockWorkers,
mockProjects,
mockWorkTypes,
mockErrorTypes,
mockWorkReports,
mockAttendance,
mockAnalysisData,
// 헬퍼 함수
createSuccessResponse,
createErrorResponse,
createDateString,
createDbResult
};