- 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>
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Test calendar API endpoint
|
|
*/
|
|
|
|
require('dotenv').config();
|
|
const fetch = require('node-fetch');
|
|
const { generateToken } = require('../src/utils/jwt.util');
|
|
const mongoose = require('mongoose');
|
|
|
|
async function testCalendar() {
|
|
try {
|
|
// Connect to MongoDB to get a real admin user
|
|
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/tractatus_dev');
|
|
|
|
const User = mongoose.model('User', new mongoose.Schema({}, { strict: false, collection: 'users' }));
|
|
const adminUser = await User.findOne({ role: 'admin' });
|
|
|
|
if (!adminUser) {
|
|
console.error('✗ No admin user found in database');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Generate token with real user ID
|
|
const token = generateToken({ userId: adminUser._id.toString(), role: 'admin' });
|
|
|
|
console.log('Testing calendar endpoints...\n');
|
|
|
|
// Test stats endpoint
|
|
console.log('1. Testing GET /api/calendar/stats');
|
|
const statsResponse = await fetch('http://localhost:9000/api/calendar/stats', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
console.log(' Status:', statsResponse.status);
|
|
const statsData = await statsResponse.json();
|
|
console.log(' Response:', JSON.stringify(statsData, null, 2));
|
|
|
|
if (statsResponse.status === 200) {
|
|
console.log(' ✓ Stats endpoint working\n');
|
|
} else {
|
|
console.log(' ✗ Stats endpoint failed\n');
|
|
}
|
|
|
|
// Test tasks endpoint
|
|
console.log('2. Testing GET /api/calendar/tasks');
|
|
const tasksResponse = await fetch('http://localhost:9000/api/calendar/tasks?limit=10', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
console.log(' Status:', tasksResponse.status);
|
|
const tasksData = await tasksResponse.json();
|
|
console.log(' Response:', JSON.stringify(tasksData, null, 2));
|
|
|
|
if (tasksResponse.status === 200) {
|
|
console.log(' ✓ Tasks endpoint working');
|
|
console.log(' ✓ Found', tasksData.tasks ? tasksData.tasks.length : 0, 'tasks');
|
|
} else {
|
|
console.log(' ✗ Tasks endpoint failed');
|
|
}
|
|
|
|
await mongoose.disconnect();
|
|
|
|
} catch (error) {
|
|
console.error('✗ Test failed:', error.message);
|
|
console.error(error.stack);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testCalendar();
|