add changes
This commit is contained in:
48
tests/test-conversion-quick.js
Normal file
48
tests/test-conversion-quick.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const BASE_URL = 'http://localhost:3000/api';
|
||||
|
||||
async function quickTest() {
|
||||
console.log('Creating guest session...');
|
||||
|
||||
const guestResponse = await axios.post(`${BASE_URL}/guest/start-session`, {
|
||||
deviceId: `test_${Date.now()}`
|
||||
});
|
||||
|
||||
const guestToken = guestResponse.data.data.sessionToken;
|
||||
console.log('✅ Guest session created');
|
||||
console.log('Guest ID:', guestResponse.data.data.guestId);
|
||||
|
||||
console.log('\nConverting guest to user...');
|
||||
|
||||
try {
|
||||
const timestamp = Date.now();
|
||||
const response = await axios.post(`${BASE_URL}/guest/convert`, {
|
||||
username: `testuser${timestamp}`,
|
||||
email: `test${timestamp}@example.com`,
|
||||
password: 'Password123'
|
||||
}, {
|
||||
headers: {
|
||||
'X-Guest-Token': guestToken
|
||||
},
|
||||
timeout: 10000 // 10 second timeout
|
||||
});
|
||||
|
||||
console.log('\n✅ Conversion successful!');
|
||||
console.log('User:', response.data.data.user.username);
|
||||
console.log('Migration:', response.data.data.migration);
|
||||
|
||||
} catch (error) {
|
||||
console.error('\n❌ Conversion failed:');
|
||||
if (error.response) {
|
||||
console.error('Status:', error.response.status);
|
||||
console.error('Full response data:', JSON.stringify(error.response.data, null, 2));
|
||||
} else if (error.code === 'ECONNABORTED') {
|
||||
console.error('Request timeout - server took too long to respond');
|
||||
} else {
|
||||
console.error('Error:', error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
quickTest();
|
||||
Reference in New Issue
Block a user