fix: Playwright 전메뉴 기능테스트로 발견한 화면 버그 4건 수정
- products: /api/products 가 bare 배열 반환 → PageResponse 정렬(PageHelper).
contracts/rules-commission 의 products?.list.map 크래시 + products 빈목록 동시 해결
- grade-eval: gradeEvalRules 가 PageResponse(.list) 추출하도록 수정 (rowData.map 크래시)
- batch: batch.ts 를 실제 백엔드(/settlement/run body, /jobs/{id}, /jobs)로 정렬 +
VO필드(jobId/currentStep/processedCount/finishedAt/durationSec) 어댑터 매핑
검증: Playwright 84화면 재실행 FAIL 7→3 (잔여 3건은 미구현 /api/report/*)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,19 +29,60 @@ export interface BatchHistoryResp {
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
/** 백엔드 batch_job_log VO (실제 응답 형태) */
|
||||
interface BatchJobVO {
|
||||
jobId: number;
|
||||
jobName: string;
|
||||
status: string; // REQUESTED | STARTED | COMPLETED | FAILED
|
||||
currentStep?: string;
|
||||
totalCount?: number;
|
||||
processedCount?: number;
|
||||
errorCount?: number;
|
||||
errorMessage?: string;
|
||||
startedAt?: number[] | string;
|
||||
finishedAt?: number[] | string;
|
||||
durationSec?: number;
|
||||
}
|
||||
|
||||
/** LocalDateTime 배열([y,M,d,h,m,s,..]) → 'YYYY-MM-DD HH:mm:ss' */
|
||||
function fmtTs(v?: number[] | string): string | undefined {
|
||||
if (v == null) return undefined;
|
||||
if (typeof v === 'string') return v;
|
||||
const [y, mo, d, h = 0, mi = 0, s = 0] = v;
|
||||
const p = (n: number) => String(n).padStart(2, '0');
|
||||
return `${y}-${p(mo)}-${p(d)} ${p(h)}:${p(mi)}:${p(s)}`;
|
||||
}
|
||||
|
||||
function mapStatus(s: string): BatchJobLogResp['status'] {
|
||||
if (s === 'STARTED') return 'RUNNING';
|
||||
if (s === 'REQUESTED' || s === 'RUNNING' || s === 'COMPLETED' || s === 'FAILED') return s;
|
||||
return 'RUNNING';
|
||||
}
|
||||
|
||||
/** 백엔드 VO → 프론트 BatchJobLogResp 어댑터 */
|
||||
function toJobLog(v: BatchJobVO): BatchJobLogResp {
|
||||
return {
|
||||
jobLogId: v.jobId,
|
||||
jobName: v.jobName,
|
||||
status: mapStatus(v.status),
|
||||
stepName: v.currentStep,
|
||||
totalCount: v.totalCount,
|
||||
successCount: v.processedCount,
|
||||
errorCount: v.errorCount,
|
||||
startedAt: fmtTs(v.startedAt),
|
||||
endedAt: fmtTs(v.finishedAt),
|
||||
durationMs: v.durationSec != null ? v.durationSec * 1000 : undefined,
|
||||
errorMessage: v.errorMessage,
|
||||
};
|
||||
}
|
||||
|
||||
export const batchRunApi = {
|
||||
run: (settleMonth: string, companyCode?: string) =>
|
||||
unwrap<number>(
|
||||
api.post('/api/batch/settlement/run', null, {
|
||||
params: { settleMonth, companyCode },
|
||||
}),
|
||||
),
|
||||
unwrap<number>(api.post('/api/batch/settlement/run', { settleMonth, companyCode })),
|
||||
status: (jobLogId: number) =>
|
||||
unwrap<BatchJobLogResp>(
|
||||
api.get('/api/batch/settlement/status', { params: { jobLogId } }),
|
||||
),
|
||||
unwrap<BatchJobVO>(api.get(`/api/batch/jobs/${jobLogId}`)).then(toJobLog),
|
||||
history: (size = 10) =>
|
||||
unwrap<BatchHistoryResp[]>(
|
||||
api.get('/api/batch/settlement/history', { params: { size } }),
|
||||
unwrap<BatchJobVO[]>(api.get('/api/batch/jobs')).then((rows) =>
|
||||
rows.slice(0, size).map(toJobLog) as BatchHistoryResp[],
|
||||
),
|
||||
};
|
||||
|
||||
@@ -153,9 +153,9 @@ export const operationApi = {
|
||||
hqSettleDelete: (id: number) =>
|
||||
unwrap<void>(api.delete(`/api/hq-settles/${id}`)),
|
||||
|
||||
// GradeEval Rules
|
||||
// GradeEval Rules — 백엔드는 PageResponse({list}) 반환이므로 .list 추출
|
||||
gradeEvalRules: () =>
|
||||
unwrap<GradeEvalRuleRow[]>(api.get('/api/grade-evaluations/rules')),
|
||||
unwrap<{ list: GradeEvalRuleRow[] }>(api.get('/api/grade-evaluations/rules')).then((r) => r.list ?? []),
|
||||
gradeEvalRuleGet: (id: number) =>
|
||||
unwrap<GradeEvalRuleRow>(api.get(`/api/grade-evaluations/rules/${id}`)),
|
||||
gradeEvalRuleCreate: (body: Partial<GradeEvalRuleRow>) =>
|
||||
|
||||
Reference in New Issue
Block a user