import { expect, test } from "@playwright/test"; test.use({ viewport: { width: 1440, height: 900 } }); async function openSaveAs(page: import("@playwright/test").Page): Promise { await page.getByRole("button", { name: "文件", exact: true }).click(); await page.getByRole("menuitem", { name: "另存为", exact: true }).click(); await page.getByLabel("另存为文件名", { exact: true }).waitFor({ timeout: 30_000 }); } test("Save As writes OPFS only and local .blend requires the explicit download action", async ({ page }) => { test.setTimeout(240_000); await page.goto("/?ui=web"); await page.locator("main.blender-app").waitFor({ timeout: 120_000 }); await expect(page.getByTestId("scene-stats")).toBeVisible({ timeout: 120_000 }); await openSaveAs(page); await expect(page.getByText("不会自动下载文件", { exact: false })).toBeVisible(); await page.getByLabel("另存为文件名", { exact: true }).fill("manual-save-as.blend"); const unexpectedDownload = page.waitForEvent("download", { timeout: 2_000 }).then(() => true).catch(() => false); await page.getByRole("button", { name: "确认", exact: true }).click(); expect(await unexpectedDownload).toBe(false); await expect(page.locator("main.blender-app")).toHaveAttribute("data-user-action-save-as-status", "SUCCEEDED", { timeout: 60_000 }); const download = page.waitForEvent("download", { timeout: 60_000 }); await page.locator('button[aria-label="下载 .blend"]').evaluate((element) => (element as HTMLElement).click()); expect((await download).suggestedFilename()).toMatch(/\.blend$/); });