| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- import { expect, test } from "@playwright/test"
- test("project artifact library aggregates ended runs and previews files", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?completed&files")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect(page.getByRole("heading", { name: "成果", exact: true })).toBeVisible()
- const group = page.getByRole("region", { name: "已有研究 的成果" })
- await expect(group).toBeVisible()
- await expect(group.getByText("研究计划.pdf", { exact: true })).toBeVisible()
- await expect(group.getByText("研究计划.md", { exact: true })).toBeVisible()
- await expect(group.getByText("config.yml", { exact: true })).toHaveCount(0)
- await expect(page.getByText("7 个文件", { exact: true })).toBeVisible()
- // Different artifact IDs with equal names must remain individually accessible.
- await expect(group.getByText("manifest.json", { exact: true })).toHaveCount(2)
- await page.getByRole("button", { name: "预览 研究计划.md", exact: true }).click()
- const preview = page.getByLabel("右侧预览", { exact: true })
- await expect(preview).toBeVisible()
- await expect(preview.getByText("可预览的研究计划", { exact: true })).toBeVisible()
- await page.getByRole("button", { name: "保存 研究计划.md", exact: true }).click()
- await expect(page.getByText("已保存 研究计划.md", { exact: true })).toBeVisible()
- })
- test("artifact library filters by type and search", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?completed&files")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts-filter")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- const library = page.locator(".paas-artifact-page")
- await page.getByRole("button", { name: "数据 · 3", exact: true }).click()
- await expect(library.getByText("config.yml", { exact: true })).toHaveCount(0)
- await expect(library.getByText("研究计划.md", { exact: true })).toHaveCount(0)
- await page.getByRole("button", { name: "代码 · 1", exact: true }).click()
- await expect(library.getByText("analysis.py", { exact: true })).toBeVisible()
- await expect(library.getByText("config.yml", { exact: true })).toHaveCount(0)
- await page.getByRole("button", { name: "全部 · 7", exact: true }).click()
- await page.getByLabel("搜索成果", { exact: true }).fill("不存在")
- await expect(library.getByText("没有匹配的成果", { exact: true })).toBeVisible()
- await page.getByRole("button", { name: "清除筛选", exact: true }).click()
- await expect(library.getByText("研究计划.md", { exact: true })).toBeVisible()
- })
- test("artifact library switches between session and folder views", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?completed&files")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts-views")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- const group = page.getByRole("region", { name: "已有研究 的成果" })
- await expect(group.getByText("已完成", { exact: true })).toBeVisible()
- await page.getByRole("button", { name: "按目录", exact: true }).click()
- const tree = page.locator(".paas-artifact-tree")
- await expect(tree.getByText("根目录 · 2 个文件", { exact: true })).toBeVisible()
- await expect(tree.getByText("final", { exact: true })).toBeVisible()
- await expect(tree.getByText("work", { exact: true })).toBeVisible()
- await expect(tree.getByText("研究计划.md", { exact: true })).toBeVisible()
- await page.getByRole("button", { name: "按会话", exact: true }).click()
- await group.getByRole("button", { name: "打开会话", exact: true }).click()
- await expect(page.locator(".paas-topbar-page")).toHaveText("会话")
- })
- test("artifact library is scoped to the active project", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?completed")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts-scope")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- 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.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect(page.getByText("还没有可归档的成果", { exact: true })).toBeVisible()
- await expect(page.getByText("研究计划.md", { exact: true })).toHaveCount(0)
- })
- declare global {
- interface Window {
- artifactUX: { failFiles: boolean; holdFiles: boolean; held: boolean; release(): void }
- }
- }
- test("partial artifact discovery remains visible, reports incompleteness and retries when reopened", async ({
- page,
- }) => {
- await page.goto("/e2e/paas/index.html?completed&files")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts-partial")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- await page.evaluate(() => {
- window.artifactUX.failFiles = true
- })
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect(
- page.getByText("部分任务的成果暂未同步,已展示其余内容;可稍后刷新重试。", { exact: true }),
- ).toBeVisible()
- await expect(page.locator(".paas-artifact-page").getByText("研究计划成果.pdf", { exact: true })).toBeVisible()
- await page.locator(".paas-sidebar").getByRole("button", { name: "会话", exact: true }).click()
- await page.evaluate(() => {
- window.artifactUX.failFiles = false
- })
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect(page.locator(".paas-artifact-page").getByText("研究计划.md", { exact: true })).toBeVisible()
- await expect(page.getByText("部分任务的成果暂未同步,已展示其余内容;可稍后刷新重试。", { exact: true })).toHaveCount(
- 0,
- )
- })
- test("late artifact results cannot populate a different project", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?completed&files")
- await page.getByLabel("API Key", { exact: true }).fill("artifacts-late")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page
- .getByRole("button", { name: /已有研究/ })
- .first()
- .click()
- await page.evaluate(() => {
- window.artifactUX.holdFiles = true
- })
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect.poll(() => page.evaluate(() => window.artifactUX.held)).toBe(true)
- 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.artifactUX.holdFiles = false
- window.artifactUX.release()
- })
- await page.locator(".paas-sidebar").getByRole("button", { name: "成果", exact: true }).click()
- await expect(page.getByText("还没有可归档的成果", { exact: true })).toBeVisible()
- await expect(page.locator(".paas-artifact-page .paas-artifact-row")).toHaveCount(0)
- })
|