| | import api from '../services/api'; |
| |
|
| | |
| | export const testApiStructure = async () => { |
| | try { |
| | console.log('🧪 [TEST] Starting API structure test...'); |
| | |
| | |
| | console.log('🧪 [TEST] Testing /accounts endpoint...'); |
| | const response = await api.get('/accounts'); |
| | |
| | console.log('🧪 [TEST] Raw response:', response); |
| | console.log('🧪 [TEST] Response data:', response.data); |
| | console.log('🧪 [TEST] Response data type:', typeof response.data); |
| | console.log('🧪 [TEST] Response data is array:', Array.isArray(response.data)); |
| | |
| | if (response.data) { |
| | console.log('🧪 [TEST] Response data keys:', Object.keys(response.data)); |
| | |
| | if (response.data.success) { |
| | console.log('🧪 [TEST] Response is successful'); |
| | if (response.data.accounts) { |
| | console.log('🧪 [TEST] Accounts found:', response.data.accounts.length); |
| | console.log('🧪 [TEST] Accounts type:', typeof response.data.accounts); |
| | console.log('🧪 [TEST] Accounts is array:', Array.isArray(response.data.accounts)); |
| | |
| | |
| | const linkedinAccounts = response.data.accounts.filter( |
| | account => account && account.social_network && account.social_network.toLowerCase() === 'linkedin' |
| | ); |
| | console.log('🧪 [TEST] LinkedIn accounts found:', linkedinAccounts.length); |
| | console.log('🧪 [TEST] LinkedIn accounts:', linkedinAccounts); |
| | } |
| | } else { |
| | console.log('🧪 [TEST] Response not successful'); |
| | } |
| | } |
| | |
| | return response; |
| | } catch (error) { |
| | console.error('🧪 [TEST] API test failed:', error); |
| | return error; |
| | } |
| | }; |
| |
|
| | |
| | export const testServiceBehavior = async () => { |
| | try { |
| | console.log('🧪 [TEST] Testing service behavior...'); |
| | |
| | const response = await api.get('/accounts'); |
| | |
| | |
| | let accounts = []; |
| | |
| | if (response.data && response.data.success && response.data.accounts) { |
| | console.log('🧪 [TEST] Format 1: success + accounts structure'); |
| | accounts = response.data.accounts; |
| | } else if (Array.isArray(response.data)) { |
| | console.log('🧪 [TEST] Format 2: Direct array'); |
| | accounts = response.data; |
| | } else { |
| | console.error('🧪 [TEST] Unexpected response format:', response.data); |
| | throw new Error('Unexpected response format from API'); |
| | } |
| | |
| | console.log('🧪 [TEST] All accounts:', accounts); |
| | |
| | |
| | const linkedinAccounts = accounts.filter( |
| | account => account && account.social_network && account.social_network.toLowerCase() === 'linkedin' |
| | ); |
| | |
| | console.log('🧪 [TEST] Filtered LinkedIn accounts:', linkedinAccounts); |
| | return linkedinAccounts; |
| | } catch (error) { |
| | console.error('🧪 [TEST] Service test failed:', error); |
| | return []; |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |