|
|
@@ -41,7 +41,10 @@ test("workspace assistant requires and forwards the project folder", async ({ pa
|
|
|
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,
|
|
|
+ () =>
|
|
|
+ (window as unknown as { paasTestCalls: { action: string }[] }).paasTestCalls.filter(
|
|
|
+ (call) => call.action === "execute",
|
|
|
+ ).length,
|
|
|
),
|
|
|
).toBe(0)
|
|
|
|
|
|
@@ -56,9 +59,10 @@ test("workspace assistant requires and forwards the project folder", async ({ pa
|
|
|
await expect
|
|
|
.poll(() =>
|
|
|
page.evaluate(
|
|
|
- () => (window as unknown as { paasTestCalls: { action: string; workDir?: string }[] }).paasTestCalls.find(
|
|
|
- (call) => call.action === "execute",
|
|
|
- )?.workDir,
|
|
|
+ () =>
|
|
|
+ (window as unknown as { paasTestCalls: { action: string; workDir?: string }[] }).paasTestCalls.find(
|
|
|
+ (call) => call.action === "execute",
|
|
|
+ )?.workDir,
|
|
|
),
|
|
|
)
|
|
|
.toBe("D:/Research/optics")
|
|
|
@@ -88,3 +92,104 @@ test("projects isolate chat history and keep a bound workspace after reload", as
|
|
|
await expect(page.getByLabel("切换项目", { exact: true })).toContainText("光学综述")
|
|
|
await expect(page.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("folder failures can be retried and delayed selections stay with the original project", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("folder-race")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ const project = page.getByLabel("切换项目", { exact: true })
|
|
|
+ const original = await project.inputValue()
|
|
|
+ await page.evaluate(() => {
|
|
|
+ ;(window as unknown as { paasUX: { directoryError: string } }).paasUX.directoryError = "picker failed"
|
|
|
+ })
|
|
|
+ await page.getByRole("button", { name: "绑定工作文件夹", exact: true }).click()
|
|
|
+ await expect(page.getByRole("status").filter({ hasText: "未能打开文件夹选择器" })).toBeVisible()
|
|
|
+ await page.evaluate(() => {
|
|
|
+ const ux = (window as unknown as { paasUX: { directoryError: string; holdDirectory: boolean } }).paasUX
|
|
|
+ ux.directoryError = ""
|
|
|
+ ux.holdDirectory = true
|
|
|
+ })
|
|
|
+ await page.getByRole("button", { name: "绑定工作文件夹", exact: true }).click()
|
|
|
+ await expect(page.getByRole("button", { name: "正在选择文件夹…", exact: true })).toBeDisabled()
|
|
|
+ await page.getByRole("button", { name: "新建项目", exact: true }).click()
|
|
|
+ await page.getByLabel("项目名称", { exact: true }).fill("另一个项目")
|
|
|
+ await page.getByRole("button", { name: "创建项目", exact: true }).click()
|
|
|
+ await page.evaluate(() => {
|
|
|
+ ;(window as unknown as { paasUX: { releaseDirectory: () => void } }).paasUX.releaseDirectory()
|
|
|
+ })
|
|
|
+ await expect(page.getByRole("button", { name: "绑定工作文件夹", exact: true })).toBeEnabled()
|
|
|
+ await expect(page.getByText("D:/Research/optics", { exact: true })).toHaveCount(0)
|
|
|
+ await project.selectOption(original)
|
|
|
+ await expect(page.getByText("D:/Research/optics", { exact: true })).toBeVisible()
|
|
|
+})
|
|
|
+
|
|
|
+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)
|
|
|
+ })
|
|
|
+}
|