From 07804911050866e3a969b116e2b7fd2dcc9c30fd Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 6 Jul 2026 12:04:36 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85E2E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=20-=20=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E4=B8=BA=E7=A9=BA/=E7=BC=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=8F=8D=E5=90=91=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增2个注册反向测试用例: - 注册用户名为空 - 验证返回400校验错误 - 注册缺用户名字段 - 验证返回422校验错误 加上原有的5个场景(邮箱已存在、弱密码、密码错误、账号不存在、项目名 为空),共覆盖7个错误场景。全部在staging环境验证通过。 --- apps/web/e2e/test_auth.spec.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/web/e2e/test_auth.spec.ts b/apps/web/e2e/test_auth.spec.ts index cb34b90fa..121600034 100755 --- a/apps/web/e2e/test_auth.spec.ts +++ b/apps/web/e2e/test_auth.spec.ts @@ -150,6 +150,36 @@ test.describe("认证流程", () => { expect([400, 422]).toContain(response.status()); }); + test("注册用户名为空 - 反向", async ({ request }) => { + const response = await request.post(`${apiBase}/auth/register`, { + data: { + email: uniqueEmail("emptyuser"), + password: PASSWORD, + username: "", + display_name: "Empty Username", + }, + }); + + expect([400, 422], "用户名为空应返回 4xx 校验错误").toContain( + response.status(), + ); + }); + + test("注册缺用户名字段 - 反向", async ({ request }) => { + const response = await request.post(`${apiBase}/auth/register`, { + data: { + email: uniqueEmail("nouser"), + password: PASSWORD, + display_name: "No Username Field", + }, + }); + + expect( + [400, 422], + "缺少用户名字段应返回 4xx 校验错误", + ).toContain(response.status()); + }); + // ─── 登录 ──────────────────────────────────────────── test("登录成功 - 正向", async ({ request }) => {