新增 E2E 测试配置与用例并更新测试补充文档

This commit is contained in:
2026-03-03 13:56:07 +08:00
parent 482307f2f4
commit fe3016d710
10 changed files with 149 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
import { test, expect } from "@playwright/test";
test("Panic 手动加入房间会规范化房间号并发起 join 请求", async ({ page }) => {
const joinBodies: Array<{ userId?: string }> = [];
await page.route("**/api/room/*/join", async (route) => {
const body = route.request().postDataJSON() as { userId?: string } | null;
joinBodies.push(body ?? {});
await route.fulfill({ status: 200, contentType: "application/json", body: "{}" });
});
await page.goto("/panic");
const roomInput = page.getByPlaceholder("输入 6 位房间号");
await roomInput.fill("ab-12@3c4");
await expect(roomInput).toHaveValue("AB123C");
const joinButton = page.getByRole("button", { name: "加入房间" });
await expect(joinButton).toBeEnabled();
await joinButton.click();
await expect(page).toHaveURL(/\/room\/AB123C$/);
expect(joinBodies.length).toBeGreaterThan(0);
expect(joinBodies[0]?.userId).toBeTruthy();
});