product-benchmark.spec.ts 1.0 KB

1234567891011121314151617181920
  1. import { expect, test } from "@playwright/test"
  2. import { writeFile } from "node:fs/promises"
  3. test("desktop production task navigation benchmark", async ({ page }) => {
  4. const samples: number[] = []
  5. for (let index = 0; index < 3; index++) {
  6. await page.goto("/e2e/paas/index.html?completed&unified")
  7. await page.getByLabel("API Key", { exact: true }).fill("benchmark")
  8. const start = Date.now()
  9. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  10. await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeVisible()
  11. await page.getByRole("textbox", { name: "消息", exact: true }).fill("整理研究材料")
  12. await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
  13. await expect(page.locator(".paas-report").first()).toBeVisible()
  14. samples.push(Date.now() - start)
  15. }
  16. await writeFile(
  17. process.env.PAAS_BENCHMARK_OUTPUT || "/private/tmp/desktop-product-benchmark.json",
  18. JSON.stringify({ samples, median: [...samples].sort((a, b) => a - b)[1] }),
  19. )
  20. })