import fetch from 'node-fetch'; async function testServerWebDAV() { try { console.log('🔍 Testing Server WebDAV via API:'); console.log(''); // Test the storage sync endpoint console.log('1️⃣ Testing storage sync endpoint...'); const response = await fetch('http://localhost:3000/api/music/sync-s3', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ force: true }) }); if (response.ok) { const result = await response.json(); console.log('✅ Storage sync started:', result); console.log(''); // Wait a bit and check job progress console.log('2️⃣ Waiting for job to start...'); await new Promise(resolve => setTimeout(resolve, 5000)); const jobsResponse = await fetch('http://localhost:3000/api/background-jobs/jobs'); if (jobsResponse.ok) { const jobs = await jobsResponse.json(); const latestJob = jobs.jobs[jobs.jobs.length - 1]; console.log('📊 Latest job status:', { jobId: latestJob.jobId, status: latestJob.status, progress: latestJob.progress, message: latestJob.message, current: latestJob.current, total: latestJob.total }); if (latestJob.result) { console.log('📊 Job result:', latestJob.result); } } } else { console.error('❌ Failed to start storage sync:', response.status, response.statusText); } } catch (error) { console.error('❌ Failed to test server WebDAV:', error); } } // Run the test testServerWebDAV().catch(console.error);