Просмотр исходного кода

更新故事006.019文档和测试调试日志

- 更新故事006.019的Dev Agent Record,添加测试修复进度记录
- 在BatchSpecCreator测试中添加调试日志,帮助诊断测试超时问题
- 保持测试与API模拟规范一致

🤖 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 месяц назад
Родитель
Сommit
4115596fd8

+ 3 - 0
docs/stories/006.019.batch-spec-creator-test-fixes-api-mock-normalization.story.md

@@ -163,8 +163,11 @@ Claude Sonnet
    - 移除对@tanstack/react-query的useQuery模拟(部分完成,测试需要进一步调试)
    - 移除对@tanstack/react-query的useQuery模拟(部分完成,测试需要进一步调试)
    - 添加统一的rpcClient模拟代替goodsClientManager模拟
    - 添加统一的rpcClient模拟代替goodsClientManager模拟
    - 移除直接模拟goodsClientManager的代码
    - 移除直接模拟goodsClientManager的代码
+   - 使用与其他测试一致的`createMockResponse`模式
+   - 添加必要的等待逻辑(所有测试添加`await waitForParentGoodsLoaded()`)
 4. BatchSpecCreatorInline所有23个测试通过验证
 4. BatchSpecCreatorInline所有23个测试通过验证
 5. 检查故事完成状态:BatchSpecCreatorInline测试已全部通过(23/23),BatchSpecCreator组件API模拟规范已应用但测试仍失败,需要进一步调试mock配置问题
 5. 检查故事完成状态:BatchSpecCreatorInline测试已全部通过(23/23),BatchSpecCreator组件API模拟规范已应用但测试仍失败,需要进一步调试mock配置问题
+6. BatchSpecCreator测试失败原因分析:所有测试超时,组件持续显示加载状态。mock被调用且返回数据,但React Query未成功完成查询。可能原因包括:mock响应结构不完整、React Query配置问题、组件状态更新问题。需要进一步深入调试。
 
 
 ### File List
 ### File List
 1. `packages/goods-management-ui-mt/src/components/BatchSpecCreatorInline.tsx` - 主要组件源码
 1. `packages/goods-management-ui-mt/src/components/BatchSpecCreatorInline.tsx` - 主要组件源码

+ 6 - 3
packages/goods-management-ui-mt/tests/unit/BatchSpecCreator.test.tsx

@@ -19,7 +19,10 @@ const createMockResponse = (status: number, data?: any) => ({
   url: '',
   url: '',
   redirected: false,
   redirected: false,
   type: 'basic' as ResponseType,
   type: 'basic' as ResponseType,
-  json: async () => data || {},
+  json: async () => {
+    console.debug('createMockResponse json() called, data:', data);
+    return data || {};
+  },
   text: async () => '',
   text: async () => '',
   blob: async () => new Blob(),
   blob: async () => new Blob(),
   arrayBuffer: async () => new ArrayBuffer(0),
   arrayBuffer: async () => new ArrayBuffer(0),
@@ -28,8 +31,8 @@ const createMockResponse = (status: number, data?: any) => ({
 });
 });
 
 
 // 统一模拟rpcClient函数(符合API模拟规范)
 // 统一模拟rpcClient函数(符合API模拟规范)
-const mockRpcClient = vi.hoisted(() => vi.fn(() => {
-  console.debug('mockRpcClient called');
+const mockRpcClient = vi.hoisted(() => vi.fn((aptBaseUrl: string) => {
+  console.debug('mockRpcClient called with baseUrl:', aptBaseUrl);
   const mockClient = {
   const mockClient = {
     ':id': {
     ':id': {
       $get: vi.fn((options) => {
       $get: vi.fn((options) => {