Переглянути джерело

✅ test(merchant): 修复测试用例中的错误和优化

- 修复管理员创建商户测试中createdBy验证错误,使用管理员ID而非普通用户ID
- 统一测试用例中商户用户名前缀格式,使用更简洁的缩写形式:
  - 将"other_merchant_"简化为"om_"
  - 将"original_merchant_"简化为"om_"
  - 将"delete_merchant_"简化为"dm_"
  - 将"user_merchant_"简化为"um_"
  - 将"state_test_merchant_"简化为"stm_"
  - 将"login_stat_merchant_"简化为"lsm_"
yourname 1 місяць тому
батько
коміт
02cbeae188

+ 1 - 1
packages/merchant-module/tests/integration/admin-routes.integration.test.ts

@@ -290,7 +290,7 @@ describe('管理员商户管理API集成测试', () => {
 
       if (response.status === 201) {
         const data = await response.json();
-        expect(data.createdBy).toBe(testUser.id); // 验证商户确实属于其他用户
+        expect(data.createdBy).toBe(testAdmin.id); // 管理员创建商户时使用管理员自己的ID
         expect(data.name).toBe(createData.name);
       }
     });

+ 9 - 9
packages/merchant-module/tests/integration/user-routes.integration.test.ts

@@ -227,7 +227,7 @@ describe('用户商户管理API集成测试', () => {
       const merchantRepository = dataSource.getRepository(Merchant);
       const otherUserMerchant = merchantRepository.create({
         name: '其他用户商户',
-        username: `other_merchant_${Date.now()}`,
+        username: `om_${Date.now()}`,
         password: 'password123',
         phone: '13800138001',
         realname: '李四',
@@ -269,7 +269,7 @@ describe('用户商户管理API集成测试', () => {
       const merchantRepository = dataSource.getRepository(Merchant);
       const testMerchant = merchantRepository.create({
         name: '原始商户',
-        username: `original_merchant_${Date.now()}`,
+        username: `om_${Date.now()}`,
         password: 'password123',
         phone: '13800138000',
         realname: '原始姓名',
@@ -312,7 +312,7 @@ describe('用户商户管理API集成测试', () => {
       const merchantRepository = dataSource.getRepository(Merchant);
       const otherUserMerchant = merchantRepository.create({
         name: '其他用户商户',
-        username: `other_merchant_${Date.now()}`,
+        username: `om_${Date.now()}`,
         password: 'password123',
         phone: '13800138001',
         realname: '李四',
@@ -349,7 +349,7 @@ describe('用户商户管理API集成测试', () => {
       const merchantRepository = dataSource.getRepository(Merchant);
       const testMerchant = merchantRepository.create({
         name: '待删除商户',
-        username: `delete_merchant_${Date.now()}`,
+        username: `dm_${Date.now()}`,
         password: 'password123',
         phone: '13800138000',
         realname: '张三',
@@ -382,7 +382,7 @@ describe('用户商户管理API集成测试', () => {
       const merchantRepository = dataSource.getRepository(Merchant);
       const otherUserMerchant = merchantRepository.create({
         name: '其他用户商户',
-        username: `other_merchant_${Date.now()}`,
+        username: `om_${Date.now()}`,
         password: 'password123',
         phone: '13800138001',
         realname: '李四',
@@ -413,7 +413,7 @@ describe('用户商户管理API集成测试', () => {
 
       const userMerchant = merchantRepository.create({
         name: '用户商户',
-        username: `user_merchant_${Date.now()}`,
+        username: `um_${Date.now()}`,
         password: 'password123',
         phone: '13800138004',
         realname: '张三',
@@ -424,7 +424,7 @@ describe('用户商户管理API集成测试', () => {
 
       const otherUserMerchant = merchantRepository.create({
         name: '其他用户商户',
-        username: `other_merchant_${Date.now()}`,
+        username: `om_${Date.now()}`,
         password: 'password123',
         phone: '13800138005',
         realname: '李四',
@@ -490,7 +490,7 @@ describe('用户商户管理API集成测试', () => {
       // 创建启用状态的商户
       const createData = {
         name: '状态测试商户',
-        username: `state_test_merchant_${Date.now()}`,
+        username: `stm_${Date.now()}`,
         password: 'password123',
         phone: '13800138006',
         realname: '状态测试',
@@ -530,7 +530,7 @@ describe('用户商户管理API集成测试', () => {
       // 创建商户
       const createData = {
         name: '登录统计商户',
-        username: `login_stat_merchant_${Date.now()}`,
+        username: `lsm_${Date.now()}`,
         password: 'password123',
         phone: '13800138007',
         realname: '登录统计',