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

chore: auto bump version and changelog [skip ci]

iwt 2 месяцев назад
Родитель
Сommit
8a17ef336a

+ 42 - 9
cfc-frontend/__tests__/api/api.test.js

@@ -25,7 +25,6 @@ function mockFail(err) {
   })
 }
 
-/** Helper: make uni.request return a sequence of responses (one per call) */
 function mockSequence(responses) {
   var i = 0
   global.uni.request.mockImplementation((opts) => {
@@ -167,6 +166,38 @@ describe('auth API', () => {
     jest.useRealTimers()
   })
 
+  test('401 with cached openid silently re-logins and retries original request', async () => {
+    global.uni.reLaunch.mockReset()
+    global.uni.showToast.mockReset()
+    global.uni._storage.openid = 'openid_abc'
+    global.uni._storage.token = 'expired-token'
+    mockSequence([
+      { data: { code: 401, message: 'Token无效或已过期', data: null } },
+      { data: { code: 200, data: { token: 'new-jwt', userId: 42, role: 'parent', familyId: 1, openid: 'openid_abc' } } },
+      { data: { code: 200, data: { userId: 42, role: 'parent' } } }
+    ])
+    const res = await api.verifyToken()
+    expect(res.data.userId).toBe(42)
+    expect(global.uni._storage.token).toBe('new-jwt')
+    expect(global.uni.reLaunch).not.toHaveBeenCalled()
+    expect(global.uni.showToast).not.toHaveBeenCalled()
+  })
+
+  test('401 with cached openid falls back to login when auto-login fails', async () => {
+    jest.useFakeTimers()
+    global.uni._storage.openid = 'openid_abc'
+    global.uni._storage.token = 'expired-token'
+    mockSequence([
+      { data: { code: 401, message: 'Token无效或已过期', data: null } },
+      { data: { code: 401, message: '用户不存在', data: null } }
+    ])
+    await expect(api.verifyToken()).rejects.toEqual({ code: 401, message: 'Token无效或已过期', data: null })
+    jest.runAllTimers()
+    expect(global.uni.reLaunch).toHaveBeenCalledWith({ url: '/pages/login/login' })
+    expect(global.uni.showToast).toHaveBeenCalled()
+    jest.useRealTimers()
+  })
+
   test('Authorization header includes Bearer token', async () => {
     mockSuccess({ code: 200 })
     global.uni._storage.token = 'my-jwt-token'
@@ -306,10 +337,10 @@ describe('user & family API', () => {
     expect(lastRequest().url).toMatch(/\/api\/user\/switch-back-to-parent$/)
   })
 
-  test('getChildren sends POST', async () => {
+  test('getChildren sends POST to unified member list', async () => {
     mockSuccess({ code: 200 })
     await api.getChildren()
-    expect(lastRequest().url).toMatch(/\/api\/family\/user\/children\/list$/)
+    expect(lastRequest().url).toMatch(/\/api\/family\/member\/list$/)
   })
 
   test('createChild sends POST with data', async () => {
@@ -413,11 +444,12 @@ describe('tasks API', () => {
     expect(lastRequest().data.size).toBe(20)
   })
 
-  test('deleteTask sends DELETE', async () => {
+  test('deleteTask sends POST with _method DELETE', async () => {
     mockSuccess({ code: 200 })
     await api.deleteTask(10)
-    expect(lastRequest().method).toBe('DELETE')
+    expect(lastRequest().method).toBe('POST')
     expect(lastRequest().url).toMatch(/\/api\/tasks\/10$/)
+    expect(lastRequest().data._method).toBe('DELETE')
   })
 
   test('batchCompleteTasks sends POST with array', async () => {
@@ -549,10 +581,11 @@ describe('identity parameter hardening', () => {
 // --------------- guide / packages module ---------------
 
 describe('guide & packages API', () => {
-  test('getGuidePackages sends POST to list', async () => {
+  test('getGuidePackages sends POST to my list', async () => {
     mockSuccess({ code: 200 })
     await api.getGuidePackages(1)
-    expect(lastRequest().url).toMatch(/\/api\/guide\/packages$/)
+    expect(lastRequest().url).toMatch(/\/api\/guide\/packages\/my$/)
+    expect(lastRequest().data.guideId).toBe(1)
   })
 
   test('registerGuide sends POST', async () => {
@@ -963,8 +996,8 @@ describe('health report API', () => {
 
   test('getSurveyStatus sends POST with reportId', async () => {
     mockSuccess({ code: 200 })
-    await api.getSurveyStatus(10)
-    expect(lastRequest().url).toMatch(/\/api\/health\/survey\/status$/)
+    await api.getSurveyStatus({ reportId: 10 })
+    expect(lastRequest().url).toMatch(/\/api\/survey\/status$/)
     expect(lastRequest().data.reportId).toBe(10)
   })
 })

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-767c29ce9c79fbcf1ea0a074f781fc563cbab279
+e9bce3010b8ae4655701d6bdc48dc16f12548dd7

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1278",
+  "version": "1.0.1279",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.1278",
+      "version": "1.0.1279",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1279",
+  "version": "1.0.1280",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 24 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,30 @@
 
 ---
 
+## v1.0.1280 (2026-09-02)
+
+### 文档
+- 饮食页面换一批/生成食谱端到端修复实现计划
+
+### 其他
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+
+### 新功能
+- 前端生成食谱/换一批取值修复 + 添加食材弹窗搜索
+- 生成食谱使用所选食材+共餐参与者,归一化LangGraph菜单
+- 换一批seed生效 + 食材搜索接口
+
+### Bug 修复
+- 修复知识库弹窗长文本超出右边界
+
+
 ## v1.0.1279 (2026-09-02)
 
 ### 新功能

+ 25 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.1279
+> 当前版本: v1.0.1280
 
 ## 历史版本
 
@@ -8,6 +8,30 @@
 
 ---
 
+## v1.0.1280 (2026-09-02)
+
+### 文档
+- 饮食页面换一批/生成食谱端到端修复实现计划
+
+### 其他
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+- Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
+- 
+
+### 新功能
+- 前端生成食谱/换一批取值修复 + 添加食材弹窗搜索
+- 生成食谱使用所选食材+共餐参与者,归一化LangGraph菜单
+- 换一批seed生效 + 食材搜索接口
+
+### Bug 修复
+- 修复知识库弹窗长文本超出右边界
+
+
 ## v1.0.1279 (2026-09-02)
 
 ### 新功能