Refactor SupabaseConnectionTest component

The SupabaseConnectionTest component was refactored into smaller, more manageable components to improve readability and maintainability.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 12:45:12 +00:00
parent 1e6d360d69
commit 971a1d29e5
10 changed files with 320 additions and 177 deletions

View File

@@ -2,7 +2,7 @@
import { testAuth } from './authTests';
import { testRestApi } from './apiTests';
import { testDatabaseConnection } from './databaseTests';
import { TestResults } from './types';
import { TestResults, TestDebugInfo } from './types';
import { supabase, isValidUrl } from '../client';
import { getSupabaseUrl, getSupabaseKey, isCorsProxyEnabled, getProxyType } from '../config';
@@ -17,7 +17,18 @@ export const testSupabaseConnection = async (): Promise<TestResults> => {
restApi: false,
auth: false,
database: false,
errors: []
errors: [],
debugInfo: {
originalUrl: getSupabaseUrl(),
proxyUrl: '',
usingProxy: isCorsProxyEnabled(),
proxyType: getProxyType(),
keyLength: getSupabaseKey().length,
browserInfo: navigator.userAgent,
timestamp: new Date().toISOString(),
backupProxySuccess: false,
lastErrorDetails: ''
}
};
try {
@@ -40,12 +51,16 @@ export const testSupabaseConnection = async (): Promise<TestResults> => {
} else {
results.proxyUrl = baseUrl; // 기본값
}
// debugInfo에도 proxyUrl 설정
results.debugInfo.proxyUrl = results.proxyUrl;
} else {
results.proxyUrl = results.url; // 프록시 사용 안 함
results.debugInfo.proxyUrl = results.url;
}
// 테스트 실행
const authResults = await testAuth(supabase, results.url);
const authResults = await testAuth(supabase);
const apiResults = await testRestApi(supabase);
const dbResults = await testDatabaseConnection(supabase);
@@ -57,15 +72,20 @@ export const testSupabaseConnection = async (): Promise<TestResults> => {
// 오류 수집
if (!authResults.success && authResults.error) {
results.errors.push(`인증 테스트 실패: ${authResults.error}`);
results.debugInfo.lastErrorDetails += `인증: ${authResults.error}; `;
}
if (!apiResults.success && apiResults.error) {
results.errors.push(`REST API 테스트 실패: ${apiResults.error}`);
results.debugInfo.lastErrorDetails += `API: ${apiResults.error}; `;
}
if (!dbResults.success && dbResults.error) {
results.errors.push(`DB 테스트 실패: ${dbResults.error}`);
results.debugInfo.lastErrorDetails += `DB: ${dbResults.error}; `;
}
} catch (error: any) {
results.errors.push(`테스트 실행 오류: ${error.message || '알 수 없는 오류'}`);
const errorMsg = `테스트 실행 오류: ${error.message || '알 수 없는 오류'}`;
results.errors.push(errorMsg);
results.debugInfo.lastErrorDetails = errorMsg;
}
return results;