| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import { expect, test } from "@playwright/test"
- test("automatic route selects data analysis and hides internal roles", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?agent-groups")
- await page.getByLabel("API Key", { exact: true }).fill("automatic-route")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("合并 CSV 并画趋势图")
- const route = page.locator(".paas-agent-route > summary")
- await expect(route).toContainText("自动 · data67")
- await route.click()
- const select = page.getByLabel("选择执行角色", { exact: true })
- const options = await select.locator("option").allTextContents()
- expect(options).toContain("data67")
- expect(options).not.toContain("本体证据补全员")
- })
- test("agent directory separates direct roles from internal subagents", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?agent-groups")
- await page.getByLabel("API Key", { exact: true }).fill("agent-groups")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.getByRole("button", { name: "智能体", exact: true }).click()
- await expect(page.getByRole("heading", { name: "默认入口", exact: true })).toBeVisible()
- await expect(page.getByRole("heading", { name: "专业任务", exact: true })).toBeVisible()
- await expect(page.getByRole("heading", { name: "研究流水线", exact: true })).toBeVisible()
- const internal = page.locator(".paas-agent-internal")
- await expect(internal.getByRole("heading", { name: "本体证据补全员", exact: true })).toBeHidden()
- await internal.getByText("流程内部能力 · 1", { exact: true }).click()
- await expect(internal.getByRole("heading", { name: "本体证据补全员", exact: true })).toBeVisible()
- await expect(internal.getByRole("button", { name: "与 本体证据补全员 对话", exact: true })).toHaveCount(0)
- })
- test("workspace assistant requires and forwards the project folder", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?workspace")
- await page.getByLabel("API Key", { exact: true }).fill("workspace-context")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.locator(".paas-agent-route > summary").click()
- await page.getByLabel("选择执行角色", { exact: true }).selectOption({ label: "工作区助手" })
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("整理这个文件夹")
- await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
- await expect(page.getByText("需要绑定项目工作文件夹", { exact: true })).toBeVisible()
- expect(
- await page.evaluate(
- () =>
- (window as unknown as { paasTestCalls: { action: string }[] }).paasTestCalls.filter(
- (call) => call.action === "execute",
- ).length,
- ),
- ).toBe(0)
- await page.getByRole("button", { name: "新建项目", exact: true }).click()
- await page.getByLabel("项目名称", { exact: true }).fill("工作区研究")
- await page.getByRole("button", { name: "创建项目", exact: true }).click()
- await page.getByRole("button", { name: "绑定文件夹", exact: true }).click()
- await page.locator(".paas-agent-route > summary").click()
- await page.getByLabel("选择执行角色", { exact: true }).selectOption({ label: "工作区助手" })
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("整理这个文件夹并改 README")
- await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
- await expect
- .poll(() =>
- page.evaluate(
- () =>
- (window as unknown as { paasTestCalls: { action: string; workDir?: string }[] }).paasTestCalls.find(
- (call) => call.action === "execute",
- )?.workDir,
- ),
- )
- .toBe("D:/Research/optics")
- })
- test("projects isolate chat history and keep a bound workspace after reload", async ({ page }) => {
- await page.goto("/e2e/paas/index.html")
- await page.getByLabel("API Key", { exact: true }).fill("project-test")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
- await page.getByRole("button", { name: "新建项目", exact: true }).click()
- await page.getByLabel("项目名称", { exact: true }).fill("光学综述")
- await page.getByRole("button", { name: "创建项目", exact: true }).click()
- await expect(page.getByLabel("切换项目", { exact: true })).toContainText("光学综述")
- await page.getByRole("button", { name: "绑定文件夹", exact: true }).click()
- await expect(page.locator(".paas-composer-context").getByText("D:/Research/optics", { exact: true })).toBeVisible()
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("光学综述草稿")
- await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
- await expect(page.getByRole("button", { name: /已有研究/ })).toHaveCount(0)
- await page.reload()
- await page.getByLabel("API Key", { exact: true }).fill("project-test")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByLabel("切换项目", { exact: true })).toContainText("光学综述")
- await expect(page.locator(".paas-composer-context").getByText("D:/Research/optics", { exact: true })).toBeVisible()
- })
- test("project creation supports focus, Chinese composition and cancellation", async ({ page }) => {
- await page.goto("/e2e/paas/index.html")
- await page.getByLabel("API Key", { exact: true }).fill("project-keyboard")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- const toggle = page.getByRole("button", { name: "新建项目", exact: true })
- await toggle.click()
- const name = page.getByLabel("项目名称", { exact: true })
- await expect(name).toBeFocused()
- await name.fill("材料研究")
- const cancelled = await name.evaluate(
- (input) =>
- !input.dispatchEvent(
- new KeyboardEvent("keydown", {
- key: "Enter",
- isComposing: true,
- bubbles: true,
- cancelable: true,
- }),
- ),
- )
- expect(cancelled).toBe(true)
- await expect(name).toBeVisible()
- await name.press("Escape")
- await expect(name).toHaveCount(0)
- await expect(toggle).toBeFocused()
- await expect(page.getByLabel("切换项目").locator("option", { hasText: "材料研究" })).toHaveCount(0)
- })
- test("role overrides can return to automatic matching without losing the draft", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?agent-groups")
- await page.getByLabel("API Key", { exact: true }).fill("role-reset")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- const input = page.getByRole("textbox", { name: "消息", exact: true })
- await input.fill("合并 CSV 并画趋势图")
- const summary = page.locator(".paas-agent-route > summary")
- const menu = page.locator(".paas-agent-route")
- await summary.click()
- await page.getByLabel("选择执行角色").selectOption({ label: "工作区助手" })
- await expect(summary).toContainText("指定")
- await summary.click()
- await expect(menu).toContainText("已按你的选择指定角色")
- await page.getByLabel("选择执行角色").selectOption("")
- await expect(summary).toContainText("自动 · data67")
- await expect(input).toHaveValue("合并 CSV 并画趋势图")
- await summary.click()
- await page.keyboard.press("Escape")
- await expect(menu).not.toHaveAttribute("open", "")
- await expect(summary).toBeFocused()
- await summary.click()
- await input.click()
- await expect(menu).not.toHaveAttribute("open", "")
- })
- test("project folder errors are recoverable without changing the saved folders", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByLabel("API Key", { exact: true }).fill("folder-retry")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.getByRole("button", { name: "项目设置", exact: true }).click()
- await page.evaluate(() => Object.assign(Reflect.get(window, "paasUX"), { directoryError: "picker failed" }))
- await page.getByRole("button", { name: "添加工作文件夹", exact: true }).click()
- await expect(page.getByRole("alert")).toContainText("未能打开文件夹选择器")
- await expect(page.locator(".paas-project-folder-card")).toHaveCount(0)
- await page.evaluate(() => Object.assign(Reflect.get(window, "paasUX"), { directoryError: "" }))
- await page.getByRole("button", { name: "添加工作文件夹", exact: true }).click()
- await expect(page.locator(".paas-project-folder-card")).toContainText("D:/Research/optics")
- await page.getByRole("button", { name: "完成", exact: true }).click()
- await expect(page.locator(".paas-composer-context")).toContainText("D:/Research/optics")
- })
- for (const width of [360, 520]) {
- test(`role chooser stays within a ${width}px window`, async ({ page }) => {
- await page.setViewportSize({ width, height: 740 })
- await page.emulateMedia({ colorScheme: "dark" })
- await page.goto("/e2e/paas/index.html?agent-groups")
- await page.getByLabel("API Key", { exact: true }).fill(`narrow-${width}`)
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.locator(".paas-agent-route > summary").click()
- const panel = page.locator(".paas-agent-route-panel")
- await expect(panel).toBeVisible()
- const bounds = await panel.boundingBox()
- expect(bounds!.x).toBeGreaterThanOrEqual(0)
- expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width)
- await expect(page.getByLabel("选择执行角色")).toBeVisible()
- expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width)
- })
- }
|