Fix jwt-token
This commit is contained in:
@@ -94,6 +94,11 @@ async function setupTestEnvironment() {
|
||||
// Store models globally for routes to access
|
||||
global.__TEST_MODELS__ = models;
|
||||
|
||||
// Debug info
|
||||
console.log(`🔧 DEBUG: Test sequelize instance: ${sequelize.constructor.name}`);
|
||||
console.log(`🔧 DEBUG: Test database storage: ${sequelize.options.storage}`);
|
||||
console.log(`🔧 DEBUG: Global models set:`, Object.keys(global.__TEST_MODELS__));
|
||||
|
||||
// Sync database
|
||||
await sequelize.sync({ force: true });
|
||||
|
||||
@@ -197,14 +202,25 @@ async function createTestDevice(deviceData = {}) {
|
||||
|
||||
// If a specific ID is provided, use upsert to ensure it's respected
|
||||
if (deviceData.id) {
|
||||
console.log(`🔧 DEBUG: Creating device with specific ID: ${deviceData.id} (type: ${typeof deviceData.id})`);
|
||||
console.log(`🔧 DEBUG: Device data:`, defaultDeviceData);
|
||||
const [device, created] = await Device.upsert(defaultDeviceData, {
|
||||
returning: true
|
||||
});
|
||||
console.log(`🔧 DEBUG: Device ${created ? 'created' : 'updated'}: ID=${device.id} (type: ${typeof device.id}), approved=${device.is_approved}`);
|
||||
|
||||
// Verify the device exists immediately after creation
|
||||
const verification = await Device.findByPk(device.id);
|
||||
console.log(`🔧 DEBUG: Verification lookup: ${verification ? `Found device ${verification.id}` : 'Device not found after creation!'}`);
|
||||
|
||||
return device;
|
||||
} else {
|
||||
// Auto-generate ID when none provided
|
||||
defaultDeviceData.id = Math.floor(Math.random() * 1000000000);
|
||||
return await Device.create(defaultDeviceData);
|
||||
console.log(`🔧 DEBUG: Creating device with auto-generated ID: ${defaultDeviceData.id}`);
|
||||
const device = await Device.create(defaultDeviceData);
|
||||
console.log(`🔧 DEBUG: Auto-generated device created: ID=${device.id}, approved=${device.is_approved}`);
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user