|
|
@@ -0,0 +1,107 @@
|
|
|
+import { test, expect } from "@playwright/test"
|
|
|
+
|
|
|
+test("desktop appearance, compact navigation, and project naming", async ({ page }) => {
|
|
|
+ await page.setViewportSize({ width: 1180, height: 720 })
|
|
|
+ await page.goto("/e2e/paas/index.html?ux")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("synthetic")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
|
|
|
+ await page.getByLabel("外观模式").selectOption("light")
|
|
|
+ await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "light")
|
|
|
+ await page.getByLabel("外观模式").selectOption("dark")
|
|
|
+ await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "dark")
|
|
|
+ await page.getByRole("button", { name: "功能导航", exact: true }).click()
|
|
|
+ await expect(page.getByRole("button", { name: "平台任务", exact: true })).toBeHidden()
|
|
|
+ expect(
|
|
|
+ await page.locator(".paas-nav-history").evaluate((el) => el.getBoundingClientRect().height),
|
|
|
+ ).toBeGreaterThanOrEqual(150)
|
|
|
+ await page.getByRole("button", { name: "新建项目", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "选择主文件夹", exact: true }).click()
|
|
|
+ await expect(page.getByRole("textbox", { name: "项目名称", exact: true })).not.toHaveValue("")
|
|
|
+ await page.getByRole("button", { name: "创建项目", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: /工作文件夹 · 1/ }).click()
|
|
|
+ await page.getByRole("button", { name: "重命名项目", exact: true }).click()
|
|
|
+ await page.getByRole("textbox", { name: "项目名称", exact: true }).fill("跨目录项目")
|
|
|
+ await page.getByRole("button", { name: "保存名称", exact: true }).click()
|
|
|
+ await expect(page.getByRole("combobox", { name: "切换项目", exact: true }).locator("option:checked")).toHaveText(
|
|
|
+ "跨目录项目",
|
|
|
+ )
|
|
|
+ await page.screenshot({ path: "/private/tmp/lambda-project-settings.png" })
|
|
|
+})
|
|
|
+
|
|
|
+test("fresh model setup distinguishes a local service from saved credentials", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?setup&ux&unified&fresh-models")
|
|
|
+ await page.getByRole("button", { name: "准备本机服务并连接", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "平台设置", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "检查与配置资源", exact: true }).click()
|
|
|
+ const select = page.getByRole("region", { name: "模型与应用配置" }).getByLabel("模型服务", { exact: true })
|
|
|
+ await expect(select.locator('option[value="anthropic"]')).toHaveText("Anthropic · 未配置")
|
|
|
+ await expect(select.locator('option[value="ollama"]')).toHaveText("Ollama · 本地服务(待测试)")
|
|
|
+ await expect(select).not.toContainText("已配置")
|
|
|
+})
|
|
|
+
|
|
|
+test("multiple folders are shown before submission and forwarded to execution", async ({ page }) => {
|
|
|
+ await page.setViewportSize({ width: 1180, height: 720 })
|
|
|
+ await page.goto("/e2e/paas/index.html?ux&workspace")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("synthetic")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.evaluate(() =>
|
|
|
+ Object.assign(Reflect.get(window, "paasUX"), { directories: ["D:/Project/main", "D:/Project/data"] }),
|
|
|
+ )
|
|
|
+ await page.getByRole("button", { name: "新建项目", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "选择主文件夹", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: "创建项目", exact: true }).click()
|
|
|
+ await page.getByRole("button", { name: /工作文件夹 · 1/ }).click()
|
|
|
+ await page.getByRole("button", { name: "添加工作文件夹", exact: true }).click()
|
|
|
+ const scope = page.locator(".paas-task-scope")
|
|
|
+ await scope.locator(":scope > summary").click()
|
|
|
+ await expect(scope).toContainText("D:/Project/main")
|
|
|
+ await expect(scope).toContainText("D:/Project/data")
|
|
|
+ await expect(scope).toContainText("读取文件")
|
|
|
+ await expect(scope).toContainText("各项目共享")
|
|
|
+ const composer = page.locator("form.paas-composer")
|
|
|
+ const bounds = await composer.boundingBox()
|
|
|
+ const send = await page.getByRole("button", { name: "发送消息", exact: true }).boundingBox()
|
|
|
+ expect(send!.y + send!.height).toBeLessThanOrEqual(bounds!.y + bounds!.height)
|
|
|
+ expect(send!.y + send!.height).toBeLessThanOrEqual(720)
|
|
|
+ await page.getByRole("button", { name: /工作文件夹 · 2/ }).click()
|
|
|
+ await page.getByRole("button", { name: "功能导航", exact: true }).click()
|
|
|
+ await page.getByLabel("外观模式").selectOption("dark")
|
|
|
+ await page.screenshot({ path: "/private/tmp/lambda-task-scope-dark.png" })
|
|
|
+ await page.getByLabel("外观模式").selectOption("light")
|
|
|
+ await page.screenshot({ path: "/private/tmp/lambda-task-scope-light.png" })
|
|
|
+ await page.setViewportSize({ width: 600, height: 800 })
|
|
|
+ await expect(scope).toBeVisible()
|
|
|
+ expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(600)
|
|
|
+ await page.screenshot({ path: "/private/tmp/lambda-task-scope-narrow.png" })
|
|
|
+ await scope.locator(":scope > summary").click()
|
|
|
+ await page.screenshot({ path: "/private/tmp/lambda-task-scope-collapsed.png" })
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("请在工作文件夹中读取项目代码并整理")
|
|
|
+ await page.getByRole("button", { name: "发送消息", exact: true }).click()
|
|
|
+ await expect
|
|
|
+ .poll(() =>
|
|
|
+ page.evaluate(
|
|
|
+ () =>
|
|
|
+ Reflect.get(window, "paasTestCalls")
|
|
|
+ .filter((call: { action: string }) => call.action === "execute")
|
|
|
+ .at(-1)?.workDirs,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ .toEqual(["D:/Project/main", "D:/Project/data"])
|
|
|
+})
|
|
|
+
|
|
|
+test("scope loading failure stays recoverable and does not block ordinary tasks", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?ux")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("synthetic")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.evaluate(() => Object.assign(Reflect.get(window, "paasUX"), { scopeError: true }))
|
|
|
+ const scope = page.locator(".paas-task-scope")
|
|
|
+ await scope.locator(":scope > summary").click()
|
|
|
+ await expect(scope).toContainText("工具范围暂未加载")
|
|
|
+ await page.evaluate(() => Object.assign(Reflect.get(window, "paasUX"), { scopeError: false }))
|
|
|
+ await scope.getByRole("button", { name: "刷新范围" }).click()
|
|
|
+ await expect(scope).toContainText("读取文件")
|
|
|
+ await scope.locator(":scope > summary").click()
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("分析材料")
|
|
|
+ await expect(page.getByRole("button", { name: "发送消息", exact: true })).toBeEnabled()
|
|
|
+})
|