저장버튼 제어기능 (insert)
This commit is contained in:
287
test-dataflow-features.js
Normal file
287
test-dataflow-features.js
Normal file
@@ -0,0 +1,287 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* 🔥 버튼 제어관리 기능 수동 테스트 스크립트
|
||||
*
|
||||
* Jest가 없는 환경에서 기본적인 기능들을 검증합니다.
|
||||
*/
|
||||
|
||||
const axios = require("axios");
|
||||
|
||||
// 설정
|
||||
const BACKEND_URL = "http://localhost:8080";
|
||||
const FRONTEND_URL = "http://localhost:3000";
|
||||
|
||||
// 테스트 데이터
|
||||
const mockButtonConfig = {
|
||||
actionType: "save",
|
||||
enableDataflowControl: true,
|
||||
dataflowTiming: "after",
|
||||
dataflowConfig: {
|
||||
controlMode: "simple",
|
||||
selectedDiagramId: 1,
|
||||
selectedRelationshipId: "rel-123",
|
||||
},
|
||||
};
|
||||
|
||||
const mockContextData = {
|
||||
testField: "test-value",
|
||||
status: "active",
|
||||
userId: "test-user",
|
||||
};
|
||||
|
||||
// 테스트 결과 저장
|
||||
let testResults = [];
|
||||
|
||||
// 유틸리티 함수들
|
||||
function log(message, type = "info") {
|
||||
const timestamp = new Date().toISOString();
|
||||
const prefix = {
|
||||
info: "📋",
|
||||
success: "✅",
|
||||
error: "❌",
|
||||
warning: "⚠️",
|
||||
performance: "⚡",
|
||||
}[type];
|
||||
|
||||
console.log(`${prefix} [${timestamp}] ${message}`);
|
||||
}
|
||||
|
||||
function measureTime(name, fn) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
const result = await fn();
|
||||
const endTime = performance.now();
|
||||
const duration = endTime - startTime;
|
||||
|
||||
testResults.push({
|
||||
name,
|
||||
duration,
|
||||
success: true,
|
||||
result,
|
||||
});
|
||||
|
||||
log(`${name}: ${duration.toFixed(2)}ms`, "performance");
|
||||
resolve({ result, duration });
|
||||
} catch (error) {
|
||||
const endTime = performance.now();
|
||||
const duration = endTime - startTime;
|
||||
|
||||
testResults.push({
|
||||
name,
|
||||
duration,
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
|
||||
log(
|
||||
`${name} FAILED: ${error.message} (${duration.toFixed(2)}ms)`,
|
||||
"error"
|
||||
);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 테스트 함수들
|
||||
async function testBackendHealthCheck() {
|
||||
try {
|
||||
const response = await axios.get(`${BACKEND_URL}/health`);
|
||||
log("백엔드 서버 상태: 정상", "success");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
log("백엔드 서버 연결 실패", "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testFrontendHealthCheck() {
|
||||
try {
|
||||
const response = await axios.get(`${FRONTEND_URL}`);
|
||||
log("프론트엔드 서버 상태: 정상", "success");
|
||||
return { status: "ok" };
|
||||
} catch (error) {
|
||||
log("프론트엔드 서버 연결 실패", "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testTestModeStatus() {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${BACKEND_URL}/api/test-button-dataflow/test-status`
|
||||
);
|
||||
log("테스트 모드 상태: 정상", "success");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
log(`테스트 모드 확인 실패: ${error.message}`, "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testButtonDataflowConfig() {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${BACKEND_URL}/api/test-button-dataflow/config/test-button-1`
|
||||
);
|
||||
log("버튼 설정 조회: 성공", "success");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
log(`버튼 설정 조회 실패: ${error.message}`, "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testDataflowDiagrams() {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${BACKEND_URL}/api/test-button-dataflow/diagrams`
|
||||
);
|
||||
log("관계도 목록 조회: 성공", "success");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
log(`관계도 목록 조회 실패: ${error.message}`, "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testOptimizedExecution() {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${BACKEND_URL}/api/test-button-dataflow/execute-optimized`,
|
||||
{
|
||||
buttonId: "test-button-optimized",
|
||||
actionType: "save",
|
||||
buttonConfig: mockButtonConfig,
|
||||
contextData: mockContextData,
|
||||
companyCode: "DEFAULT",
|
||||
}
|
||||
);
|
||||
log("최적화된 실행: 성공", "success");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
log(`최적화된 실행 실패: ${error.message}`, "error");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function testPerformanceLoad() {
|
||||
const requests = 10;
|
||||
const promises = [];
|
||||
|
||||
log(`성능 부하 테스트 시작 (${requests}개 요청)`, "info");
|
||||
|
||||
for (let i = 0; i < requests; i++) {
|
||||
promises.push(
|
||||
axios.post(`${BACKEND_URL}/api/test-button-dataflow/execute-optimized`, {
|
||||
buttonId: `load-test-button-${i}`,
|
||||
actionType: "save",
|
||||
buttonConfig: mockButtonConfig,
|
||||
contextData: { ...mockContextData, index: i },
|
||||
companyCode: "DEFAULT",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
const responses = await Promise.allSettled(promises);
|
||||
const successful = responses.filter((r) => r.status === "fulfilled").length;
|
||||
const failed = responses.filter((r) => r.status === "rejected").length;
|
||||
|
||||
log(
|
||||
`부하 테스트 완료: 성공 ${successful}개, 실패 ${failed}개`,
|
||||
failed === 0 ? "success" : "warning"
|
||||
);
|
||||
|
||||
return { successful, failed, total: requests };
|
||||
}
|
||||
|
||||
// 메인 테스트 실행
|
||||
async function runAllTests() {
|
||||
log("🔥 버튼 제어관리 기능 테스트 시작", "info");
|
||||
log("=".repeat(50), "info");
|
||||
|
||||
const tests = [
|
||||
{ name: "백엔드 서버 상태 확인", fn: testBackendHealthCheck },
|
||||
{ name: "프론트엔드 서버 상태 확인", fn: testFrontendHealthCheck },
|
||||
{ name: "테스트 모드 상태 확인", fn: testTestModeStatus },
|
||||
{ name: "버튼 설정 조회 테스트", fn: testButtonDataflowConfig },
|
||||
{ name: "관계도 목록 조회 테스트", fn: testDataflowDiagrams },
|
||||
{ name: "최적화된 실행 테스트", fn: testOptimizedExecution },
|
||||
{ name: "성능 부하 테스트", fn: testPerformanceLoad },
|
||||
];
|
||||
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
|
||||
for (const test of tests) {
|
||||
try {
|
||||
await measureTime(test.name, test.fn);
|
||||
passed++;
|
||||
} catch (error) {
|
||||
failed++;
|
||||
// 테스트 실패해도 계속 진행
|
||||
}
|
||||
|
||||
// 각 테스트 사이에 잠시 대기
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
|
||||
// 결과 요약
|
||||
log("=".repeat(50), "info");
|
||||
log("📊 테스트 결과 요약", "info");
|
||||
log(`총 테스트: ${tests.length}개`, "info");
|
||||
log(`성공: ${passed}개`, "success");
|
||||
log(`실패: ${failed}개`, failed > 0 ? "error" : "success");
|
||||
|
||||
// 성능 메트릭
|
||||
const successfulTests = testResults.filter((r) => r.success);
|
||||
if (successfulTests.length > 0) {
|
||||
const avgDuration =
|
||||
successfulTests.reduce((sum, t) => sum + t.duration, 0) /
|
||||
successfulTests.length;
|
||||
const maxDuration = Math.max(...successfulTests.map((t) => t.duration));
|
||||
const minDuration = Math.min(...successfulTests.map((t) => t.duration));
|
||||
|
||||
log("⚡ 성능 메트릭", "performance");
|
||||
log(`평균 응답시간: ${avgDuration.toFixed(2)}ms`, "performance");
|
||||
log(`최대 응답시간: ${maxDuration.toFixed(2)}ms`, "performance");
|
||||
log(`최소 응답시간: ${minDuration.toFixed(2)}ms`, "performance");
|
||||
}
|
||||
|
||||
// 상세 결과
|
||||
log("📋 상세 결과", "info");
|
||||
testResults.forEach((result) => {
|
||||
const status = result.success ? "✅" : "❌";
|
||||
const duration = result.duration.toFixed(2);
|
||||
log(` ${status} ${result.name}: ${duration}ms`, "info");
|
||||
if (!result.success) {
|
||||
log(` 오류: ${result.error}`, "error");
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
total: tests.length,
|
||||
passed,
|
||||
failed,
|
||||
results: testResults,
|
||||
};
|
||||
}
|
||||
|
||||
// 스크립트 실행
|
||||
if (require.main === module) {
|
||||
runAllTests()
|
||||
.then((summary) => {
|
||||
log("🎯 모든 테스트 완료", "success");
|
||||
process.exit(summary.failed === 0 ? 0 : 1);
|
||||
})
|
||||
.catch((error) => {
|
||||
log(`예상치 못한 오류 발생: ${error.message}`, "error");
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
runAllTests,
|
||||
testResults,
|
||||
};
|
||||
Reference in New Issue
Block a user