import { describe, it, expect } from 'vitest';
import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
import { UserEntity, Role } from '@d8d/user-module';
import { DeliveryAddress } from '@d8d/delivery-address-module';
import { AreaEntity } from '@d8d/geo-areas';
import { Merchant } from '@d8d/merchant-module';
import { Supplier } from '@d8d/supplier-module';
import { File } from '@d8d/file-module';
import { Order } from '../../src/entities';

// 设置集成测试钩子
setupIntegrationDatabaseHooksWithEntities([
  UserEntity, Role, Order, DeliveryAddress, Merchant, Supplier, File, AreaEntity
])

describe('简单实体配置测试', () => {
  it('应该能够正确初始化所有实体', async () => {
    const dataSource = await IntegrationTestDatabase.getDataSource();

    // 验证数据源已正确初始化
    expect(dataSource).toBeDefined();

    // 验证所有实体都已正确注册
    const entityMetadatas = dataSource.entityMetadatas;
    const entityNames = entityMetadatas.map(metadata => metadata.name);

    expect(entityNames).toContain('Order');
    expect(entityNames).toContain('UserEntity');
    expect(entityNames).toContain('DeliveryAddress');
    expect(entityNames).toContain('AreaEntity');
    expect(entityNames).toContain('Merchant');
    expect(entityNames).toContain('Supplier');

    console.log('所有实体已正确注册:', entityNames);
  });
});