test-web-interface.js•3.62 kB
#!/usr/bin/env node
/**
* Coolify 웹 인터페이스 자동화 테스트
* MCP Playwright 서버를 사용하여 Coolify 초기 설정 자동화
*/
async function testCoolifyWebInterface() {
let browser = null;
let page = null;
try {
console.log('🌐 Coolify 웹 인터페이스 테스트 시작...');
// 브라우저 시작
browser = await chromium.launch({
headless: false, // 브라우저 UI 표시
slowMo: 1000 // 액션 간 1초 대기
});
page = await browser.newPage();
// Coolify 접속
console.log('🔗 http://localhost:8000 접속 중...');
await page.goto('http://localhost:8000', { waitUntil: 'networkidle' });
// 페이지 제목 확인
const title = await page.title();
console.log(`📄 페이지 제목: ${title}`);
// 스크린샷 촬영
await page.screenshot({ path: 'coolify-screenshot.png', fullPage: true });
console.log('📸 스크린샷 저장: coolify-screenshot.png');
// 페이지 내용 확인
const bodyText = await page.textContent('body');
if (bodyText.includes('Coolify') || bodyText.includes('Login') || bodyText.includes('Register')) {
console.log('✅ Coolify 인터페이스 정상 로드됨');
// 주요 요소들 확인
const elements = await page.$$eval('*', (elements) => {
return elements
.map(el => el.tagName.toLowerCase())
.filter((tag, index, array) => array.indexOf(tag) === index)
.sort();
});
console.log('🏗️ 발견된 HTML 요소들:', elements.slice(0, 10).join(', '), '...');
} else {
console.log('❌ Coolify 인터페이스를 찾을 수 없음');
console.log('페이지 내용 미리보기:', bodyText.substring(0, 200));
}
// 5초 대기 (사용자가 확인할 수 있도록)
console.log('⏳ 5초 대기 중... (브라우저 창을 확인하세요)');
await page.waitForTimeout(5000);
} catch (error) {
console.log('❌ 테스트 오류:', error.message);
if (error.message.includes('net::ERR_CONNECTION_REFUSED')) {
console.log('💡 해결 방법: demo-server가 실행 중인지 확인하세요');
console.log(' 명령어: cd demo-server && docker compose ps');
}
} finally {
if (browser) {
await browser.close();
console.log('🔒 브라우저 종료됨');
}
}
}
// Playwright 설치 확인
async function checkPlaywright() {
try {
require('playwright');
return true;
} catch (error) {
console.log('❌ Playwright가 설치되지 않았습니다.');
console.log('💡 설치 명령어: npm install playwright');
console.log('🎭 브라우저 설치: npx playwright install');
return false;
}
}
// 메인 실행
async function main() {
const playwrightInstalled = await checkPlaywright();
if (playwrightInstalled) {
await testCoolifyWebInterface();
} else {
console.log('\n🎯 Playwright 설치 후 다시 실행해주세요:');
console.log(' npm install playwright');
console.log(' npx playwright install');
console.log(' node test-web-interface.js');
}
}
main().catch(console.error);