-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-withdraw-page-connection.cjs
More file actions
65 lines (55 loc) · 2.23 KB
/
test-withdraw-page-connection.cjs
File metadata and controls
65 lines (55 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const axios = require('axios');
const BASE_URL = 'http://localhost:3005';
// Create axios instance similar to frontend
const api = axios.create({
baseURL: BASE_URL,
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
async function testWithdrawPageConnection() {
console.log('🔍 Testing WithdrawPage API connections...\n');
try {
// Step 1: Test basic connectivity
console.log('1. Testing basic connectivity...');
const healthResponse = await api.get('/health');
console.log('✅ Backend health:', healthResponse.data.status);
// Step 2: Test /me endpoint (authentication check)
console.log('\n2. Testing /me endpoint...');
try {
const meResponse = await api.get('/me');
console.log('✅ /me endpoint working:', meResponse.data);
} catch (error) {
console.log('⚠️ /me endpoint failed (expected if not logged in):', error.response?.data?.error || error.message);
}
// Step 3: Test withdrawal requirements endpoint
console.log('\n3. Testing /api/withdrawal-requirements...');
try {
const requirementsResponse = await api.get('/api/withdrawal-requirements');
console.log('✅ Requirements endpoint working:', requirementsResponse.data);
} catch (error) {
console.log('❌ Requirements endpoint failed:');
console.log('Status:', error.response?.status);
console.log('Error:', error.response?.data?.error || error.message);
}
// Step 4: Test withdrawal history endpoint
console.log('\n4. Testing /api/withdrawal-history...');
try {
const historyResponse = await api.get('/api/withdrawal-history');
console.log('✅ History endpoint working:', historyResponse.data);
} catch (error) {
console.log('❌ History endpoint failed:');
console.log('Status:', error.response?.status);
console.log('Error:', error.response?.data?.error || error.message);
}
console.log('\n🎉 WithdrawPage connection test completed!');
} catch (error) {
console.error('❌ Test failed:', error.response?.data || error.message);
if (error.response?.status) {
console.error('Status:', error.response.status);
}
}
}
testWithdrawPageConnection();