| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { expect, test, type Page } from "@playwright/test"
- async function connect(page: Page) {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByLabel("API Key", { exact: true }).fill("acceptance")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
- }
- test("IME confirmation retains the draft until a separate Enter sends it", async ({ page }) => {
- await connect(page)
- const input = page.getByRole("textbox", { name: "消息", exact: true })
- await input.fill("确认中文研究目标")
- await input.dispatchEvent("keydown", { key: "Enter", code: "Enter", keyCode: 229, bubbles: true })
- await expect(input).toHaveValue("确认中文研究目标")
- expect(
- await page.evaluate(
- () =>
- (window as unknown as { paasTestCalls: { action: string }[] }).paasTestCalls.filter(
- (c) => c.action === "execute",
- ).length,
- ),
- ).toBe(0)
- await input.press("Enter")
- await expect(input).toHaveValue("")
- })
- test("widening the window releases the drawer keyboard trap", async ({ page }) => {
- await page.setViewportSize({ width: 587, height: 800 })
- await connect(page)
- await page.getByRole("button", { name: "打开导航", exact: true }).click()
- await expect(page.locator(".paas-nav-open")).toHaveCount(1)
- await page.setViewportSize({ width: 1280, height: 800 })
- await expect(page.locator(".paas-nav-open")).toHaveCount(0)
- await page.setViewportSize({ width: 587, height: 800 })
- await expect(page.getByRole("button", { name: "打开导航", exact: true })).toBeVisible()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeInViewport()
- })
- test("choosing a suggested research task focuses the editable draft", async ({ page }) => {
- await connect(page)
- await page.locator(".paas-suggestions button").first().click()
- const input = page.getByRole("textbox", { name: "消息", exact: true })
- await expect(input).toBeFocused()
- await expect(input).not.toHaveValue("")
- })
- test("long attachment names keep removal and sending accessible in narrow windows", async ({ page }) => {
- await page.setViewportSize({ width: 520, height: 705 })
- await connect(page)
- const name = `${"research_material_".repeat(15)}.txt`
- const transfer = await page.evaluateHandle((name) => {
- const data = new DataTransfer()
- data.items.add(new File(["research"], name, { type: "text/plain" }))
- return data
- }, name)
- await page.locator(".paas-composer").dispatchEvent("drop", { dataTransfer: transfer })
- const remove = page.getByRole("button", { name: `移除${name}`, exact: true })
- await expect(remove).toBeInViewport()
- expect(await page.locator(".paas-composer").evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true)
- await remove.click()
- await expect(remove).toHaveCount(0)
- })
- test("partial research explains generated output failures and keeps the report available", async ({ page }) => {
- await connect(page)
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("部分成果验收")
- await page.getByRole("button", { name: "发送消息", exact: true }).click()
- await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible()
- await page.evaluate(() =>
- window.paasUX.update("ux_1", {
- status: "partial",
- output: "已保留的研究方案",
- research: {
- science: {
- outcome: {
- plan: {
- issues: [
- {
- code: "review_format_failure",
- stage: "round-01-plan-build",
- message: "Plan generation exhausted local structural repairs; prior artifacts were preserved",
- },
- ],
- },
- },
- },
- },
- }),
- )
- await page.getByRole("button", { name: "刷新状态", exact: true }).click()
- await page.getByText("待处理原因(1 项)", { exact: true }).click()
- await expect(page.getByText("生成结果未通过格式校验", { exact: true })).toBeVisible()
- await expect(page.getByText("需要检查输入材料", { exact: true })).toHaveCount(0)
- await expect(page.getByRole("button", { name: "基于已有成果续研", exact: true })).toBeVisible()
- await expect(page.getByRole("button", { name: "阅读与对比", exact: true })).toBeVisible()
- })
|