Prechádzať zdrojové kódy

test(goods-module): 修复集成测试中的条件断言逻辑

- 在规格数据验证测试中添加if判断包装断言
- 确保在状态码为400时才访问data.error.message属性
- 保持测试的一致性和安全性

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 1 mesiac pred
rodič
commit
09ce737293

+ 5 - 3
packages/goods-module-mt/tests/integration/admin-goods-parent-child.integration.test.ts

@@ -413,9 +413,11 @@ describe('管理员父子商品管理API集成测试', () => {
       console.debug('验证规格数据有效性测试 - 响应数据:', data);
 
       expect(response.status).toBe(400);
-      expect(data.success).toBe(false);
-      // Zod错误消息是JSON字符串,检查是否包含错误信息
-      expect(data.error.message).toMatch(/规格名称不能为空/);
+      if (response.status === 400) {
+        expect(data.success).toBe(false);
+        // Zod错误消息是JSON字符串,检查是否包含错误信息
+        expect(data.error.message).toMatch(/规格名称不能为空/);
+      }
     });
 
     it('应该继承父商品的分类和其他信息', async () => {