← back to Dear Bubbe Nextjs

archived/tests/test-auto-post.js

40 lines

// Test automatic posting integration
const axios = require('axios');

async function testAutoPost() {
  console.log('🧪 Testing automatic Twitter posting integration...\n');
  
  // Create a test conversation
  const testData = {
    messageId: 'test-' + Date.now(),
    timestamp: new Date().toISOString(),
    userId: 'test-user-123',
    userName: 'Test User',
    location: 'New York, NY',
    userMessage: "My mother-in-law keeps criticizing my cooking. What should I do?",
    bubbeResponse: "Oy vey, your cooking must be really terrible if even your mother-in-law notices! What are you making, cardboard? Listen bubbeleh, either learn to cook or order takeout and pretend you made it. Works every time!",
    mode: 'bubbe'
  };
  
  try {
    // Send to admin dashboard for immediate posting
    const response = await axios.post('http://45.61.58.125:5013/api/social-post-now', testData);
    
    console.log('✅ Request sent successfully!');
    console.log('Response:', response.data);
    
    if (response.data.results && response.data.results.twitter) {
      console.log('\n🎉 Tweet posted successfully!');
      console.log('Check it out on Twitter/X');
    } else {
      console.log('\n⚠️ Tweet was not posted. Check logs for details.');
    }
  } catch (error) {
    console.error('❌ Error:', error.message);
    if (error.response) {
      console.error('Response data:', error.response.data);
    }
  }
}

testAutoPost();