|
|
@@ -4,8 +4,8 @@ import {
|
|
|
IntegrationTestDatabase,
|
|
|
setupIntegrationDatabaseHooksWithEntities
|
|
|
} from '@d8d/shared-test-util';
|
|
|
-import { PaymentRoutes } from '../../src/routes/payment.routes.js';
|
|
|
-import { PaymentEntity } from '../../src/entities/payment.entity.js';
|
|
|
+import { PaymentMtRoutes } from '../../src/routes/payment.mt.routes.js';
|
|
|
+import { PaymentMtEntity } from '../../src/entities/payment.mt.entity.js';
|
|
|
import { PaymentStatus } from '../../src/entities/payment.types.js';
|
|
|
import { UserEntity } from '@d8d/user-module';
|
|
|
import { Role } from '@d8d/user-module';
|
|
|
@@ -22,17 +22,17 @@ config({ path: resolve(process.cwd(), '.env.test') });
|
|
|
vi.mock('wechatpay-node-v3')
|
|
|
|
|
|
// 设置集成测试钩子
|
|
|
-setupIntegrationDatabaseHooksWithEntities([PaymentEntity, UserEntity, File, Role])
|
|
|
+setupIntegrationDatabaseHooksWithEntities([PaymentMtEntity, UserEntity, File, Role])
|
|
|
|
|
|
describe('支付API集成测试', () => {
|
|
|
- let client: ReturnType<typeof testClient<typeof PaymentRoutes>>;
|
|
|
+ let client: ReturnType<typeof testClient<typeof PaymentMtRoutes>>;
|
|
|
let testToken: string;
|
|
|
let testUser: UserEntity;
|
|
|
- let testPayment: PaymentEntity;
|
|
|
+ let testPayment: PaymentMtEntity;
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
// 创建测试客户端
|
|
|
- client = testClient(PaymentRoutes);
|
|
|
+ client = testClient(PaymentMtRoutes);
|
|
|
|
|
|
// 创建测试用户并生成token
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
@@ -54,10 +54,11 @@ describe('支付API集成测试', () => {
|
|
|
});
|
|
|
|
|
|
// 创建测试支付记录 - 使用不同的外部订单ID避免冲突
|
|
|
- const paymentRepository = dataSource.getRepository(PaymentEntity);
|
|
|
+ const paymentRepository = dataSource.getRepository(PaymentMtEntity);
|
|
|
testPayment = paymentRepository.create({
|
|
|
externalOrderId: 999, // 使用一个不会与测试冲突的ID
|
|
|
userId: testUser.id,
|
|
|
+ tenantId: 1, // 添加租户ID
|
|
|
totalAmount: 20000,
|
|
|
description: '测试支付',
|
|
|
paymentStatus: PaymentStatus.PENDING,
|
|
|
@@ -199,7 +200,7 @@ describe('支付API集成测试', () => {
|
|
|
it('应该验证支付状态', async () => {
|
|
|
// 更新支付状态为已支付
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
- const paymentRepository = dataSource.getRepository(PaymentEntity);
|
|
|
+ const paymentRepository = dataSource.getRepository(PaymentMtEntity);
|
|
|
await paymentRepository.update(testPayment.id, {
|
|
|
paymentStatus: PaymentStatus.PAID
|
|
|
});
|
|
|
@@ -375,7 +376,7 @@ describe('支付API集成测试', () => {
|
|
|
|
|
|
// 验证支付状态已更新为处理中
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
- const paymentRepository = dataSource.getRepository(PaymentEntity);
|
|
|
+ const paymentRepository = dataSource.getRepository(PaymentMtEntity);
|
|
|
const updatedPayment = await paymentRepository.findOne({
|
|
|
where: { externalOrderId: testPayment.externalOrderId }
|
|
|
});
|