@lobehub/lobehub 2.0.0-next.266 → 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.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +5 -0
- package/e2e/CLAUDE.md +34 -73
- package/e2e/docs/local-setup.md +67 -219
- package/e2e/scripts/setup.ts +529 -0
- package/e2e/src/features/home/sidebarAgent.feature +62 -0
- package/e2e/src/features/home/sidebarGroup.feature +62 -0
- package/e2e/src/steps/home/sidebarAgent.steps.ts +373 -0
- package/e2e/src/steps/home/sidebarGroup.steps.ts +168 -0
- package/e2e/src/steps/hooks.ts +2 -0
- package/package.json +3 -3
- package/packages/utils/src/multimodalContent.test.ts +302 -0
- package/packages/utils/src/server/__tests__/sse.test.ts +353 -0
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentGroupItem/Editing.tsx +4 -11
- package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentGroupItem/index.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Params/Controls.tsx +42 -7
- package/src/store/home/slices/sidebarUI/action.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
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
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## [Version 2.0.0-next.266](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.265...v2.0.0-next.266)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2026-01-11**</sup>
|
package/changelog/v1.json
CHANGED
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
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
#
|
|
126
|
-
|
|
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
|
-
|
|
338
|
-
lsof -ti:3010 | xargs kill -9 2> /dev/null
|
|
319
|
+
# 一键清理(推荐)
|
|
320
|
+
bun e2e/scripts/setup.ts --clean
|
|
339
321
|
```
|
|
340
322
|
|
|
341
|
-
|
|
323
|
+
或手动清理:
|
|
342
324
|
|
|
343
325
|
```bash
|
|
344
326
|
# 停止并删除 PostgreSQL 容器
|
|
345
|
-
docker stop postgres-e2e
|
|
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
|
|
package/e2e/docs/local-setup.md
CHANGED
|
@@ -7,216 +7,108 @@
|
|
|
7
7
|
- pnpm 已安装
|
|
8
8
|
- 项目已 `pnpm install`
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 一键启动(推荐)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
每次运行测试前,建议先清理环境,避免残留状态导致问题。
|
|
12
|
+
使用 TypeScript 脚本自动完成环境设置:
|
|
15
13
|
|
|
16
14
|
```bash
|
|
17
|
-
#
|
|
18
|
-
# 如果未运行,请先启动 Docker Desktop
|
|
15
|
+
# 在项目根目录运行
|
|
19
16
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
docker rm postgres-e2e 2> /dev/null
|
|
17
|
+
# 仅设置数据库(启动 PostgreSQL + 运行迁移)
|
|
18
|
+
bun e2e/scripts/setup.ts
|
|
23
19
|
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
lsof -ti:5433 | xargs kill -9 2> /dev/null # PostgreSQL 端口
|
|
27
|
-
```
|
|
20
|
+
# 设置数据库并启动服务器
|
|
21
|
+
bun e2e/scripts/setup.ts --start
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
# 完整设置(数据库 + 构建 + 启动服务器)
|
|
24
|
+
bun e2e/scripts/setup.ts --build --start
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
###
|
|
30
|
+
### 脚本选项
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
| 选项 | 说明 |
|
|
33
|
+
| ---------------- | ---------------------------- |
|
|
34
|
+
| `--clean` | 清理现有容器和进程 |
|
|
35
|
+
| `--skip-db` | 跳过数据库设置(使用已有的) |
|
|
36
|
+
| `--skip-migrate` | 跳过数据库迁移 |
|
|
37
|
+
| `--build` | 启动前构建应用 |
|
|
38
|
+
| `--start` | 设置完成后启动服务器 |
|
|
39
|
+
| `--port <port>` | 服务器端口(默认 3006) |
|
|
40
|
+
| `--help` | 显示帮助信息 |
|
|
51
41
|
|
|
52
|
-
|
|
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
|
-
|
|
47
|
+
# 运行所有测试
|
|
48
|
+
BASE_URL=http://localhost:3006 bun run test
|
|
66
49
|
|
|
67
|
-
|
|
50
|
+
# 运行特定标签
|
|
51
|
+
BASE_URL=http://localhost:3006 bun run test -- --tags "@conversation"
|
|
68
52
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
57
|
+
## 手动启动流程
|
|
85
58
|
|
|
86
|
-
|
|
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
|
|
61
|
+
### Step 1: 环境清理
|
|
96
62
|
|
|
97
63
|
```bash
|
|
98
|
-
#
|
|
99
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
-
until docker exec postgres-e2e pg_isready
|
|
142
|
-
|
|
82
|
+
# 等待数据库就绪
|
|
83
|
+
until docker exec postgres-e2e pg_isready; do sleep 2; done
|
|
84
|
+
```
|
|
143
85
|
|
|
144
|
-
|
|
145
|
-
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
146
|
-
DATABASE_DRIVER=node \
|
|
147
|
-
bun run db:migrate
|
|
86
|
+
### Step 3: 运行数据库迁移
|
|
148
87
|
|
|
149
|
-
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
**症状**: `
|
|
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
|
-
**解决**:
|
|
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
|
-
**解决**:
|
|
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
|
-
```
|