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 }) => {