Fix jwt-token
This commit is contained in:
@@ -113,10 +113,12 @@ describe('AlertService', () => {
|
||||
describe('checkAlertRules', () => {
|
||||
it('should trigger alert when detection meets rule criteria', async () => {
|
||||
const tenant = await createTestTenant();
|
||||
const user = await createTestUser({ tenant_id: tenant.id });
|
||||
const device = await createTestDevice({ tenant_id: tenant.id });
|
||||
|
||||
// Create alert rule
|
||||
await models.AlertRule.create({
|
||||
user_id: user.id,
|
||||
tenant_id: tenant.id,
|
||||
name: 'Test Rule',
|
||||
drone_type: 2,
|
||||
@@ -140,10 +142,12 @@ describe('AlertService', () => {
|
||||
|
||||
it('should not trigger alert when detection does not meet criteria', async () => {
|
||||
const tenant = await createTestTenant();
|
||||
const user = await createTestUser({ tenant_id: tenant.id });
|
||||
const device = await createTestDevice({ tenant_id: tenant.id });
|
||||
|
||||
// Create alert rule with strict criteria
|
||||
await models.AlertRule.create({
|
||||
user_id: user.id,
|
||||
tenant_id: tenant.id,
|
||||
name: 'Strict Rule',
|
||||
drone_type: 2,
|
||||
@@ -165,10 +169,12 @@ describe('AlertService', () => {
|
||||
|
||||
it('should not trigger alert for inactive rules', async () => {
|
||||
const tenant = await createTestTenant();
|
||||
const user = await createTestUser({ tenant_id: tenant.id });
|
||||
const device = await createTestDevice({ tenant_id: tenant.id });
|
||||
|
||||
// Create inactive alert rule
|
||||
await models.AlertRule.create({
|
||||
user_id: user.id,
|
||||
tenant_id: tenant.id,
|
||||
name: 'Inactive Rule',
|
||||
drone_type: 2,
|
||||
@@ -189,10 +195,12 @@ describe('AlertService', () => {
|
||||
|
||||
it('should handle multiple matching rules', async () => {
|
||||
const tenant = await createTestTenant();
|
||||
const user = await createTestUser({ tenant_id: tenant.id });
|
||||
const device = await createTestDevice({ tenant_id: tenant.id });
|
||||
|
||||
// Create multiple alert rules
|
||||
await models.AlertRule.create({
|
||||
user_id: user.id,
|
||||
tenant_id: tenant.id,
|
||||
name: 'Rule 1',
|
||||
drone_type: 2,
|
||||
@@ -201,6 +209,7 @@ describe('AlertService', () => {
|
||||
});
|
||||
|
||||
await models.AlertRule.create({
|
||||
user_id: user.id,
|
||||
tenant_id: tenant.id,
|
||||
name: 'Rule 2',
|
||||
min_rssi: -70, // No specific drone type
|
||||
|
||||
@@ -214,12 +214,16 @@ async function createTestDevice(deviceData = {}) {
|
||||
}
|
||||
|
||||
if (!tenant) {
|
||||
tenant = await Tenant.create({
|
||||
// Use manual UUID generation for tenant creation
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const tenantWithId = {
|
||||
id: uuidv4(),
|
||||
name: 'Test Tenant',
|
||||
slug: 'test-tenant-' + uniqueSuffix,
|
||||
domain: 'test-' + uniqueSuffix + '.example.com',
|
||||
is_active: true
|
||||
});
|
||||
};
|
||||
tenant = await Tenant.create(tenantWithId);
|
||||
}
|
||||
|
||||
const defaultDeviceData = {
|
||||
|
||||
Reference in New Issue
Block a user