@lobehub/lobehub 2.0.0-next.265 → 2.0.0-next.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +14 -0
  3. package/e2e/CLAUDE.md +34 -73
  4. package/e2e/docs/local-setup.md +67 -219
  5. package/e2e/scripts/setup.ts +529 -0
  6. package/e2e/src/features/home/sidebarAgent.feature +62 -0
  7. package/e2e/src/features/home/sidebarGroup.feature +62 -0
  8. package/e2e/src/steps/home/sidebarAgent.steps.ts +373 -0
  9. package/e2e/src/steps/home/sidebarGroup.steps.ts +168 -0
  10. package/e2e/src/steps/hooks.ts +2 -0
  11. package/locales/ar/chat.json +1 -0
  12. package/locales/ar/modelProvider.json +20 -0
  13. package/locales/ar/models.json +33 -10
  14. package/locales/ar/plugin.json +1 -0
  15. package/locales/ar/providers.json +1 -0
  16. package/locales/ar/setting.json +2 -0
  17. package/locales/bg-BG/chat.json +1 -0
  18. package/locales/bg-BG/modelProvider.json +20 -0
  19. package/locales/bg-BG/models.json +27 -7
  20. package/locales/bg-BG/plugin.json +1 -0
  21. package/locales/bg-BG/providers.json +1 -0
  22. package/locales/bg-BG/setting.json +2 -0
  23. package/locales/de-DE/chat.json +1 -0
  24. package/locales/de-DE/modelProvider.json +20 -0
  25. package/locales/de-DE/models.json +44 -10
  26. package/locales/de-DE/plugin.json +1 -0
  27. package/locales/de-DE/providers.json +1 -0
  28. package/locales/de-DE/setting.json +2 -0
  29. package/locales/en-US/chat.json +1 -0
  30. package/locales/en-US/modelProvider.json +20 -0
  31. package/locales/en-US/models.json +10 -10
  32. package/locales/en-US/providers.json +1 -0
  33. package/locales/en-US/setting.json +2 -1
  34. package/locales/es-ES/chat.json +1 -0
  35. package/locales/es-ES/modelProvider.json +20 -0
  36. package/locales/es-ES/models.json +53 -10
  37. package/locales/es-ES/plugin.json +1 -0
  38. package/locales/es-ES/providers.json +1 -0
  39. package/locales/es-ES/setting.json +2 -0
  40. package/locales/fa-IR/chat.json +1 -0
  41. package/locales/fa-IR/modelProvider.json +20 -0
  42. package/locales/fa-IR/models.json +33 -10
  43. package/locales/fa-IR/plugin.json +1 -0
  44. package/locales/fa-IR/providers.json +1 -0
  45. package/locales/fa-IR/setting.json +2 -0
  46. package/locales/fr-FR/chat.json +1 -0
  47. package/locales/fr-FR/modelProvider.json +20 -0
  48. package/locales/fr-FR/models.json +27 -7
  49. package/locales/fr-FR/plugin.json +1 -0
  50. package/locales/fr-FR/providers.json +1 -0
  51. package/locales/fr-FR/setting.json +2 -0
  52. package/locales/it-IT/chat.json +1 -0
  53. package/locales/it-IT/modelProvider.json +20 -0
  54. package/locales/it-IT/models.json +10 -10
  55. package/locales/it-IT/plugin.json +1 -0
  56. package/locales/it-IT/providers.json +1 -0
  57. package/locales/it-IT/setting.json +2 -0
  58. package/locales/ja-JP/chat.json +1 -0
  59. package/locales/ja-JP/modelProvider.json +20 -0
  60. package/locales/ja-JP/models.json +5 -10
  61. package/locales/ja-JP/plugin.json +1 -0
  62. package/locales/ja-JP/providers.json +1 -0
  63. package/locales/ja-JP/setting.json +2 -0
  64. package/locales/ko-KR/chat.json +1 -0
  65. package/locales/ko-KR/modelProvider.json +20 -0
  66. package/locales/ko-KR/models.json +36 -10
  67. package/locales/ko-KR/plugin.json +1 -0
  68. package/locales/ko-KR/providers.json +1 -0
  69. package/locales/ko-KR/setting.json +2 -0
  70. package/locales/nl-NL/chat.json +1 -0
  71. package/locales/nl-NL/modelProvider.json +20 -0
  72. package/locales/nl-NL/models.json +35 -4
  73. package/locales/nl-NL/plugin.json +1 -0
  74. package/locales/nl-NL/providers.json +1 -0
  75. package/locales/nl-NL/setting.json +2 -0
  76. package/locales/pl-PL/chat.json +1 -0
  77. package/locales/pl-PL/modelProvider.json +20 -0
  78. package/locales/pl-PL/models.json +37 -7
  79. package/locales/pl-PL/plugin.json +1 -0
  80. package/locales/pl-PL/providers.json +1 -0
  81. package/locales/pl-PL/setting.json +2 -0
  82. package/locales/pt-BR/chat.json +1 -0
  83. package/locales/pt-BR/modelProvider.json +20 -0
  84. package/locales/pt-BR/models.json +51 -9
  85. package/locales/pt-BR/plugin.json +1 -0
  86. package/locales/pt-BR/providers.json +1 -0
  87. package/locales/pt-BR/setting.json +2 -0
  88. package/locales/ru-RU/chat.json +1 -0
  89. package/locales/ru-RU/modelProvider.json +20 -0
  90. package/locales/ru-RU/models.json +48 -7
  91. package/locales/ru-RU/plugin.json +1 -0
  92. package/locales/ru-RU/providers.json +1 -0
  93. package/locales/ru-RU/setting.json +2 -0
  94. package/locales/tr-TR/chat.json +1 -0
  95. package/locales/tr-TR/modelProvider.json +20 -0
  96. package/locales/tr-TR/models.json +48 -7
  97. package/locales/tr-TR/plugin.json +1 -0
  98. package/locales/tr-TR/providers.json +1 -0
  99. package/locales/tr-TR/setting.json +2 -0
  100. package/locales/vi-VN/chat.json +1 -0
  101. package/locales/vi-VN/modelProvider.json +20 -0
  102. package/locales/vi-VN/models.json +5 -5
  103. package/locales/vi-VN/plugin.json +1 -0
  104. package/locales/vi-VN/providers.json +1 -0
  105. package/locales/vi-VN/setting.json +2 -0
  106. package/locales/zh-CN/modelProvider.json +20 -20
  107. package/locales/zh-CN/models.json +49 -8
  108. package/locales/zh-CN/providers.json +1 -0
  109. package/locales/zh-CN/setting.json +2 -1
  110. package/locales/zh-TW/chat.json +1 -0
  111. package/locales/zh-TW/modelProvider.json +20 -0
  112. package/locales/zh-TW/models.json +29 -10
  113. package/locales/zh-TW/plugin.json +1 -0
  114. package/locales/zh-TW/providers.json +1 -0
  115. package/locales/zh-TW/setting.json +2 -0
  116. package/package.json +3 -3
  117. package/packages/utils/src/multimodalContent.test.ts +302 -0
  118. package/packages/utils/src/server/__tests__/sse.test.ts +353 -0
  119. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Body.tsx +1 -1
  120. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Cron/CronTopicGroup.tsx +84 -0
  121. package/src/app/[variants]/(main)/agent/_layout/Sidebar/{Topic/CronTopicList → Cron}/CronTopicItem.tsx +1 -1
  122. package/src/app/[variants]/(main)/agent/_layout/Sidebar/{Topic/CronTopicList → Cron}/index.tsx +23 -33
  123. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/List/Item/Editing.tsx +12 -49
  124. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/List/index.tsx +3 -1
  125. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/TopicListContent/ThreadList/ThreadItem/Editing.tsx +12 -40
  126. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/hooks/useTopicNavigation.ts +5 -1
  127. package/src/app/[variants]/(main)/agent/profile/features/AgentCronJobs/CronJobCards.tsx +1 -1
  128. package/src/app/[variants]/(main)/agent/profile/features/AgentCronJobs/CronJobForm.tsx +1 -1
  129. package/src/app/[variants]/(main)/group/_layout/Sidebar/AddGroupMemberModal/AvailableAgentList.tsx +0 -1
  130. package/src/app/[variants]/(main)/group/_layout/Sidebar/AddGroupMemberModal/index.tsx +5 -1
  131. package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentGroupItem/Editing.tsx +4 -11
  132. package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentGroupItem/index.tsx +3 -3
  133. package/src/components/InlineRename/index.tsx +121 -0
  134. package/src/features/ChatInput/ActionBar/Params/Controls.tsx +42 -7
  135. package/src/features/NavPanel/components/NavItem.tsx +1 -1
  136. package/src/locales/default/setting.ts +2 -0
  137. package/src/store/agent/slices/cron/action.ts +108 -0
  138. package/src/store/agent/slices/cron/index.ts +1 -0
  139. package/src/store/agent/store.ts +3 -0
  140. package/src/store/home/slices/sidebarUI/action.ts +9 -0
  141. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/CronTopicList/CronTopicGroup.tsx +0 -74
  142. package/src/app/[variants]/(main)/group/features/ChangelogModal.tsx +0 -11
  143. package/src/hooks/useFetchCronTopicsWithJobInfo.ts +0 -56
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.267](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.266...v2.0.0-next.267)
6
+
7
+ <sup>Released on **2026-01-12**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **ChatInput**: Add missing MaxTokens setting to params popover.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **ChatInput**: Add missing MaxTokens setting to params popover, closes [#11412](https://github.com/lobehub/lobe-chat/issues/11412) [#11375](https://github.com/lobehub/lobe-chat/issues/11375) ([3db4389](https://github.com/lobehub/lobe-chat/commit/3db4389))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ## [Version 2.0.0-next.266](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.265...v2.0.0-next.266)
31
+
32
+ <sup>Released on **2026-01-11**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Improve cron jobs style.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Improve cron jobs style, closes [#11420](https://github.com/lobehub/lobe-chat/issues/11420) ([d1602f6](https://github.com/lobehub/lobe-chat/commit/d1602f6))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 2.0.0-next.265](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.264...v2.0.0-next.265)
6
56
 
7
57
  <sup>Released on **2026-01-11**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "children": {},
4
+ "date": "2026-01-12",
5
+ "version": "2.0.0-next.267"
6
+ },
7
+ {
8
+ "children": {
9
+ "improvements": [
10
+ "Improve cron jobs style."
11
+ ]
12
+ },
13
+ "date": "2026-01-11",
14
+ "version": "2.0.0-next.266"
15
+ },
2
16
  {
3
17
  "children": {
4
18
  "fixes": [
package/e2e/CLAUDE.md CHANGED
@@ -108,57 +108,42 @@ e2e/
108
108
 
109
109
  > 详细流程参考 [e2e/docs/local-setup.md](./docs/local-setup.md)
110
110
 
111
- ### 快速启动流程
111
+ ### 一键启动(推荐)
112
+
113
+ 使用 TypeScript 脚本自动完成环境设置:
112
114
 
113
115
  ```bash
114
- # Step 1: 清理环境
115
- docker stop postgres-e2e 2> /dev/null; docker rm postgres-e2e 2> /dev/null
116
- lsof -ti:3006 | xargs kill -9 2> /dev/null
117
- lsof -ti:5433 | xargs kill -9 2> /dev/null
118
-
119
- # Step 2: 启动数据库(使用 paradedb 镜像,支持 pgvector)
120
- docker run -d --name postgres-e2e \
121
- -e POSTGRES_PASSWORD=postgres \
122
- -p 5433:5432 \
123
- paradedb/paradedb:latest
124
-
125
- # 等待数据库就绪
126
- until docker exec postgres-e2e pg_isready; do sleep 2; done
127
-
128
- # Step 3: 运行数据库迁移(项目根目录)
129
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
130
- DATABASE_DRIVER=node \
131
- KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
132
- bun run db:migrate
133
-
134
- # Step 4: 构建应用(首次或代码变更后)
135
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
136
- DATABASE_DRIVER=node \
137
- KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
138
- BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
139
- NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
140
- SKIP_LINT=1 \
141
- bun run build
142
-
143
- # Step 5: 启动服务器(必须在项目根目录运行!)
144
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
145
- DATABASE_DRIVER=node \
146
- KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
147
- BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
148
- NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
149
- NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION=0 \
150
- S3_ACCESS_KEY_ID=e2e-mock-access-key \
151
- S3_SECRET_ACCESS_KEY=e2e-mock-secret-key \
152
- S3_BUCKET=e2e-mock-bucket \
153
- S3_ENDPOINT=https://e2e-mock-s3.localhost \
154
- bunx next start -p 3006
116
+ # 在项目根目录运行
117
+
118
+ # 仅设置数据库(启动 PostgreSQL + 运行迁移)
119
+ bun e2e/scripts/setup.ts
120
+
121
+ # 设置数据库并启动服务器
122
+ bun e2e/scripts/setup.ts --start
123
+
124
+ # 完整设置(数据库 + 构建 + 启动服务器)
125
+ bun e2e/scripts/setup.ts --build --start
126
+
127
+ # 清理环境
128
+ bun e2e/scripts/setup.ts --clean
155
129
  ```
156
130
 
131
+ ### 脚本选项
132
+
133
+ | 选项 | 说明 |
134
+ | ---------------- | ---------------------------- |
135
+ | `--clean` | 清理现有容器和进程 |
136
+ | `--skip-db` | 跳过数据库设置(使用已有的) |
137
+ | `--skip-migrate` | 跳过数据库迁移 |
138
+ | `--build` | 启动前构建应用 |
139
+ | `--start` | 设置完成后启动服务器 |
140
+ | `--port <port>` | 服务器端口(默认 3006) |
141
+
157
142
  **重要提示**:
158
143
 
159
144
  - 必须使用 `paradedb/paradedb:latest` 镜像(支持 pgvector 扩展)
160
145
  - 服务器必须在**项目根目录**启动,不能在 e2e 目录
161
- - S3 环境变量是**必需**的,即使不测试文件上传
146
+ - S3 环境变量是**必需**的,即使不测试文件上传(脚本已自动处理)
162
147
 
163
148
  ## 运行测试
164
149
 
@@ -328,45 +313,21 @@ S3_ENDPOINT=https://e2e-mock-s3.localhost
328
313
 
329
314
  ## 清理环境
330
315
 
331
- 测试完成后或需要重置环境时,执行以下清理操作:
332
-
333
- ### 停止服务器
316
+ 测试完成后或需要重置环境时:
334
317
 
335
318
  ```bash
336
- # 查找并停止占用端口的进程
337
- lsof -ti:3006 | xargs kill -9 2> /dev/null
338
- lsof -ti:3010 | xargs kill -9 2> /dev/null
319
+ # 一键清理(推荐)
320
+ bun e2e/scripts/setup.ts --clean
339
321
  ```
340
322
 
341
- ### 停止 Docker 容器
323
+ 或手动清理:
342
324
 
343
325
  ```bash
344
326
  # 停止并删除 PostgreSQL 容器
345
- docker stop postgres-e2e 2> /dev/null
346
- docker rm postgres-e2e 2> /dev/null
347
- ```
327
+ docker stop postgres-e2e && docker rm postgres-e2e
348
328
 
349
- ### 一键清理(推荐)
350
-
351
- ```bash
352
- # 清理所有 E2E 相关进程和容器
353
- docker stop postgres-e2e 2> /dev/null
354
- docker rm postgres-e2e 2> /dev/null
355
- lsof -ti:3006 | xargs kill -9 2> /dev/null
356
- lsof -ti:3010 | xargs kill -9 2> /dev/null
357
- lsof -ti:5433 | xargs kill -9 2> /dev/null
358
- echo "Cleanup done"
359
- ```
360
-
361
- ### 清理端口占用
362
-
363
- 如果遇到端口被占用的错误,可以清理特定端口:
364
-
365
- ```bash
366
- # 清理 Next.js 服务器端口
329
+ # 清理端口占用
367
330
  lsof -ti:3006 | xargs kill -9
368
-
369
- # 清理 PostgreSQL 端口
370
331
  lsof -ti:5433 | xargs kill -9
371
332
  ```
372
333
 
@@ -7,216 +7,108 @@
7
7
  - pnpm 已安装
8
8
  - 项目已 `pnpm install`
9
9
 
10
- ## 完整启动流程
10
+ ## 一键启动(推荐)
11
11
 
12
- ### Step 0: 环境清理(重要!)
13
-
14
- 每次运行测试前,建议先清理环境,避免残留状态导致问题。
12
+ 使用 TypeScript 脚本自动完成环境设置:
15
13
 
16
14
  ```bash
17
- # 0.1 确保 Docker Desktop 正在运行
18
- # 如果未运行,请先启动 Docker Desktop
15
+ # 在项目根目录运行
19
16
 
20
- # 0.2 清理旧的 PostgreSQL 容器
21
- docker stop postgres-e2e 2> /dev/null
22
- docker rm postgres-e2e 2> /dev/null
17
+ # 仅设置数据库(启动 PostgreSQL + 运行迁移)
18
+ bun e2e/scripts/setup.ts
23
19
 
24
- # 0.3 清理占用的端口
25
- lsof -ti:3006 | xargs kill -9 2> /dev/null # Next.js 服务器端口
26
- lsof -ti:5433 | xargs kill -9 2> /dev/null # PostgreSQL 端口
27
- ```
20
+ # 设置数据库并启动服务器
21
+ bun e2e/scripts/setup.ts --start
28
22
 
29
- ### Step 1: 启动数据库
23
+ # 完整设置(数据库 + 构建 + 启动服务器)
24
+ bun e2e/scripts/setup.ts --build --start
30
25
 
31
- ```bash
32
- # 启动 PostgreSQL (端口 5433)
33
- docker run -d --name postgres-e2e \
34
- -e POSTGRES_PASSWORD=postgres \
35
- -p 5433:5432 \
36
- paradedb/paradedb:latest
37
-
38
- # 等待数据库就绪
39
- until docker exec postgres-e2e pg_isready; do sleep 2; done
40
- echo "PostgreSQL is ready!"
26
+ # 清理环境
27
+ bun e2e/scripts/setup.ts --clean
41
28
  ```
42
29
 
43
- ### Step 2: 运行数据库迁移
30
+ ### 脚本选项
44
31
 
45
- ```bash
46
- # 在项目根目录运行
47
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
48
- DATABASE_DRIVER=node \
49
- bun run db:migrate
50
- ```
32
+ | 选项 | 说明 |
33
+ | ---------------- | ---------------------------- |
34
+ | `--clean` | 清理现有容器和进程 |
35
+ | `--skip-db` | 跳过数据库设置(使用已有的) |
36
+ | `--skip-migrate` | 跳过数据库迁移 |
37
+ | `--build` | 启动前构建应用 |
38
+ | `--start` | 设置完成后启动服务器 |
39
+ | `--port <port>` | 服务器端口(默认 3006) |
40
+ | `--help` | 显示帮助信息 |
51
41
 
52
- ### Step 3: 构建应用(首次或代码变更后)
42
+ ## 运行测试
53
43
 
54
44
  ```bash
55
- # 在项目根目录运行
56
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
57
- DATABASE_DRIVER=node \
58
- KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
59
- BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
60
- NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
61
- SKIP_LINT=1 \
62
- bun run build
63
- ```
45
+ cd e2e
64
46
 
65
- ### Step 4: 启动应用服务器
47
+ # 运行所有测试
48
+ BASE_URL=http://localhost:3006 bun run test
66
49
 
67
- **重要**: 必须在**项目根目录**运行,不能在 e2e 目录运行!
50
+ # 运行特定标签
51
+ BASE_URL=http://localhost:3006 bun run test -- --tags "@conversation"
68
52
 
69
- ```bash
70
- # 在项目根目录运行(注意:不是 e2e 目录)
71
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
72
- DATABASE_DRIVER=node \
73
- KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
74
- BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
75
- NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
76
- NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION=0 \
77
- S3_ACCESS_KEY_ID=e2e-mock-access-key \
78
- S3_SECRET_ACCESS_KEY=e2e-mock-secret-key \
79
- S3_BUCKET=e2e-mock-bucket \
80
- S3_ENDPOINT=https://e2e-mock-s3.localhost \
81
- bunx next start -p 3006
53
+ # 调试模式(显示浏览器)
54
+ HEADLESS=false BASE_URL=http://localhost:3006 bun run test -- --tags "@smoke"
82
55
  ```
83
56
 
84
- ### Step 5: 等待服务器就绪
57
+ ## 手动启动流程
85
58
 
86
- ```bash
87
- # 在另一个终端运行,确认服务器已启动
88
- until curl -s http://localhost:3006 > /dev/null; do
89
- sleep 2
90
- echo "Waiting..."
91
- done
92
- echo "Server is ready!"
93
- ```
59
+ 如果需要手动控制各个步骤,可以按照以下流程操作:
94
60
 
95
- ### Step 6: 运行测试
61
+ ### Step 1: 环境清理
96
62
 
97
63
  ```bash
98
- # e2e 目录运行测试
99
- cd e2e
100
-
101
- # 运行特定标签(默认无头模式)
102
- BASE_URL=http://localhost:3006 \
103
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
104
- pnpm exec cucumber-js --config cucumber.config.js --tags "@conversation"
64
+ # 清理旧的 PostgreSQL 容器
65
+ docker stop postgres-e2e 2> /dev/null
66
+ docker rm postgres-e2e 2> /dev/null
105
67
 
106
- # 运行所有测试
107
- BASE_URL=http://localhost:3006 \
108
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
109
- pnpm exec cucumber-js --config cucumber.config.js
110
-
111
- # 调试模式(显示浏览器,观察执行过程)
112
- HEADLESS=false \
113
- BASE_URL=http://localhost:3006 \
114
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
115
- pnpm exec cucumber-js --config cucumber.config.js --tags "@conversation"
68
+ # 清理占用的端口
69
+ lsof -ti:3006 | xargs kill -9 2> /dev/null
70
+ lsof -ti:5433 | xargs kill -9 2> /dev/null
116
71
  ```
117
72
 
118
- ## 一键启动脚本
119
-
120
- ### 完整初始化(首次运行或需要重建)
121
-
122
- 在项目根目录创建 `e2e-init.sh`:
73
+ ### Step 2: 启动数据库
123
74
 
124
75
  ```bash
125
- #!/bin/bash
126
- set -e
127
-
128
- echo "🧹 Step 0: Cleaning up..."
129
- docker stop postgres-e2e 2> /dev/null || true
130
- docker rm postgres-e2e 2> /dev/null || true
131
- lsof -ti:3006 | xargs kill -9 2> /dev/null || true
132
- lsof -ti:5433 | xargs kill -9 2> /dev/null || true
133
-
134
- echo "🐘 Step 1: Starting PostgreSQL..."
76
+ # 启动 PostgreSQL (端口 5433)
135
77
  docker run -d --name postgres-e2e \
136
78
  -e POSTGRES_PASSWORD=postgres \
137
79
  -p 5433:5432 \
138
80
  paradedb/paradedb:latest
139
81
 
140
- echo "⏳ Waiting for PostgreSQL..."
141
- until docker exec postgres-e2e pg_isready 2> /dev/null; do sleep 2; done
142
- echo "✅ PostgreSQL is ready!"
82
+ # 等待数据库就绪
83
+ until docker exec postgres-e2e pg_isready; do sleep 2; done
84
+ ```
143
85
 
144
- echo "🔄 Step 2: Running migrations..."
145
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
146
- DATABASE_DRIVER=node \
147
- bun run db:migrate
86
+ ### Step 3: 运行数据库迁移
148
87
 
149
- echo "🔨 Step 3: Building application..."
88
+ ```bash
150
89
  DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
151
90
  DATABASE_DRIVER=node \
152
91
  KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
153
- BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
154
- NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
155
- SKIP_LINT=1 \
156
- bun run build
157
-
158
- echo "✅ Initialization complete! Now run e2e-start.sh to start the server."
92
+ bun run db:migrate
159
93
  ```
160
94
 
161
- ### 快速启动服务器
162
-
163
- 在项目根目录创建 `e2e-start.sh`:
95
+ ### Step 4: 构建应用(首次或代码变更后)
164
96
 
165
97
  ```bash
166
- #!/bin/bash
167
- set -e
168
-
169
- echo "🧹 Cleaning up ports..."
170
- lsof -ti:3006 | xargs kill -9 2> /dev/null || true
171
-
172
- echo "🚀 Starting Next.js server on port 3006..."
173
98
  DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
174
99
  DATABASE_DRIVER=node \
175
100
  KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
176
101
  BETTER_AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
177
102
  NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
178
- NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION=0 \
179
- S3_ACCESS_KEY_ID=e2e-mock-access-key \
180
- S3_SECRET_ACCESS_KEY=e2e-mock-secret-key \
181
- S3_BUCKET=e2e-mock-bucket \
182
- S3_ENDPOINT=https://e2e-mock-s3.localhost \
183
- bunx next start -p 3006
184
- ```
185
-
186
- ### 运行测试
187
-
188
- 在 e2e 目录创建 `run-test.sh`:
189
-
190
- ```bash
191
- #!/bin/bash
192
-
193
- # 默认参数
194
- TAGS="${1:-@journey}"
195
- HEADLESS="${HEADLESS:-true}" # 默认无头模式
196
-
197
- echo "🧪 Running E2E tests with tags: $TAGS"
198
- echo " Headless: $HEADLESS"
199
-
200
- HEADLESS=$HEADLESS \
201
- BASE_URL=http://localhost:3006 \
202
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
203
- pnpm exec cucumber-js --config cucumber.config.js --tags "$TAGS"
103
+ SKIP_LINT=1 \
104
+ bun run build
204
105
  ```
205
106
 
206
- 使用方式:
107
+ ### Step 5: 启动应用服务器
207
108
 
208
- ```bash
209
- # 运行特定标签(默认无头模式)
210
- ./run-test.sh "@conversation"
211
-
212
- # 调试模式(显示浏览器)
213
- HEADLESS=false ./run-test.sh "@conversation"
214
- ```
215
-
216
- ## 快速启动(假设数据库和构建已完成)
109
+ **重要**: 必须在**项目根目录**运行!
217
110
 
218
111
  ```bash
219
- # Terminal 1: 启动服务器(项目根目录)
220
112
  DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
221
113
  DATABASE_DRIVER=node \
222
114
  KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
@@ -228,30 +120,11 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
228
120
  S3_BUCKET=e2e-mock-bucket \
229
121
  S3_ENDPOINT=https://e2e-mock-s3.localhost \
230
122
  bunx next start -p 3006
231
-
232
- # Terminal 2: 运行测试(e2e 目录,默认无头模式)
233
- cd e2e
234
- BASE_URL=http://localhost:3006 \
235
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
236
- pnpm exec cucumber-js --config cucumber.config.js --tags "@conversation"
237
-
238
- # 调试模式(显示浏览器)
239
- HEADLESS=false BASE_URL=http://localhost:3006 \
240
- DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
241
- pnpm exec cucumber-js --config cucumber.config.js --tags "@conversation"
242
123
  ```
243
124
 
244
125
  ## 环境变量参考
245
126
 
246
- ### 测试运行时环境变量
247
-
248
- | 变量 | 值 | 说明 |
249
- | -------------- | -------------------------------------------------------- | --------------------------------------------------- |
250
- | `BASE_URL` | `http://localhost:3006` | 测试服务器地址 |
251
- | `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5433/postgres` | 数据库连接 |
252
- | `HEADLESS` | `true`(默认)/`false` | 是否无头模式运行浏览器,设为 `false` 可观察执行过程 |
253
-
254
- ### 服务器启动环境变量(全部必需)
127
+ ### 服务器启动环境变量
255
128
 
256
129
  | 变量 | 值 | 说明 |
257
130
  | ------------------------------------- | -------------------------------------------------------- | ---------------- |
@@ -262,7 +135,7 @@ HEADLESS=false BASE_URL=http://localhost:3006 \
262
135
  | `NEXT_PUBLIC_ENABLE_BETTER_AUTH` | `1` | 启用 Better Auth |
263
136
  | `NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION` | `0` | 禁用邮箱验证 |
264
137
 
265
- ### S3 Mock 变量(必需!)
138
+ ### S3 Mock 变量(必需)
266
139
 
267
140
  | 变量 | 值 |
268
141
  | ---------------------- | ------------------------------- |
@@ -271,9 +144,15 @@ HEADLESS=false BASE_URL=http://localhost:3006 \
271
144
  | `S3_BUCKET` | `e2e-mock-bucket` |
272
145
  | `S3_ENDPOINT` | `https://e2e-mock-s3.localhost` |
273
146
 
274
- **注意**: S3 环境变量是**必需**的,即使不测试文件上传功能。缺少这些变量会导致发送消息时报错 "S3 environment variables are not set completely"。
147
+ ### 测试运行时环境变量
148
+
149
+ | 变量 | 值 | 说明 |
150
+ | -------------- | -------------------------------------------------------- | ---------------------- |
151
+ | `BASE_URL` | `http://localhost:3006` | 测试服务器地址 |
152
+ | `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5433/postgres` | 数据库连接 |
153
+ | `HEADLESS` | `true`(默认)/`false` | 是否显示浏览器执行过程 |
275
154
 
276
- ## 常见问题排查
155
+ ## 常见问题
277
156
 
278
157
  ### Docker daemon is not running
279
158
 
@@ -283,37 +162,34 @@ HEADLESS=false BASE_URL=http://localhost:3006 \
283
162
 
284
163
  ### PostgreSQL 容器已存在
285
164
 
286
- **症状**: `docker: Error response from daemon: Conflict. The container name "/postgres-e2e" is already in use`
165
+ **症状**: `The container name "/postgres-e2e" is already in use`
287
166
 
288
- **解决**:
167
+ **解决**: `bun e2e/scripts/setup.ts --clean` 或手动执行:
289
168
 
290
169
  ```bash
291
- docker stop postgres-e2e
292
- docker rm postgres-e2e
170
+ docker stop postgres-e2e && docker rm postgres-e2e
293
171
  ```
294
172
 
295
173
  ### S3 environment variables are not set completely
296
174
 
297
175
  **原因**: 服务器启动时缺少 S3 环境变量
298
176
 
299
- **解决**: 启动服务器时必须设置所有 S3 mock 变量
177
+ **解决**: 使用 `bun e2e/scripts/setup.ts --start` 或确保手动设置所有 S3 mock 变量
300
178
 
301
179
  ### Cannot find module './src/libs/next/config/define-config'
302
180
 
303
181
  **原因**: 在 e2e 目录下运行 `next start`
304
182
 
305
- **解决**: 必须在**项目根目录**运行 `bunx next start`,不能在 e2e 目录运行
183
+ **解决**: 必须在**项目根目录**运行服务器
306
184
 
307
185
  ### EADDRINUSE: address already in use
308
186
 
309
187
  **原因**: 端口被占用
310
188
 
311
- **解决**:
189
+ **解决**: `bun e2e/scripts/setup.ts --clean` 或:
312
190
 
313
191
  ```bash
314
- # 查找并杀掉占用端口的进程
315
192
  lsof -ti:3006 | xargs kill -9
316
- lsof -ti:5433 | xargs kill -9
317
193
  ```
318
194
 
319
195
  ### BeforeAll hook errored: net::ERR_CONNECTION_REFUSED
@@ -324,31 +200,3 @@ lsof -ti:5433 | xargs kill -9
324
200
 
325
201
  1. 确认服务器已启动:`curl http://localhost:3006`
326
202
  2. 确认 `BASE_URL` 环境变量设置正确
327
- 3. 等待服务器完全就绪后再运行测试
328
-
329
- ### 测试超时或不稳定
330
-
331
- **可能原因**:
332
-
333
- 1. 网络延迟
334
- 2. 服务器响应慢
335
- 3. 元素定位问题
336
-
337
- **解决**:
338
-
339
- 1. 使用 `HEADLESS=false` 观察测试执行过程
340
- 2. 检查 `screenshots/` 目录中的失败截图
341
- 3. 增加等待时间或使用更稳定的定位器
342
-
343
- ## 清理环境
344
-
345
- 测试完成后,清理环境:
346
-
347
- ```bash
348
- # 停止服务器
349
- lsof -ti:3006 | xargs kill -9
350
-
351
- # 停止并删除 PostgreSQL 容器
352
- docker stop postgres-e2e
353
- docker rm postgres-e2e
354
- ```