e65da6f294
- 新增法制日报机构种子数据(机构/用户/分类/15应用/知识库),登录页默认账号预填 - 引入 Playwright e2e:登录复用 storageState,覆盖对话/补全/工作流/智能体四类交互 - 配置测试脚本与产物 gitignore Co-authored-by: Cursor <cursor@cursor.com>
26 lines
924 B
TypeScript
26 lines
924 B
TypeScript
import { test as setup, expect } from "@playwright/test";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
|
|
const AUTH_FILE = path.join(__dirname, ".auth", "state.json");
|
|
|
|
setup("登录法制日报账号并保存会话", async ({ page }) => {
|
|
fs.mkdirSync(path.dirname(AUTH_FILE), { recursive: true });
|
|
|
|
await page.goto("/login");
|
|
|
|
await expect(page.locator("#org")).toBeVisible({ timeout: 30_000 });
|
|
|
|
await page.locator("#org").selectOption("a0000000-0000-0000-0000-00000000000a");
|
|
await page.fill("#email", "fazhiribao@govai.gov.cn");
|
|
await page.fill("#password", "admin123");
|
|
|
|
await page.getByRole("button", { name: /登\s*录/ }).click();
|
|
|
|
await page.waitForURL(/\/store/, { timeout: 30_000 });
|
|
|
|
const token = await page.evaluate(() => localStorage.getItem("token"));
|
|
expect(token, "登录后应在 localStorage 写入 token").toBeTruthy();
|
|
|
|
await page.context().storageState({ path: AUTH_FILE });
|
|
}); |