Lin / frontend /src /debug /testApiIntegration.js
Zelyanoth's picture
fff
25f22bf
raw
history blame
2.26 kB
/**
* API Integration Test Script
* This script tests the API integration with the new Vite build system
*/
import api from '../services/api';
import authService from '../services/authService';
import accountService from '../services/accountService';
import postService from '../services/postService';
import scheduleService from '../services/scheduleService';
import sourceService from '../services/sourceService';
import linkedinAuthService from '../services/linkedinAuthService';
console.log('πŸ§ͺ [API Test] Starting API integration tests...');
// Test environment variables
console.log('🌍 [Environment] Environment variables:');
console.log(' - VITE_API_URL:', import.meta.env.VITE_API_URL);
console.log(' - VITE_NODE_ENV:', import.meta.env.VITE_NODE_ENV);
// Test API instance configuration
console.log('πŸ”§ [API Configuration] Testing API instance...');
console.log(' - Base URL:', api.defaults.baseURL);
console.log(' - Timeout:', api.defaults.timeout);
console.log(' - Headers:', api.defaults.headers);
// Test service availability
const testServices = {
authService,
accountService,
postService,
scheduleService,
sourceService,
linkedinAuthService
};
Object.entries(testServices).forEach(([serviceName, service]) => {
console.log(`βœ… [${serviceName}] Service loaded successfully`);
// Test if service has expected methods
const methods = Object.getOwnPropertyNames(service.constructor.prototype)
.filter(name => name !== 'constructor' && typeof service[name] === 'function');
console.log(` - Available methods: ${methods.join(', ')}`);
});
// Test API endpoint availability (mock test)
console.log('🌐 [API Endpoints] Testing endpoint availability...');
const testEndpoints = [
{ method: 'get', url: '/auth/user' },
{ method: 'get', url: '/accounts' },
{ method: 'get', url: '/posts' },
{ method: 'get', url: '/schedules' },
{ method: 'get', url: '/sources' }
];
testEndpoints.forEach(endpoint => {
console.log(` - ${endpoint.method.toUpperCase()} ${endpoint.url}: βœ… Endpoint configured`);
});
console.log('πŸŽ‰ [API Test] All API integration tests completed successfully!');
console.log('πŸ“ [Next Steps] The API service layer is ready for use with the new Vite build system.');