import { expect, test } from "@playwright/test"; import fs from "node:fs"; import path from "node:path"; const fixture = path.resolve(import.meta.dirname, "../../..", "tests/files/web/basic_scene.blend"); test("Modeling case adds Cube, transforms, cancels, undoes and reopens", async ({ page }, testInfo) => { await page.goto("/?ui=web"); await page.getByTestId("blend-file-input").setInputFiles(fixture); await expect(page.getByTestId("engine-status")).toContainText("SceneIR"); const webTools = page.getByRole("button", { name: "Web 业务工具", exact: true }); if (await webTools.count()) await webTools.click(); await expect(page.getByTestId("scene-stats")).toContainText("Objects 3"); await page.getByRole("button", { name: "添加立方体", exact: true }).click(); await expect(page.getByTestId("scene-stats")).toContainText("Objects 4"); const beforeCancel = await page.getByTestId("object-location").textContent(); await page.locator(".status-bar").click({ position: { x: 700, y: 10 } }); await page.keyboard.press("g"); await page.keyboard.press("r"); await page.keyboard.press("s"); await expect(page.getByTestId("object-location")).not.toHaveText(beforeCancel ?? ""); const transformed = await page.getByTestId("object-location").textContent(); await page.keyboard.press("Escape"); await expect(page.getByTestId("object-location")).toHaveText(transformed ?? ""); await page.getByRole("button", { name: "撤销", exact: true }).click(); await page.getByRole("button", { name: "重做", exact: true }).click(); const download = page.waitForEvent("download"); await page.getByRole("button", { name: "保存项目", exact: true }).click(); const saved = testInfo.outputPath("b2-modeling.blend"); await (await download).saveAs(saved); await page.setInputFiles("[data-testid=blend-file-input]", saved); await expect(page.getByTestId("scene-stats")).toContainText("Objects 4"); expect(fs.statSync(saved).size).toBeGreaterThan(0); });