web_ppt_7.7 / backend /test-simple-fix.js
CatPtain's picture
Upload 85 files
28e1dba verified
import huggingfaceStorageService from './src/services/huggingfaceStorageService.js';
// 简单测试Huggingface环境修复
async function testSimpleFix() {
console.log('🧪 Testing Huggingface storage fix...');
try {
// 测试存储服务初始化
console.log('\n📁 Testing storage service initialization...');
await huggingfaceStorageService.initialize();
console.log('✅ Storage service initialized successfully');
console.log(`📁 Data directory: ${huggingfaceStorageService.dataDir}`);
// 测试目录创建
console.log('\n📂 Testing directory creation...');
const testUserId = 'PS02';
const testPptId = 'test-ppt-' + Date.now();
try {
await huggingfaceStorageService.storePPTData(testUserId, testPptId, {
title: 'Test PPT for Huggingface',
slides: [{
id: 'slide1',
elements: [{
type: 'text',
content: 'Hello Huggingface!'
}]
}]
});
console.log('✅ PPT data storage test passed - no permission errors!');
// 测试数据读取
const storedData = await huggingfaceStorageService.getPPTData(testUserId, testPptId);
if (storedData && storedData.title === 'Test PPT for Huggingface') {
console.log('✅ PPT data retrieval test passed!');
} else {
console.log('⚠️ PPT data retrieval test failed');
}
} catch (storageError) {
console.error('❌ PPT data storage test failed:', storageError.message);
if (storageError.code === 'EACCES') {
console.error('🚨 Permission denied error - the fix may not be working in production');
}
}
console.log('\n🎉 Core storage tests completed!');
} catch (error) {
console.error('❌ Test failed:', error.message);
}
}
// 运行测试
testSimpleFix().catch(console.error);