import { expect, test } from "@playwright/test" async function connect(page: import("@playwright/test").Page, query = "") { await page.goto(`/e2e/paas/index.html?completed&files&transfer${query}`) await page.getByLabel("API Key", { exact: true }).fill("durability") await page.getByRole("button", { name: "连接平台", exact: true }).click() await page .getByRole("button", { name: /已有研究/ }) .first() .click() await expect(page.locator(".paas-report").first()).toBeVisible() } test("continue artifact makes an editable new draft with the actual attachment, without running it", async ({ page, }) => { await connect(page) await page.getByRole("textbox", { name: "消息", exact: true }).fill("原会话待发送要求") await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click() await page.getByRole("button", { name: "继续处理 研究计划.md", exact: true }).click() await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue( "请基于附件「研究计划.md」继续处理。", ) await expect(page.getByText("研究计划.md", { exact: true }).last()).toBeVisible() expect(await page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "execute").length)).toBe(0) await page.getByRole("textbox", { name: "消息", exact: true }).fill("请继续完善附件中的研究方案") await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter") await expect .poll(() => page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "execute").length)) .toBe(1) const submitted = await page.evaluate(() => window.paasTestCalls.findLast((call) => call.action === "execute")) expect(submitted).toMatchObject({ files: [{ file_id: "continued-file", name: "研究计划.md" }] }) }) test("interrupted stage recovery first attempts safe resume then requires explicit acknowledgement", async ({ page, }) => { await connect(page, "&recovery") const recover = page.getByRole("button", { name: "从已保存进度恢复", exact: true }) await recover.click() await expect(recover).toBeDisabled() await page.locator(".paas-recovery-card").screenshot({ path: "/private/tmp/desktop-round2-recovery.png" }) await page.getByLabel("我已核对执行记录,同意重试未确认完成的步骤").check() await recover.click() await expect(recover).toHaveCount(0) await expect(page.getByRole("button", { name: "停止任务", exact: true }).first()).toBeVisible() const calls = await page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "recover")) expect(calls).toMatchObject([{ retryInterrupted: false }, { retryInterrupted: true }]) expect(await page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "execute").length)).toBe(0) }) test("project backup captures lazy history and restores an independent readable project without replay", async ({ page, }) => { await connect(page) await page.getByRole("textbox", { name: "消息", exact: true }).fill("稍后继续") await page.locator(".paas-sidebar").getByRole("button", { name: "平台设置", exact: true }).click() await page.getByRole("button", { name: "备份当前项目", exact: true }).click() await expect(page.getByText("备份已保存:/backup/project.zip")).toBeVisible() for (const mode of ["light", "dark"]) { await page.evaluate((theme) => { document.documentElement.style.colorScheme = theme document.documentElement.setAttribute("data-color-scheme", theme) }, mode) await page .getByRole("region", { name: "项目备份与恢复", exact: true }) .screenshot({ path: `/private/tmp/desktop-round2-backup-${mode}.png` }) } await page.getByRole("button", { name: "从备份恢复", exact: true }).click() await expect(page.getByLabel("切换项目")).toContainText("我的项目(恢复)") await expect(page.getByText(/已恢复到独立项目/)).toBeVisible() await page.locator(".paas-sidebar").getByRole("button", { name: "会话", exact: true }).click() await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("稍后继续") await expect(page.locator(".paas-report").first()).toBeVisible() expect(await page.evaluate(() => window.paasTestCalls.filter((call) => call.action === "execute").length)).toBe(0) })