- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Test sync health endpoint
|
|
* Verifies graceful handling of MongoDB disconnection
|
|
*/
|
|
|
|
require('dotenv').config();
|
|
const fetch = require('node-fetch');
|
|
const { generateToken } = require('../src/utils/jwt.util');
|
|
|
|
async function testSyncHealth() {
|
|
try {
|
|
// Generate admin token using proper utility
|
|
const token = generateToken({ userId: 'admin', role: 'admin' });
|
|
|
|
console.log('Testing sync health endpoint...\n');
|
|
|
|
// Test sync health endpoint
|
|
const response = await fetch('http://localhost:9000/api/admin/sync/health', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
console.log('Status:', response.status);
|
|
console.log('Response:', JSON.stringify(data, null, 2));
|
|
|
|
if (response.status === 200 && data.success) {
|
|
console.log('\n✓ Endpoint responding correctly');
|
|
if (data.health.status === 'warning' && data.health.message.includes('Database not connected')) {
|
|
console.log('✓ MongoDB disconnection handled gracefully');
|
|
console.log('✓ Recommendations provided:', data.health.recommendations);
|
|
} else if (data.health.status === 'healthy') {
|
|
console.log('✓ MongoDB connected and sync healthy');
|
|
}
|
|
} else {
|
|
console.log('\n✗ Endpoint returned error');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('✗ Test failed:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testSyncHealth();
|